feat: bash
This commit is contained in:
parent
937ab54f8c
commit
7ae0b331cf
30 changed files with 517 additions and 65 deletions
|
@ -13,7 +13,6 @@ function set_light() {
|
|||
echo "$((CUR * max / 100))" > "$1/brightness"
|
||||
}
|
||||
|
||||
NOTIFY=(notify-send -t 1000 -a "$(basename "$0")" -u low)
|
||||
|
||||
DIRS=(/sys/class/backlight/*)
|
||||
CUR="$(get_current "${DIRS[0]}")"
|
||||
|
@ -34,4 +33,5 @@ for d in "${DIRS[@]}"; do
|
|||
set_light "$d"
|
||||
done
|
||||
|
||||
"${NOTIFY[@]}" -h string:synchronous:light -h int:value:"$CUR" "$CUR%"
|
||||
notify-send -t 1000 -u low -i display-brightness-symbolic \
|
||||
-h string:synchronous:light -h int:value:"$CUR" "$CUR%"
|
||||
|
|
|
@ -35,7 +35,7 @@ function update_sink_vol() {
|
|||
sink_vol='🔇'
|
||||
return
|
||||
fi
|
||||
vol="$(awk '{print int($2 * 100)}' <<< "$sink")"
|
||||
vol="$(awk '{printf "%.0f", $2 * 100}' <<< "$sink")"
|
||||
{ [ "$vol" -gt 67 ] && sink_vol=" $vol"; } ||
|
||||
{ [ "$vol" -gt 33 ] && sink_vol=" $vol"; } ||
|
||||
{ sink_vol=" $vol"; }
|
||||
|
@ -49,18 +49,18 @@ function update_source_vol() {
|
|||
source_vol=''
|
||||
return
|
||||
fi
|
||||
source_vol=" $(awk '{print int($2 * 100)}' <<< "$source")"
|
||||
source_vol=" $(awk '{printf "%.0f", $2 * 100}' <<< "$source")"
|
||||
}
|
||||
|
||||
function update_wlp() {
|
||||
local sig ssid dev=wlan0
|
||||
|
||||
sig="$(awk "/$dev/{print int(\$3)}" /proc/net/wireless)"
|
||||
sig="$(awk "/$dev/{printf \"%.0f\", \$3}" /proc/net/wireless)"
|
||||
if [ -z "$sig" ]; then
|
||||
wlp='⚠'
|
||||
return
|
||||
fi
|
||||
ssid="$(networkctl status "$dev" | grep -Po 'Wi-Fi access point:\s*\K\w+')"
|
||||
ssid="$(networkctl status "$dev" --json=short | jq -r .SSID)"
|
||||
{ [ "$sig" -gt 56 ] && wlp="▂▄▆█ $ssid"; } ||
|
||||
{ [ "$sig" -gt 38 ] && wlp="▂▄▆_ $ssid"; } ||
|
||||
{ [ "$sig" -gt 21 ] && wlp="▂▄__ $ssid"; } ||
|
||||
|
@ -69,7 +69,11 @@ function update_wlp() {
|
|||
}
|
||||
|
||||
function update_time() {
|
||||
time="$(date "+%a %m-%d %R")"
|
||||
time="$(date '+%a %m-%d %R')"
|
||||
}
|
||||
|
||||
function reload() {
|
||||
sec=0
|
||||
}
|
||||
|
||||
function display() {
|
||||
|
@ -84,8 +88,9 @@ fi
|
|||
|
||||
# SIGNALING
|
||||
# trap '<function>;display;wait' 'RTMIN+n'
|
||||
trap 'update_sink_vol;display;wait' 'RTMIN'
|
||||
trap 'update_wlp;display;wait' 'RTMIN+1'
|
||||
trap 'reload' 'RTMIN'
|
||||
trap 'update_sink_vol;display;wait' 'RTMIN+1'
|
||||
trap 'update_wlp;display;wait' 'RTMIN+2'
|
||||
# to update it from external commands
|
||||
## kill -m "$(cat ~/.cache/pidofbar)"
|
||||
# where m = 34 + n
|
||||
|
@ -94,19 +99,18 @@ echo "$$" > "$HOME/.cache/pidofbar"
|
|||
|
||||
sec=0
|
||||
while true; do
|
||||
wait && {
|
||||
[ "$((sec % 300))" = 10 ] && update_crypto
|
||||
[ "$((sec % 10))" = 0 ] && {
|
||||
update_cpu
|
||||
update_memory
|
||||
update_sink_vol
|
||||
update_source_vol
|
||||
update_wlp
|
||||
update_bat
|
||||
update_time
|
||||
display
|
||||
}
|
||||
sec="$((sec + 10))"
|
||||
[ "$((sec % 300))" = 10 ] && update_crypto
|
||||
[ "$((sec % 10))" = 0 ] && {
|
||||
update_cpu
|
||||
update_memory
|
||||
update_sink_vol
|
||||
update_source_vol
|
||||
update_wlp
|
||||
update_bat
|
||||
update_time
|
||||
display
|
||||
}
|
||||
sec="$((sec + 10))"
|
||||
awk "@load \"time\"; BEGIN {d=10; s=$(date '+%S.%N'); sleep(d - s % d)}" &
|
||||
wait
|
||||
done
|
||||
|
|
3
.local/bin/steam
Executable file
3
.local/bin/steam
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
com.valvesoftware.Steam --nobrowser
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
SINK='@DEFAULT_AUDIO_SINK@'
|
||||
NOTIFY=(notify-send -t 1000 -a "$(basename "$0")" -u low)
|
||||
NOTIFY=(notify-send -t 1000 -u low)
|
||||
|
||||
function update_vol() {
|
||||
if [[ "$1" =~ ^(-|\+)* ]]; then
|
||||
|
@ -22,14 +22,13 @@ if [ -z "$1" ]; then
|
|||
exit
|
||||
elif [ "$1" == 'm' ] && [ -z "$MUTE" ]; then
|
||||
wpctl set-mute "$SINK" 1
|
||||
"${NOTIFY[@]}" -i audio-volume-muted -h string:synchronous:vol "Mute"
|
||||
"${NOTIFY[@]}" -i audio-volume-muted-symbolic -h string:synchronous:vol "Mute"
|
||||
else
|
||||
if [[ "$1" =~ [0-9] ]]; then
|
||||
update_vol "$1"
|
||||
fi
|
||||
[ -n "$MUTE" ] && wpctl set-mute "$SINK" 0
|
||||
"${NOTIFY[@]}" -h string:synchronous:vol -h int:value:"$CUR" "$CUR%"
|
||||
"${NOTIFY[@]}" -i audio-volume-high-symbolic -h string:synchronous:vol -h int:value:"$CUR" "$CUR%"
|
||||
fi
|
||||
|
||||
# update sbar
|
||||
kill -34 "$(cat "$HOME/.cache/pidofbar")"
|
||||
kill -35 "$(cat "$HOME/.cache/pidofbar")"
|
||||
|
|
|
@ -6,7 +6,7 @@ iwctl=(iwctl station wlan0)
|
|||
|
||||
for _ in {0..29}; do
|
||||
if "${iwctl[@]}" show | grep -q '\s*State\s\+connected\s*$'; then
|
||||
kill -35 "$(cat "$HOME/.cache/pidofbar")"
|
||||
kill -36 "$(cat "$HOME/.cache/pidofbar")"
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue