feat: working rounded set-light, set-vol bounds
This commit is contained in:
parent
cf8428b2ac
commit
89d08552b2
@ -1 +1 @@
|
|||||||
Subproject commit 1028360e0f2f724d93e876df3d22f63c1acd6ff9
|
Subproject commit 0f598b9ab9f2a6d7e137074be99c8d89af44b990
|
@ -1 +1 @@
|
|||||||
Subproject commit be49680937e821e4d8522329727e50734fdb9b97
|
Subproject commit 42267407ae588fd6c07238777d48869571193a49
|
@ -1 +1 @@
|
|||||||
Subproject commit a954f789aaa0cedea7609b5493007867b1cd3e9e
|
Subproject commit 2c59e0ff3da6514b03d853ebecb6c36c515a5d7d
|
@ -1 +1 @@
|
|||||||
Subproject commit 9288ee09c89a76cf904886d3c7ffb158948347a1
|
Subproject commit e28dedcf452a9117d76f70090d2f48e01b908f8e
|
@ -1 +1 @@
|
|||||||
Subproject commit 79753faacb6dc511088cb0d136ec438873613932
|
Subproject commit e4b8925478d79795713c80dca4680782a33cdc1b
|
@ -1 +1 @@
|
|||||||
Subproject commit 46c70406dd0b26bbd61210873ad6c86d9e8ee5da
|
Subproject commit 50c678687e73d1433f278b7bb7f168e8fa817670
|
@ -1,5 +1,17 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
function round() {
|
||||||
|
local nb="$1"
|
||||||
|
local closest="${2#-}"
|
||||||
|
local mod; mod="$((nb % closest))"
|
||||||
|
|
||||||
|
if [ "$mod" -lt "$((closest / 2))" ]; then
|
||||||
|
echo "$((nb - mod))"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo "$((nb + closest - mod))"
|
||||||
|
}
|
||||||
|
|
||||||
function get_current() {
|
function get_current() {
|
||||||
local d="$1"
|
local d="$1"
|
||||||
local cur; cur="$(cat "$1/brightness")"
|
local cur; cur="$(cat "$1/brightness")"
|
||||||
@ -8,27 +20,30 @@ function get_current() {
|
|||||||
echo "$((cur * 100 / max))"
|
echo "$((cur * 100 / max))"
|
||||||
}
|
}
|
||||||
|
|
||||||
function set-light() {
|
function set_light() {
|
||||||
local d="$1"
|
local d="$1"
|
||||||
local max; max="$(cat "$d/max_brightness")"
|
local max; max="$(cat "$d/max_brightness")"
|
||||||
|
|
||||||
echo "$((CUR * max / 100))" > "$d/brightness"
|
echo "$((CUR * max / 100))" > "$d/brightness"
|
||||||
}
|
}
|
||||||
|
|
||||||
NOTIFY='notify-send -t 1000 -a changeVolume -u low'
|
NOTIFY='notify-send -t 1000 -a changeBrightness -u low'
|
||||||
NOTIFYVOL="$NOTIFY -i audio-volume-high"
|
NOTIFYVOL="$NOTIFY -i audio-volume-high"
|
||||||
|
|
||||||
DIRS=(/sys/class/backlight/*)
|
DIRS=(/sys/class/backlight/*)
|
||||||
CUR="$(get_current "${DIRS[0]}")"
|
CUR="$(get_current "${DIRS[0]}")"
|
||||||
|
|
||||||
case "${1:0:1}" in
|
case "${1:0:1}" in
|
||||||
'') echo "$CUR"; exit ;;
|
'') echo "$CUR"; exit ;;
|
||||||
'+'|'-') CUR="$((CUR + $1))" ;;
|
'+'|'-') CUR="$(round $((CUR + "$1")) "$1")" ;;
|
||||||
*) CUR="$1" ;;
|
*) CUR="$1" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
[ "$CUR" -lt 0 ] && CUR=0
|
||||||
|
[ "$CUR" -gt 100 ] && CUR=100
|
||||||
|
|
||||||
for d in "${DIRS[@]}"; do
|
for d in "${DIRS[@]}"; do
|
||||||
set-light "$d" "$CUR"
|
set_light "$d"
|
||||||
done
|
done
|
||||||
|
|
||||||
$NOTIFYVOL -h string:synchronous:vol -h int:value:"$CUR" "$CUR%"
|
$NOTIFYVOL -h string:synchronous:vol -h int:value:"$CUR" "$CUR%"
|
||||||
|
16
bin/set-vol
16
bin/set-vol
@ -19,12 +19,20 @@ if [ "$1" == 'm' ]; then
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
case "${1:0:1}" in
|
case "${1:0:1}" in
|
||||||
'') echo "$CUR"; exit ;;
|
'')
|
||||||
'+'|'-') CUR="$((CUR - CUR % $1 + $1))" ;;
|
echo "$CUR"; exit
|
||||||
*) CUR="$1" ;;
|
;;
|
||||||
|
'+'|'-')
|
||||||
|
CUR="$((CUR - CUR % $1 + $1))"
|
||||||
|
[ "$CUR" -lt 0 ] && CUR=0
|
||||||
|
[ "$CUR" -gt 150 ] && CUR=150
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
CUR="$1"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
wpctl set-volume -l 1.5 "$SINK" "$CUR%"
|
wpctl set-volume "$SINK" "$CUR%"
|
||||||
if [ "$MUTE" = 1 ]; then
|
if [ "$MUTE" = 1 ]; then
|
||||||
wpctl set-mute "$SINK" 0
|
wpctl set-mute "$SINK" 0
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user