Fix shebang in eww scripts

This commit is contained in:
ItsDrike 2024-06-20 14:53:31 +02:00
parent 408e9fc6cb
commit 142ad87364
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
8 changed files with 150 additions and 150 deletions

View file

@ -1,82 +1,82 @@
#!/bin/env bash
#!/usr/bin/env bash
if [ "$1" = "temperature" ]; then
watch_cmd="{t}"
update_cmd="UpdateTemperature"
update_signature="n"
set_cmd="Temperature"
set_signature="q"
default_val=6500
click_val=4500
scroll_change=100
cmp_op="<"
watch_cmd="{t}"
update_cmd="UpdateTemperature"
update_signature="n"
set_cmd="Temperature"
set_signature="q"
default_val=6500
click_val=4500
scroll_change=100
cmp_op="<"
elif [ "$1" = "brightness" ]; then
watch_cmd="{bp}"
update_cmd="UpdateBrightness"
update_signature="d"
set_cmd="Brightness"
set_signature="d"
default_val=1
click_val=0.8
scroll_change=0.02
cmp_op="<"
watch_cmd="{bp}"
update_cmd="UpdateBrightness"
update_signature="d"
set_cmd="Brightness"
set_signature="d"
default_val=1
click_val=0.8
scroll_change=0.02
cmp_op="<"
elif [ "$1" = "gamma" ]; then
watch_cmd="{g}"
update_cmd="UpdateGamma"
update_signature="d"
set_cmd="Gamma"
set_signature="d"
default_val=1
click_val=1.1
scroll_change=0.02
cmp_op=">"
watch_cmd="{g}"
update_cmd="UpdateGamma"
update_signature="d"
set_cmd="Gamma"
set_signature="d"
default_val=1
click_val=1.1
scroll_change=0.02
cmp_op=">"
else
>&2 echo "Invalid option, first argument must be one of: temperature, brightness, gamma"
exit 1
>&2 echo "Invalid option, first argument must be one of: temperature, brightness, gamma"
exit 1
fi
if [ "$2" = "watch" ]; then
exec wl-gammarelay-rs watch "$watch_cmd"
exec wl-gammarelay-rs watch "$watch_cmd"
elif [ "$2" = "get" ]; then
exec busctl --user get-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" | cut -d' ' -f2
exec busctl --user get-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" | cut -d' ' -f2
elif [ "$2" = "scroll" ]; then
if [ "$3" = "up" ]; then
sign="+"
elif [ "$3" = "down" ]; then
sign="-"
else
>&2 echo "Invalid sign, second argument must be one of: up, down"
exit 1
fi
if [ "$3" = "up" ]; then
sign="+"
elif [ "$3" = "down" ]; then
sign="-"
else
>&2 echo "Invalid sign, second argument must be one of: up, down"
exit 1
fi
exec busctl --user -- call rs.wl-gammarelay / rs.wl.gammarelay "$update_cmd" "$update_signature" ${sign}${scroll_change}
exec busctl --user -- call rs.wl-gammarelay / rs.wl.gammarelay "$update_cmd" "$update_signature" ${sign}${scroll_change}
elif [ "$2" = "set" ]; then
mode="$3"
if [ "$mode" = "toggle" ]; then
cur_val="$(busctl --user get-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" | cut -d' ' -f2)"
if [ "$(echo "$cur_val $cmp_op $default_val" | bc -l)" = "1" ]; then
mode="off"
else
mode="on"
fi
fi
mode="$3"
if [ "$mode" = "toggle" ]; then
cur_val="$(busctl --user get-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" | cut -d' ' -f2)"
if [ "$(echo "$cur_val $cmp_op $default_val" | bc -l)" = "1" ]; then
mode="off"
else
mode="on"
fi
fi
if [ "$mode" = "on" ]; then
exec busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" "$set_signature" "$click_val"
elif [ "$mode" = "off" ]; then
exec busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" "$set_signature" "$default_val"
else
>&2 echo "Invalid mode, third argument, must be one of: toggle, on, off"
exit 1
fi
if [ "$mode" = "on" ]; then
exec busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" "$set_signature" "$click_val"
elif [ "$mode" = "off" ]; then
exec busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" "$set_signature" "$default_val"
else
>&2 echo "Invalid mode, third argument, must be one of: toggle, on, off"
exit 1
fi
else
>&2 echo "Invalid operation, second argument must be one of: watch, scroll, set"
exit 1
>&2 echo "Invalid operation, second argument must be one of: watch, scroll, set"
exit 1
fi

View file

@ -1,4 +1,4 @@
#!/bin/env bash
#!/usr/bin/env bash
# $1: Current number
# $2: Range minimum

View file

@ -1,4 +1,4 @@
#!/bin/env bash
#!/usr/bin/env bash
# shellcheck source=include
source "./scripts/include"
@ -8,5 +8,5 @@ source "./scripts/include"
# not be enough.
if [ "$1" = "toggle" ]; then
gammastep -x
gammastep -x
fi

View file

@ -1,35 +1,35 @@
#!/bin/env bash
#!/usr/bin/env bash
MOUNTPOINTS=("/" "/mnt/ext")
data="$(df -H)"
as_json() {
mountpoint="$1"
res="$2"
arr_res=($res)
mountpoint="$1"
res="$2"
arr_res=($res)
jq -n -c --monochrome-output \
--arg mountpoint "$mountpoint" \
--arg size "${arr_res[0]}" \
--arg used "${arr_res[1]}" \
--arg avail "${arr_res[2]}" \
--arg percent "${arr_res[3]}" \
'$ARGS.named'
jq -n -c --monochrome-output \
--arg mountpoint "$mountpoint" \
--arg size "${arr_res[0]}" \
--arg used "${arr_res[1]}" \
--arg avail "${arr_res[2]}" \
--arg percent "${arr_res[3]}" \
'$ARGS.named'
}
output_json="[]"
for mountpoint in "${MOUNTPOINTS[@]}"; do
res="$(echo "$data" | awk -v m="$mountpoint" '$6 == m {print $2 " " $3 " " $4 " " $5}')"
out="$(as_json "$mountpoint" "$res")"
res="$(echo "$data" | awk -v m="$mountpoint" '$6 == m {print $2 " " $3 " " $4 " " $5}')"
out="$(as_json "$mountpoint" "$res")"
# echo "$output_json $out" | jq -c -s
# echo "$output_json $out" | jq -c -s
jq --argjson arr1 "$output_json" --argjson arr2 "[$out]" -n \
'$arr1 + $arr2'
jq --argjson arr1 "$output_json" --argjson arr2 "[$out]" -n \
'$arr1 + $arr2'
# mount_data+=("$mountpoint" $res)
# echo "${mount_data[@]}"
# mount_data+=("$mountpoint" $res)
# echo "${mount_data[@]}"
done
# echo "${mount_data[@]}"

View file

@ -1,4 +1,4 @@
#!/bin/env bash
#!/usr/bin/env bash
# shellcheck source=include
source "./scripts/include"

View file

@ -1,4 +1,4 @@
#!/bin/env bash
#!/usr/bin/env bash
# Define some icons
SPEAKER_ICONS=("" "" "")
@ -10,64 +10,64 @@ MIC_MUTED_ICON=""
# $1 can either be "SINK" (speaker) or "SOURCE" (microphone)
get_vol() {
wpctl get-volume "@DEFAULT_AUDIO_${1}@" | awk '{print int($2*100)}'
wpctl get-volume "@DEFAULT_AUDIO_${1}@" | awk '{print int($2*100)}'
}
# $1 can either be "SINK" (speaker) or "SOURCE" (microphone)
# #2 is the voulme (as percentage) to set the volume to
# $3 is optional, if set, it can be '+' or '-', which then adds/decreases volume, instead of setting
set_vol() {
wpctl set-volume "@DEFAULT_AUDIO_${1}@" "$(awk -v n="$2" 'BEGIN{print (n / 100)}')$3"
wpctl set-volume "@DEFAULT_AUDIO_${1}@" "$(awk -v n="$2" 'BEGIN{print (n / 100)}')$3"
}
# $1 can either be "SINK" (speaker) or "SOURCE" (microphone)
check_mute() {
wpctl get-volume "@DEFAULT_AUDIO_${1}@" | grep -i muted >/dev/null
echo $?
wpctl get-volume "@DEFAULT_AUDIO_${1}@" | grep -i muted >/dev/null
echo $?
}
# $1 can either be "SINK" (speaker) or "SOURCE" (microphone)
toggle_mute() {
wpctl set-mute "@DEFAULT_AUDIO_${1}@" toggle
wpctl set-mute "@DEFAULT_AUDIO_${1}@" toggle
}
get_report() {
spkr_vol="$(get_vol "SINK")"
mic_vol="$(get_vol "SOURCE")"
spkr_vol="$(get_vol "SINK")"
mic_vol="$(get_vol "SOURCE")"
if [ "$(check_mute "SINK")" == "0" ]; then
spkr_mute="true"
spkr_icon="$SPEAKER_MUTED_ICON"
else
spkr_mute="false"
index="$(awk -v n="$spkr_vol" -v m="${#SPEAKER_ICONS[@]}" 'BEGIN{print int(n/(100/m))}')"
if [ "$(check_mute "SINK")" == "0" ]; then
spkr_mute="true"
spkr_icon="$SPEAKER_MUTED_ICON"
else
spkr_mute="false"
index="$(awk -v n="$spkr_vol" -v m="${#SPEAKER_ICONS[@]}" 'BEGIN{print int(n/(100/m))}')"
# We might end up with an higher than the length of icons, if the volume is over 100%
# in this case, set the index to last icon
if [ "$index" -ge "${#SPEAKER_ICONS[@]}" ]; then
spkr_icon="${SPEAKER_ICONS[-1]}"
else
spkr_icon="${SPEAKER_ICONS[$index]}"
fi
fi
# We might end up with an higher than the length of icons, if the volume is over 100%
# in this case, set the index to last icon
if [ "$index" -ge "${#SPEAKER_ICONS[@]}" ]; then
spkr_icon="${SPEAKER_ICONS[-1]}"
else
spkr_icon="${SPEAKER_ICONS[$index]}"
fi
fi
if [ "$(check_mute "SOURCE")" = "0" ]; then
mic_mute="true"
mic_icon="$MIC_MUTED_ICON"
else
mic_mute="false"
mic_icon="$MIC_ICON"
fi
if [ "$(check_mute "SOURCE")" = "0" ]; then
mic_mute="true"
mic_icon="$MIC_MUTED_ICON"
else
mic_mute="false"
mic_icon="$MIC_ICON"
fi
echo "{ \"speaker_vol\": \"$spkr_vol\", \"speaker_mute\": $spkr_mute, \"speaker_icon\": \"$spkr_icon\", \"microphone_mute\": $mic_mute, \"microphone_vol\": \"$mic_vol\", \"microphone_icon\": \"$mic_icon\" }"
echo "{ \"speaker_vol\": \"$spkr_vol\", \"speaker_mute\": $spkr_mute, \"speaker_icon\": \"$spkr_icon\", \"microphone_mute\": $mic_mute, \"microphone_vol\": \"$mic_vol\", \"microphone_icon\": \"$mic_icon\" }"
}
# Continually run and report every volume change (into stdout)
loop() {
get_report
pactl subscribe | grep --line-buffered "change" | while read -r _; do
get_report
done
get_report
pactl subscribe | grep --line-buffered "change" | while read -r _; do
get_report
done
}
case "$1" in
@ -76,37 +76,37 @@ case "$1" in
"once") get_report ;;
"togglemute")
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
>&2 echo "Invalid usage, expected second argument to be 'SINK' or 'SOURCE', got '$2'"
exit 1
fi
toggle_mute "$2"
;;
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
>&2 echo "Invalid usage, expected second argument to be 'SINK' or 'SOURCE', got '$2'"
exit 1
fi
toggle_mute "$2"
;;
"setvol")
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
>&2 echo "Invalid usage, expected second argument to be 'SINK' or 'SOURCE', got '$2'"
exit 1
fi
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
>&2 echo "Invalid usage, expected second argument to be 'SINK' or 'SOURCE', got '$2'"
exit 1
fi
if [[ "$3" =~ ^[+-]?[0-9]*\.?[0-9]+$ ]]; then
case "$4" in
"") set_vol "$2" "$3" ;;
up | +) set_vol "$2" "$3" "+" ;;
down | -) set_vol "$2" "$3" "-" ;;
*)
>&2 echo "Invalid usage, expected fourth argument to be up/down or +/-, got '$4'"
exit 1
;;
esac
else
>&2 echo "Invalid usage, exepcted third argument to be a number, got '$3'"
exit 1
fi
;;
if [[ "$3" =~ ^[+-]?[0-9]*\.?[0-9]+$ ]]; then
case "$4" in
"") set_vol "$2" "$3" ;;
up | +) set_vol "$2" "$3" "+" ;;
down | -) set_vol "$2" "$3" "-" ;;
*)
>&2 echo "Invalid usage, expected fourth argument to be up/down or +/-, got '$4'"
exit 1
;;
esac
else
>&2 echo "Invalid usage, exepcted third argument to be a number, got '$3'"
exit 1
fi
;;
*)
>&2 echo "Invalid usage, argument '$1' not recognized."
exit 1
;;
>&2 echo "Invalid usage, argument '$1' not recognized."
exit 1
;;
esac

View file

@ -1,4 +1,4 @@
#!/bin/env bash
#!/usr/bin/env bash
# shellcheck source=include
source "./scripts/include"

View file

@ -1,13 +1,13 @@
#!/bin/env bash
#!/usr/bin/env bash
# shellcheck source=include
source "./scripts/include"
if [ "$1" = "--switch" ]; then
$HOME/.local/bin/scripts/gui/hyprland/swap-workspace "$2" >/dev/null
# hyprctl dispatch workspace "$2" >/dev/null
$HOME/.local/bin/scripts/gui/hyprland/swap-workspace "$2" >/dev/null
# hyprctl dispatch workspace "$2" >/dev/null
elif [ "$1" = "--loop" ]; then
hyprland_ipc "workspace|createworkspace|destroyworkspace" | ./scripts/workspaces.py "$@"
hyprland_ipc "workspace|createworkspace|destroyworkspace" | ./scripts/workspaces.py "$@"
else
./scripts/workspaces.py "$@"
./scripts/workspaces.py "$@"
fi