mirror of
https://github.com/ItsDrike/nixdots
synced 2024-12-26 05:54:35 +00:00
Fix shebang in eww scripts
This commit is contained in:
parent
408e9fc6cb
commit
142ad87364
|
@ -1,82 +1,82 @@
|
||||||
#!/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ "$1" = "temperature" ]; then
|
if [ "$1" = "temperature" ]; then
|
||||||
watch_cmd="{t}"
|
watch_cmd="{t}"
|
||||||
update_cmd="UpdateTemperature"
|
update_cmd="UpdateTemperature"
|
||||||
update_signature="n"
|
update_signature="n"
|
||||||
set_cmd="Temperature"
|
set_cmd="Temperature"
|
||||||
set_signature="q"
|
set_signature="q"
|
||||||
default_val=6500
|
default_val=6500
|
||||||
click_val=4500
|
click_val=4500
|
||||||
scroll_change=100
|
scroll_change=100
|
||||||
cmp_op="<"
|
cmp_op="<"
|
||||||
|
|
||||||
elif [ "$1" = "brightness" ]; then
|
elif [ "$1" = "brightness" ]; then
|
||||||
watch_cmd="{bp}"
|
watch_cmd="{bp}"
|
||||||
update_cmd="UpdateBrightness"
|
update_cmd="UpdateBrightness"
|
||||||
update_signature="d"
|
update_signature="d"
|
||||||
set_cmd="Brightness"
|
set_cmd="Brightness"
|
||||||
set_signature="d"
|
set_signature="d"
|
||||||
default_val=1
|
default_val=1
|
||||||
click_val=0.8
|
click_val=0.8
|
||||||
scroll_change=0.02
|
scroll_change=0.02
|
||||||
cmp_op="<"
|
cmp_op="<"
|
||||||
|
|
||||||
elif [ "$1" = "gamma" ]; then
|
elif [ "$1" = "gamma" ]; then
|
||||||
watch_cmd="{g}"
|
watch_cmd="{g}"
|
||||||
update_cmd="UpdateGamma"
|
update_cmd="UpdateGamma"
|
||||||
update_signature="d"
|
update_signature="d"
|
||||||
set_cmd="Gamma"
|
set_cmd="Gamma"
|
||||||
set_signature="d"
|
set_signature="d"
|
||||||
default_val=1
|
default_val=1
|
||||||
click_val=1.1
|
click_val=1.1
|
||||||
scroll_change=0.02
|
scroll_change=0.02
|
||||||
cmp_op=">"
|
cmp_op=">"
|
||||||
|
|
||||||
else
|
else
|
||||||
>&2 echo "Invalid option, first argument must be one of: temperature, brightness, gamma"
|
>&2 echo "Invalid option, first argument must be one of: temperature, brightness, gamma"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$2" = "watch" ]; then
|
if [ "$2" = "watch" ]; then
|
||||||
exec wl-gammarelay-rs watch "$watch_cmd"
|
exec wl-gammarelay-rs watch "$watch_cmd"
|
||||||
|
|
||||||
elif [ "$2" = "get" ]; then
|
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
|
elif [ "$2" = "scroll" ]; then
|
||||||
if [ "$3" = "up" ]; then
|
if [ "$3" = "up" ]; then
|
||||||
sign="+"
|
sign="+"
|
||||||
elif [ "$3" = "down" ]; then
|
elif [ "$3" = "down" ]; then
|
||||||
sign="-"
|
sign="-"
|
||||||
else
|
else
|
||||||
>&2 echo "Invalid sign, second argument must be one of: up, down"
|
>&2 echo "Invalid sign, second argument must be one of: up, down"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
elif [ "$2" = "set" ]; then
|
||||||
mode="$3"
|
mode="$3"
|
||||||
if [ "$mode" = "toggle" ]; then
|
if [ "$mode" = "toggle" ]; then
|
||||||
cur_val="$(busctl --user get-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" | cut -d' ' -f2)"
|
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
|
if [ "$(echo "$cur_val $cmp_op $default_val" | bc -l)" = "1" ]; then
|
||||||
mode="off"
|
mode="off"
|
||||||
else
|
else
|
||||||
mode="on"
|
mode="on"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$mode" = "on" ]; then
|
if [ "$mode" = "on" ]; then
|
||||||
exec busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" "$set_signature" "$click_val"
|
exec busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" "$set_signature" "$click_val"
|
||||||
elif [ "$mode" = "off" ]; then
|
elif [ "$mode" = "off" ]; then
|
||||||
exec busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" "$set_signature" "$default_val"
|
exec busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" "$set_signature" "$default_val"
|
||||||
else
|
else
|
||||||
>&2 echo "Invalid mode, third argument, must be one of: toggle, on, off"
|
>&2 echo "Invalid mode, third argument, must be one of: toggle, on, off"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
>&2 echo "Invalid operation, second argument must be one of: watch, scroll, set"
|
>&2 echo "Invalid operation, second argument must be one of: watch, scroll, set"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# $1: Current number
|
# $1: Current number
|
||||||
# $2: Range minimum
|
# $2: Range minimum
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# shellcheck source=include
|
# shellcheck source=include
|
||||||
source "./scripts/include"
|
source "./scripts/include"
|
||||||
|
@ -8,5 +8,5 @@ source "./scripts/include"
|
||||||
# not be enough.
|
# not be enough.
|
||||||
|
|
||||||
if [ "$1" = "toggle" ]; then
|
if [ "$1" = "toggle" ]; then
|
||||||
gammastep -x
|
gammastep -x
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
#!/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
MOUNTPOINTS=("/" "/mnt/ext")
|
MOUNTPOINTS=("/" "/mnt/ext")
|
||||||
|
|
||||||
data="$(df -H)"
|
data="$(df -H)"
|
||||||
|
|
||||||
as_json() {
|
as_json() {
|
||||||
mountpoint="$1"
|
mountpoint="$1"
|
||||||
res="$2"
|
res="$2"
|
||||||
arr_res=($res)
|
arr_res=($res)
|
||||||
|
|
||||||
jq -n -c --monochrome-output \
|
jq -n -c --monochrome-output \
|
||||||
--arg mountpoint "$mountpoint" \
|
--arg mountpoint "$mountpoint" \
|
||||||
--arg size "${arr_res[0]}" \
|
--arg size "${arr_res[0]}" \
|
||||||
--arg used "${arr_res[1]}" \
|
--arg used "${arr_res[1]}" \
|
||||||
--arg avail "${arr_res[2]}" \
|
--arg avail "${arr_res[2]}" \
|
||||||
--arg percent "${arr_res[3]}" \
|
--arg percent "${arr_res[3]}" \
|
||||||
'$ARGS.named'
|
'$ARGS.named'
|
||||||
}
|
}
|
||||||
|
|
||||||
output_json="[]"
|
output_json="[]"
|
||||||
for mountpoint in "${MOUNTPOINTS[@]}"; do
|
for mountpoint in "${MOUNTPOINTS[@]}"; do
|
||||||
res="$(echo "$data" | awk -v m="$mountpoint" '$6 == m {print $2 " " $3 " " $4 " " $5}')"
|
res="$(echo "$data" | awk -v m="$mountpoint" '$6 == m {print $2 " " $3 " " $4 " " $5}')"
|
||||||
out="$(as_json "$mountpoint" "$res")"
|
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 \
|
jq --argjson arr1 "$output_json" --argjson arr2 "[$out]" -n \
|
||||||
'$arr1 + $arr2'
|
'$arr1 + $arr2'
|
||||||
|
|
||||||
# mount_data+=("$mountpoint" $res)
|
# mount_data+=("$mountpoint" $res)
|
||||||
# echo "${mount_data[@]}"
|
# echo "${mount_data[@]}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# echo "${mount_data[@]}"
|
# echo "${mount_data[@]}"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# shellcheck source=include
|
# shellcheck source=include
|
||||||
source "./scripts/include"
|
source "./scripts/include"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Define some icons
|
# Define some icons
|
||||||
SPEAKER_ICONS=("" "" "")
|
SPEAKER_ICONS=("" "" "")
|
||||||
|
@ -10,64 +10,64 @@ MIC_MUTED_ICON=""
|
||||||
|
|
||||||
# $1 can either be "SINK" (speaker) or "SOURCE" (microphone)
|
# $1 can either be "SINK" (speaker) or "SOURCE" (microphone)
|
||||||
get_vol() {
|
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)
|
# $1 can either be "SINK" (speaker) or "SOURCE" (microphone)
|
||||||
# #2 is the voulme (as percentage) to set the volume to
|
# #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
|
# $3 is optional, if set, it can be '+' or '-', which then adds/decreases volume, instead of setting
|
||||||
set_vol() {
|
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)
|
# $1 can either be "SINK" (speaker) or "SOURCE" (microphone)
|
||||||
check_mute() {
|
check_mute() {
|
||||||
wpctl get-volume "@DEFAULT_AUDIO_${1}@" | grep -i muted >/dev/null
|
wpctl get-volume "@DEFAULT_AUDIO_${1}@" | grep -i muted >/dev/null
|
||||||
echo $?
|
echo $?
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1 can either be "SINK" (speaker) or "SOURCE" (microphone)
|
# $1 can either be "SINK" (speaker) or "SOURCE" (microphone)
|
||||||
toggle_mute() {
|
toggle_mute() {
|
||||||
wpctl set-mute "@DEFAULT_AUDIO_${1}@" toggle
|
wpctl set-mute "@DEFAULT_AUDIO_${1}@" toggle
|
||||||
}
|
}
|
||||||
|
|
||||||
get_report() {
|
get_report() {
|
||||||
spkr_vol="$(get_vol "SINK")"
|
spkr_vol="$(get_vol "SINK")"
|
||||||
mic_vol="$(get_vol "SOURCE")"
|
mic_vol="$(get_vol "SOURCE")"
|
||||||
|
|
||||||
if [ "$(check_mute "SINK")" == "0" ]; then
|
if [ "$(check_mute "SINK")" == "0" ]; then
|
||||||
spkr_mute="true"
|
spkr_mute="true"
|
||||||
spkr_icon="$SPEAKER_MUTED_ICON"
|
spkr_icon="$SPEAKER_MUTED_ICON"
|
||||||
else
|
else
|
||||||
spkr_mute="false"
|
spkr_mute="false"
|
||||||
index="$(awk -v n="$spkr_vol" -v m="${#SPEAKER_ICONS[@]}" 'BEGIN{print int(n/(100/m))}')"
|
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%
|
# 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
|
# in this case, set the index to last icon
|
||||||
if [ "$index" -ge "${#SPEAKER_ICONS[@]}" ]; then
|
if [ "$index" -ge "${#SPEAKER_ICONS[@]}" ]; then
|
||||||
spkr_icon="${SPEAKER_ICONS[-1]}"
|
spkr_icon="${SPEAKER_ICONS[-1]}"
|
||||||
else
|
else
|
||||||
spkr_icon="${SPEAKER_ICONS[$index]}"
|
spkr_icon="${SPEAKER_ICONS[$index]}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(check_mute "SOURCE")" = "0" ]; then
|
if [ "$(check_mute "SOURCE")" = "0" ]; then
|
||||||
mic_mute="true"
|
mic_mute="true"
|
||||||
mic_icon="$MIC_MUTED_ICON"
|
mic_icon="$MIC_MUTED_ICON"
|
||||||
else
|
else
|
||||||
mic_mute="false"
|
mic_mute="false"
|
||||||
mic_icon="$MIC_ICON"
|
mic_icon="$MIC_ICON"
|
||||||
fi
|
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)
|
# Continually run and report every volume change (into stdout)
|
||||||
loop() {
|
loop() {
|
||||||
get_report
|
get_report
|
||||||
pactl subscribe | grep --line-buffered "change" | while read -r _; do
|
pactl subscribe | grep --line-buffered "change" | while read -r _; do
|
||||||
get_report
|
get_report
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -76,37 +76,37 @@ case "$1" in
|
||||||
"once") get_report ;;
|
"once") get_report ;;
|
||||||
|
|
||||||
"togglemute")
|
"togglemute")
|
||||||
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
|
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
|
||||||
>&2 echo "Invalid usage, expected second argument to be 'SINK' or 'SOURCE', got '$2'"
|
>&2 echo "Invalid usage, expected second argument to be 'SINK' or 'SOURCE', got '$2'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
toggle_mute "$2"
|
toggle_mute "$2"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"setvol")
|
"setvol")
|
||||||
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
|
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
|
||||||
>&2 echo "Invalid usage, expected second argument to be 'SINK' or 'SOURCE', got '$2'"
|
>&2 echo "Invalid usage, expected second argument to be 'SINK' or 'SOURCE', got '$2'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$3" =~ ^[+-]?[0-9]*\.?[0-9]+$ ]]; then
|
if [[ "$3" =~ ^[+-]?[0-9]*\.?[0-9]+$ ]]; then
|
||||||
case "$4" in
|
case "$4" in
|
||||||
"") set_vol "$2" "$3" ;;
|
"") set_vol "$2" "$3" ;;
|
||||||
up | +) set_vol "$2" "$3" "+" ;;
|
up | +) set_vol "$2" "$3" "+" ;;
|
||||||
down | -) set_vol "$2" "$3" "-" ;;
|
down | -) set_vol "$2" "$3" "-" ;;
|
||||||
*)
|
*)
|
||||||
>&2 echo "Invalid usage, expected fourth argument to be up/down or +/-, got '$4'"
|
>&2 echo "Invalid usage, expected fourth argument to be up/down or +/-, got '$4'"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
>&2 echo "Invalid usage, exepcted third argument to be a number, got '$3'"
|
>&2 echo "Invalid usage, exepcted third argument to be a number, got '$3'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
>&2 echo "Invalid usage, argument '$1' not recognized."
|
>&2 echo "Invalid usage, argument '$1' not recognized."
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# shellcheck source=include
|
# shellcheck source=include
|
||||||
source "./scripts/include"
|
source "./scripts/include"
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#!/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# shellcheck source=include
|
# shellcheck source=include
|
||||||
source "./scripts/include"
|
source "./scripts/include"
|
||||||
|
|
||||||
if [ "$1" = "--switch" ]; then
|
if [ "$1" = "--switch" ]; then
|
||||||
$HOME/.local/bin/scripts/gui/hyprland/swap-workspace "$2" >/dev/null
|
$HOME/.local/bin/scripts/gui/hyprland/swap-workspace "$2" >/dev/null
|
||||||
# hyprctl dispatch workspace "$2" >/dev/null
|
# hyprctl dispatch workspace "$2" >/dev/null
|
||||||
elif [ "$1" = "--loop" ]; then
|
elif [ "$1" = "--loop" ]; then
|
||||||
hyprland_ipc "workspace|createworkspace|destroyworkspace" | ./scripts/workspaces.py "$@"
|
hyprland_ipc "workspace|createworkspace|destroyworkspace" | ./scripts/workspaces.py "$@"
|
||||||
else
|
else
|
||||||
./scripts/workspaces.py "$@"
|
./scripts/workspaces.py "$@"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue