feat: bin -> .local/bin, vcs_info untracked
This commit is contained in:
parent
af14629939
commit
7c98658d24
30 changed files with 31 additions and 46 deletions
49
.local/bin/light
Executable file
49
.local/bin/light
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/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))"
|
||||
else
|
||||
echo "$((nb + closest - mod))"
|
||||
fi
|
||||
}
|
||||
|
||||
function get_current() {
|
||||
local d="$1"
|
||||
local cur; cur="$(cat "$1/brightness")"
|
||||
local max; max="$(cat "$1/max_brightness")"
|
||||
|
||||
echo "$((cur * 100 / max))"
|
||||
}
|
||||
|
||||
function set_light() {
|
||||
local d="$1"
|
||||
local max; max="$(cat "$d/max_brightness")"
|
||||
|
||||
echo "$((CUR * max / 100))" > "$d/brightness"
|
||||
}
|
||||
|
||||
NOTIFY='notify-send -t 1000 -a changeBrightness -u low'
|
||||
NOTIFYVOL="$NOTIFY -i audio-volume-high"
|
||||
|
||||
DIRS=(/sys/class/backlight/*)
|
||||
CUR="$(get_current "${DIRS[0]}")"
|
||||
|
||||
case "${1:0:1}" in
|
||||
'') echo "$CUR"; exit ;;
|
||||
'+'|'-') CUR="$(round $((CUR + "$1")) "$1")" ;;
|
||||
*) CUR="$1" ;;
|
||||
esac
|
||||
|
||||
[ "$CUR" -lt 0 ] && CUR=0
|
||||
[ "$CUR" -gt 100 ] && CUR=100
|
||||
|
||||
for d in "${DIRS[@]}"; do
|
||||
set_light "$d"
|
||||
done
|
||||
|
||||
$NOTIFYVOL -h string:synchronous:vol -h int:value:"$CUR" "$CUR%"
|
||||
Loading…
Add table
Add a link
Reference in a new issue