aboutsummaryrefslogtreecommitdiff
path: root/scripts/.local/bin/personal/bar
diff options
context:
space:
mode:
authordavidpkj <davidpenkow1@gmail.com>2024-09-16 22:48:05 +0200
committerdavidpkj <davidpenkow1@gmail.com>2024-09-16 22:48:05 +0200
commit06de26be5328a13477942593daf06f417e830736 (patch)
tree6de86872623fac470ad5ce0d8cb8dd0fb8e6859b /scripts/.local/bin/personal/bar
parent646aa3fdeca4466e5d4c4ff7db6b9686582516c6 (diff)
Update system helper scriptsHEADmaster
Diffstat (limited to 'scripts/.local/bin/personal/bar')
-rwxr-xr-xscripts/.local/bin/personal/bar/brightness84
-rwxr-xr-xscripts/.local/bin/personal/bar/mute33
2 files changed, 30 insertions, 87 deletions
diff --git a/scripts/.local/bin/personal/bar/brightness b/scripts/.local/bin/personal/bar/brightness
index f9c84ce..3ce4076 100755
--- a/scripts/.local/bin/personal/bar/brightness
+++ b/scripts/.local/bin/personal/bar/brightness
@@ -1,60 +1,36 @@
#!/bin/bash
-# A script to manage screen and keyboard brightness on my machine
-# Depends on: bash, brightnessctl
-# By David Penkowoj, 2021/06/24
+# A script to manage screen brightness on my machine
+# Depends on: bash, brightnessctl, libnotify
+# By David Penkowoj, 2024-09-16
-MTR_DEVICE="amdgpu_bl2"
-MTR_VALUE=99
+memfile="/tmp/$(whoami)-brightness.memtxt"
+monitor_id="amdgpu_bl2"
-SWITCH="$1"
+bctl() {
+ brightnessctl --device="$monitor_id" "$@"
+}
-case $SWITCH in
- "help")
- printf "Possible arguments:\n"
- printf "===================\n"
- printf "load - loads brightness from save\n"
- printf "save - saves current brightness\n"
- printf "up - increases brightness by 5 percent and saves\n"
- printf "down - decreases brightness by 5 percent and saves\n"
- printf "smallup - increases brightness by 1 percent and saves\n"
- printf "smalldown - decreases brightness by 1 percent and saves\n"
- printf "status - show brightness of a device"
- ;;
- "load")
- brightnessctl --device="$MTR_DEVICE" set "$MTR_VALUE%"
- ;;
- "save")
- M="$(brightnessctl --device="$MTR_DEVICE" | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)"
- sed -i "s/MTR_VALUE=$MTR_VALUE/MTR_VALUE=$M/" "$0"
- ;;
- "smalldown")
- if [[ "$2" = "monitor" ]]; then brightnessctl --device="$MTR_DEVICE" set 1-%; fi
- brightness save
- notify-send -u low -r "110" "$2: $(brightness get monitor)"
- ;;
- "smallup")
- if [[ "$2" = "monitor" ]]; then brightnessctl --device="$MTR_DEVICE" set +1%; fi
- brightness save
- notify-send -u low -r "110" "$2: $(brightness get monitor)"
- ;;
- "down")
- if [[ "$2" = "monitor" ]]; then brightnessctl --device="$MTR_DEVICE" set 5-%; fi
- brightness save
- notify-send -u low -r "110" "$2: $(brightness get monitor)"
- ;;
- "up")
- if [[ "$2" = "monitor" ]]; then brightnessctl --device="$MTR_DEVICE" set +5%; fi
- brightness save
- notify-send -u low -r "110" "$2: $(brightness get monitor)"
- ;;
- "get")
- M="$(brightnessctl --device="$MTR_DEVICE" | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)"
- if [[ "$2" = "monitor" ]]; then echo "$M"; fi
- ;;
- *)
- printf "Monitor:\n"
- brightnessctl --device="$MTR_DEVICE" | tail -n 3 | sed 's/\t/- /g'
- ;;
-esac
+notify_brightness() {
+ current="$(brightness get)"
+ max="$(bctl m)"
+ notify-send -u low -r "110" "Screen brightness: $(( current * 100 / max ))%"
+}
+case "$1" in
+ "up")
+ bctl set +5%
+ notify_brightness
+ ;;
+ "down")
+ bctl set 5-%
+ notify_brightness
+ ;;
+ "get")
+ printf "%s\n" "$(bctl | grep -Eo "[0-9]+" | head -n 2 | tail -n 1)"
+ ;;
+ *)
+ printf "[ Error ] Usage: brightness [up|down|get]"
+ exit 1
+ ;;
+esac
diff --git a/scripts/.local/bin/personal/bar/mute b/scripts/.local/bin/personal/bar/mute
deleted file mode 100755
index 7c987a2..0000000
--- a/scripts/.local/bin/personal/bar/mute
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-
-SOURCE="alsa_input.usb-R__DE_Microphones_R__DE_NT-USB_Mini_610BAACA-00.mono-fallback"
-
-SOURCE="$(pactl get-default-source)"
-VOLUME="$(pactl get-source-volume "$SOURCE" | grep -o [0-9]*% | head -n 1)"
-
-if [[ "$1" == "shortstatus" ]]; then
- if [[ "$VOLUME" == "0%" ]]; then
- echo "Muted"
- else
- echo ""
- fi
-
- exit
-fi
-
-if [[ "$1" == "status" ]]; then
- NAME="$(pactl list sources | grep -o Description:.* | sed -n 's/Description: //g;2p')"
-
- echo "$NAME ($VOLUME)"
-
- exit
-fi
-
-if [[ "$VOLUME" == "0%" ]]; then
- pactl set-source-volume "$SOURCE" 70%
- notify-send -u low "Unmuted" -r 110
-else
- pactl set-source-volume "$SOURCE" 0%
- notify-send -u low "Muted" -r 110
-fi
-