From 61cb157310d046675d66ceae57b5011080923019 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Thu, 2 May 2019 19:12:23 +0200 Subject: [PATCH] Add brightnesscontrol.sh, switch pulsemixer to pamixer, fix block interrupts --- .config/i3/config | 10 ++++----- .scripts/brightnesscontrol.sh | 40 +++++++++++++++++++++++++++++++++++ .scripts/mediacontrol.sh | 21 +++++++++--------- .scripts/panel/brightness.sh | 8 ++++--- .scripts/panel/volume.sh | 14 ++++++------ packages | 2 +- 6 files changed, 69 insertions(+), 26 deletions(-) create mode 100755 .scripts/brightnesscontrol.sh diff --git a/.config/i3/config b/.config/i3/config index dcbbe73..17e413d 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -162,8 +162,8 @@ for_window [class="QtBank"] floating enable #--- Function key bindings ---# # Screen brightness -bindsym $mod+F3 exec --no-startup-id "brightnessctl -q s +10%; $HOME/.scripts/panel/brightness.sh" -bindsym $mod+F2 exec --no-startup-id "brightnessctl -q s 10%-; $HOME/.scripts/panel/brightness.sh" +bindsym $mod+F3 exec --no-startup-id brightnesscontrol.sh u 10 +bindsym $mod+F2 exec --no-startup-id brightnesscontrol.sh d 10 #--- Arrow key bindings ---# @@ -192,9 +192,9 @@ bindsym --release Shift+Print exec scrot -s -e "mv \$f "$capture # Selection bindsym --release $mod+Print exec scrot -u -e "mv \$f "$capture # Focused window # Volume -bindsym XF86AudioRaiseVolume exec --no-startup-id "mediacontrol.sh up 5; $HOME/.scripts/panel/volume.sh" -bindsym XF86AudioLowerVolume exec --no-startup-id "mediacontrol.sh down 5; $HOME/.scripts/panel/volume.sh" -bindsym XF86AudioMute exec --no-startup-id "mediacontrol.sh toggle; $HOME/.scripts/panel/volume.sh" +bindsym XF86AudioRaiseVolume exec --no-startup-id mediacontrol.sh up 5 +bindsym XF86AudioLowerVolume exec --no-startup-id mediacontrol.sh down 5 +bindsym XF86AudioMute exec --no-startup-id mediacontrol.sh toggle # Touchscreen toggle bindsym XF86HomePage exec --no-startup-id touchscreen.sh diff --git a/.scripts/brightnesscontrol.sh b/.scripts/brightnesscontrol.sh new file mode 100755 index 0000000..d8974d7 --- /dev/null +++ b/.scripts/brightnesscontrol.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# General brightness management + +RELOAD="$HOME/.scripts/panel/brightness.sh" + +[ -z "$2" ] && NUM="5" || NUM="$2" + +help() { + B=$(tput bold) + N=$(tput sgr0) + + cat << EOF +${B}NAME${N} + brightnesscontrol - control the volume of the system + +${B}SYNOPSIS${N} + ./brightnesscontrol.sh [] + +${B}DESCRIPTION${N} + Commands can be truncated, i.e. + \`${B}brightnesscontrol.sh s${N}\` for \`${B}brightnesscontrol.sh set${N}\` + + Arguments need to be of numeric value. + +${B}COMMANDS${N} + ${B}u*, up ${N} + + ${B}d*, down ${N} + + ${B}s*, set ${N} +EOF +} + +case "$1" in + u*) brightnessctl -q s +"$NUM"% ; $RELOAD ;; + d*) brightnessctl -q s "$NUM"%- ; $RELOAD ;; + s*) brightnessctl -q s "$NUM"% ; $RELOAD ;; + *) help ;; +esac diff --git a/.scripts/mediacontrol.sh b/.scripts/mediacontrol.sh index 801db5f..3024b13 100755 --- a/.scripts/mediacontrol.sh +++ b/.scripts/mediacontrol.sh @@ -2,7 +2,7 @@ # General audio management -RELOAD="pkill -RTMIN+1 i3blocks" +RELOAD="$HOME/.scripts/panel/volume.sh" [ -z "$2" ] && NUM="2" || NUM="$2" @@ -43,13 +43,14 @@ EOF } case "$1" in - u*) pulsemixer --change-volume +"$NUM" --max-volume 100 ; $RELOAD ;; - d*) pulsemixer --change-volume -"$NUM" --max-volume 100 ; $RELOAD ;; - s*) pulsemixer --set-volume "$NUM" --max-volume 100 ; $RELOAD ;; - t*) pulsemixer --toggle-mute ; $RELOAD ;; - m*) pulsemixer --mute ; $RELOAD ;; - n*) pulsemixer --unmute ; $RELOAD ;; - getv*) pulsemixer --get-volume | awk '{print $1}' ;; - getm*) pulsemixer --get-mute ;; - *) help ;; + u*) pamixer --increase "$NUM" ; $RELOAD ;; + d*) pamixer --decrease "$NUM" ; $RELOAD ;; + s*) pamixer --set-volume "$NUM" ; $RELOAD ;; + t*) [ "$(pamixer --get-mute)" = "false" ] && \ + pamixer --mute || pamixer --unmute ; $RELOAD ;; + m*) pamixer --mute ; $RELOAD ;; + n*) pamixer --unmute ; $RELOAD ;; + getv*) pamixer --get-volume ;; + getm*) pamixer --get-mute ;; + *) help ;; esac diff --git a/.scripts/panel/brightness.sh b/.scripts/panel/brightness.sh index f2d6b83..8868b0f 100755 --- a/.scripts/panel/brightness.sh +++ b/.scripts/panel/brightness.sh @@ -1,9 +1,11 @@ #!/bin/sh +BRIGHTNESS_CONTROL="$HOME/.scripts/brightnesscontrol.sh" + # Right click, scroll up, scroll down -R="A3:brightnessctl -q s 30%; $0:" -U="A4:brightnessctl -q s +10%; $0:" -D="A5:brightnessctl -q s 10%-; $0:" +R="A3:$BRIGHTNESS_CONTROL s 30:" +U="A4:$BRIGHTNESS_CONTROL u 10:" +D="A5:$BRIGHTNESS_CONTROL d 10:" PERCENTAGE=$(brightnessctl \ | awk '/\([0-9]+%\)/ { print substr($4, 2, length($4) - 3) }') diff --git a/.scripts/panel/volume.sh b/.scripts/panel/volume.sh index 209c2e5..256cf57 100755 --- a/.scripts/panel/volume.sh +++ b/.scripts/panel/volume.sh @@ -1,18 +1,18 @@ #!/bin/sh -MEDIACONTROL="$HOME/.scripts/mediacontrol.sh" +MEDIA_CONTROL="$HOME/.scripts/mediacontrol.sh" # Left click, scroll click, right click, scroll up and scroll down L="A1:pavucontrol:" -S="A2:$MEDIACONTROL set 0; $0:" -R="A3:$MEDIACONTROL toggle; $0:" -U="A4:$MEDIACONTROL up 5; $0:" -D="A5:$MEDIACONTROL down 5; $0:" +S="A2:$MEDIA_CONTROL set 0:" +R="A3:$MEDIA_CONTROL toggle:" +U="A4:$MEDIA_CONTROL up 5:" +D="A5:$MEDIA_CONTROL down 5:" -VOLUME="$($MEDIACONTROL getvolume)" +VOLUME="$($MEDIA_CONTROL getvolume)" COLOR="-" -if [ "$($MEDIACONTROL getmute)" = "1" ]; then +if [ "$($MEDIA_CONTROL getmute)" = "true" ]; then COLOR="$COLOR7" SYMBOL="" diff --git a/packages b/packages index ca882c2..03c1faa 100644 --- a/packages +++ b/packages @@ -65,6 +65,7 @@ os-prober otf-font-awesome p7zip pacman-contrib +pamixer pavucontrol pdfjs platformio @@ -72,7 +73,6 @@ playerctl poppler-glib pulseaudio pulseaudio-alsa -pulsemixer-git pwgen python2-click-5.1 python2-setuptools