feat: simplify vol, light and am
This commit is contained in:
parent
57243c81fa
commit
47c176f3bc
@ -1,10 +1,5 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
# TODO
|
||||
# mount all partitions by selecting disk
|
||||
# usage
|
||||
# support for /mnt
|
||||
|
||||
function get_row() {
|
||||
local row _col
|
||||
|
||||
@ -22,8 +17,7 @@ function clear_output() {
|
||||
done
|
||||
}
|
||||
|
||||
function main() {
|
||||
while true; do
|
||||
while true; do
|
||||
mapfile -t LSBLK <<< "$(lsblk -n --paths --list | grep part)"
|
||||
|
||||
COLUMNS=1
|
||||
@ -42,7 +36,4 @@ function main() {
|
||||
fi
|
||||
break
|
||||
done || exit
|
||||
done
|
||||
}
|
||||
|
||||
main "$@"
|
||||
done
|
||||
|
@ -13,7 +13,6 @@ function round() {
|
||||
}
|
||||
|
||||
function get_current() {
|
||||
local d="$1"
|
||||
local cur; cur="$(cat "$1/brightness")"
|
||||
local max; max="$(cat "$1/max_brightness")"
|
||||
|
||||
@ -21,21 +20,19 @@ function get_current() {
|
||||
}
|
||||
|
||||
function set_light() {
|
||||
local d="$1"
|
||||
local max; max="$(cat "$d/max_brightness")"
|
||||
local max; max="$(cat "$1/max_brightness")"
|
||||
|
||||
echo "$((CUR * max / 100))" > "$d/brightness"
|
||||
echo "$((CUR * max / 100))" > "$1/brightness"
|
||||
}
|
||||
|
||||
NOTIFY='notify-send -t 1000 -a changeBrightness -u low'
|
||||
NOTIFYVOL="$NOTIFY -i audio-volume-high"
|
||||
NOTIFY=(notify-send -t 1000 -a "$(basename "$0")" -u low)
|
||||
|
||||
DIRS=(/sys/class/backlight/*)
|
||||
CUR="$(get_current "${DIRS[0]}")"
|
||||
|
||||
case "${1:0:1}" in
|
||||
'') echo "$CUR"; exit ;;
|
||||
'+'|'-') CUR="$(round $((CUR + "$1")) "$1")" ;;
|
||||
'+'|'-') CUR="$(round $((CUR + $1)) "$1")" ;;
|
||||
*) CUR="$1" ;;
|
||||
esac
|
||||
|
||||
@ -46,4 +43,4 @@ for d in "${DIRS[@]}"; do
|
||||
set_light "$d"
|
||||
done
|
||||
|
||||
$NOTIFYVOL -h string:synchronous:vol -h int:value:"$CUR" "$CUR%"
|
||||
"${NOTIFY[@]}" -h string:synchronous:light -h int:value:"$CUR" "$CUR%"
|
||||
|
@ -1,42 +1,34 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
NOTIFY='notify-send -t 1000 -a changeVolume -u low'
|
||||
NOTIFYVOL="$NOTIFY -i audio-volume-high"
|
||||
|
||||
SINK='@DEFAULT_AUDIO_SINK@'
|
||||
WPCUR="$(wpctl get-volume "$SINK")"
|
||||
CUR="$((10#$(tr -dc '0-9' <<< "$WPCUR")))"
|
||||
NOTIFY=(notify-send -t 1000 -a "$(basename "$0")" -u low)
|
||||
|
||||
grep -q MUTED <<< "$WPCUR" && MUTE=1 || MUTE=0
|
||||
|
||||
if [ "$1" == 'm' ]; then
|
||||
if [ "$MUTE" = 1 ]; then
|
||||
wpctl set-mute "$SINK" 0
|
||||
$NOTIFYVOL -h string:synchronous:vol -h int:value:"$CUR" "$CUR%"
|
||||
else
|
||||
wpctl set-mute "$SINK" 1
|
||||
$NOTIFY -i audio-volume-muted -h string:synchronous:vol "Mute"
|
||||
fi
|
||||
else
|
||||
case "${1:0:1}" in
|
||||
'')
|
||||
echo "$CUR"; exit
|
||||
;;
|
||||
'+'|'-')
|
||||
function update_vol() {
|
||||
if [[ "$1" =~ ^(-|\+)* ]]; then
|
||||
CUR="$((CUR - CUR % $1 + $1))"
|
||||
[ "$CUR" -lt 0 ] && CUR=0
|
||||
[ "$CUR" -gt 150 ] && CUR=150
|
||||
;;
|
||||
*)
|
||||
else
|
||||
CUR="$1"
|
||||
;;
|
||||
esac
|
||||
|
||||
wpctl set-volume "$SINK" "$CUR%"
|
||||
if [ "$MUTE" = 1 ]; then
|
||||
wpctl set-mute "$SINK" 0
|
||||
fi
|
||||
$NOTIFYVOL -h string:synchronous:vol -h int:value:"$CUR" "$CUR%"
|
||||
wpctl set-volume "$SINK" "$CUR%"
|
||||
}
|
||||
|
||||
read -r _ CUR MUTE < <(wpctl get-volume "$SINK")
|
||||
CUR="${CUR/#0/}"; CUR="${CUR/#./}"
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "$CUR"
|
||||
exit
|
||||
elif [ "$1" == 'm' ] && [ -z "$MUTE" ]; then
|
||||
wpctl set-mute "$SINK" 1
|
||||
"${NOTIFY[@]}" -i audio-volume-muted -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%"
|
||||
fi
|
||||
|
||||
# update sbar
|
||||
|
Loading…
Reference in New Issue
Block a user