]> www.git.dmfe.net Git - dotfiles/commitdiff
Add volume control script.
authorDmitry Fedotov <dm.fe@yandex.ru>
Fri, 5 Mar 2021 07:24:22 +0000 (10:24 +0300)
committerDmitry Fedotov <dm.fe@yandex.ru>
Fri, 5 Mar 2021 07:24:22 +0000 (10:24 +0300)
config/i3blocks/config
config/sxhkd/sxhkdrc
scripts/sound/vc [new file with mode: 0755]
scripts/sound/volume.sh [new file with mode: 0755]
scripts/volume.sh [deleted file]

index 52afcb6eca4a2966dda63110c5dd12f7f2b352df..9e0a97e5682116229ca46de72cb63a6641a90e45 100644 (file)
@@ -60,7 +60,8 @@ command=echo  | ~/scripts/i3b-formatter.sh -s
 interval=once
 
 [volume]
-command=~/scripts/volume.sh | ~/scripts/i3b-formatter.sh -r
+command=~/scripts/sound/volume.sh | ~/scripts/i3b-formatter.sh -r
+signal=10
 interval=once
 min_width=xxx100%
 
index 661903a96b9d4ad1a748ce67e3a87751b0e33f23..4643fdd973cd2539a960be66cc3db366ab31c5e8 100644 (file)
@@ -1,34 +1,46 @@
 
 # Basic binds
 super + Return
-       $TERMINAL -e /bin/bash --rcfile ~/.bash_profile
+    $TERMINAL -e /bin/bash --rcfile ~/.bash_profile
 super + m
-       $TERMINAL -e ncmpcpp
+    $TERMINAL -e ncmpcpp
 super + shift + f
-       $TERMINAL -e ranger
+    $TERMINAL -e ranger
 super + shift + t
-       $TERMINAL -e htop
+    $TERMINAL -e htop
 super + c
-       "${TERMINAL}" -e calc
+    "${TERMINAL}" -e calc
 super + shift + n
-       nohup "${TERMINAL}" -e sh -c 'neofetch;read' >/dev/null &
+    nohup "${TERMINAL}" -e sh -c 'neofetch;read' >/dev/null &
 
 super + Print
-       import jpg:- | xclip -selection clipboard -t image/jpeg
+    import jpg:- | xclip -selection clipboard -t image/jpeg
 super + t
-       ${SCRIPTS}/shutdown.sh
+    ${SCRIPTS}/shutdown.sh
 super + d
-       ${SCRIPTS}/dmenu-run.sh
+    ${SCRIPTS}/dmenu-run.sh
 super + e
-       ${SCRIPTS}/dmenu-unicode.sh
+    ${SCRIPTS}/dmenu-unicode.sh
 super + shift + m
-       ${SCRIPTS}/dmenumount.sh
+    ${SCRIPTS}/dmenumount.sh
 super + shift + x
-       ${SCRIPTS}/screen-locker.sh
+    ${SCRIPTS}/screen-locker.sh
 super + shift + p
     ${SCRIPTS}/dmenu-pass.sh
 
+# Sound
+super + F10
+    vc toggle
+super + F12
+    vc up
+super + F11
+    vc down
+super + shift + F12
+    vc up 20
+super + shift + F11
+    vc down 20
+
 super + alt + l
-       pkill -SIGUSR1 sxhkd
+    pkill -SIGUSR1 sxhkd
 shift + ctrl + k
-       pkill -SIGRTMIN+5 i3blocks
+    pkill -SIGRTMIN+5 i3blocks
diff --git a/scripts/sound/vc b/scripts/sound/vc
new file mode 100755 (executable)
index 0000000..1ccc455
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+set -e
+#set -x
+
+NUM="${2:-5}"
+
+PULSE=true
+
+if [[ ${PULSE} = true ]]; then
+    toggle() { pulsemixer --toggle-mute ;}
+    mute() { pulsemixer --mute ;}
+    up() { pulsemixer --change-volume +"$NUM" ;}
+    down() { pulsemixer --change-volume -"$NUM" ;}
+else
+    toggle() { amixer sset Master toggle ;}
+    mute() { amixer sset Master mute ;}
+    up() { amixer sset Master "$NUM"%+ ;}
+    down() { amixer sset Master "$NUM"%- ;}
+fi
+
+case "$1" in
+    toggle) toggle ;;
+    mute) mute ;;
+    up) up ;;
+    down) down ;;
+esac >/dev/null
+
+pkill -RTMIN+10 i3blocks
+
diff --git a/scripts/sound/volume.sh b/scripts/sound/volume.sh
new file mode 100755 (executable)
index 0000000..e646f15
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+sink=$( pactl list short sinks | sed -e 's,^\([0-9][0-9]*\)[^0-9].*,\1,' | tail -n 1 )
+
+case ${BLOCK_BUTTON} in
+    2)
+        nohup "${TERMINAL}" -e "${EDITOR}" "$0" >/dev/null &
+        ;;
+    3)
+        pactl set-sink-mute $sink toggle
+        ;;
+    4)
+        pactl set-sink-volume $sink +5%
+        ;;
+    5)
+        pactl set-sink-volume $sink -5%
+        ;;
+esac
+
+muted=$( awk '/muted/ {print $2}' <(pacmd list-sinks | grep '^[[:space:]]muted:' | head -n $(( $sink + 1 )) | tail -n 1 ) )
+
+if [ "$muted" = "yes" ]; then
+  icon=""
+  printf "%s\n" "$icon"
+else
+  vol=$( pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $sink + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' )
+  if [ "$vol" -gt 60 ]; then
+    icon=""
+  elif [[ "$vol" -le 60 && "$vol" -gt 30 ]]; then
+    icon=""
+  else
+    icon=""
+  fi
+
+  printf "%s %s%%\n" "$icon" "$vol"
+fi
diff --git a/scripts/volume.sh b/scripts/volume.sh
deleted file mode 100755 (executable)
index e646f15..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-
-sink=$( pactl list short sinks | sed -e 's,^\([0-9][0-9]*\)[^0-9].*,\1,' | tail -n 1 )
-
-case ${BLOCK_BUTTON} in
-    2)
-        nohup "${TERMINAL}" -e "${EDITOR}" "$0" >/dev/null &
-        ;;
-    3)
-        pactl set-sink-mute $sink toggle
-        ;;
-    4)
-        pactl set-sink-volume $sink +5%
-        ;;
-    5)
-        pactl set-sink-volume $sink -5%
-        ;;
-esac
-
-muted=$( awk '/muted/ {print $2}' <(pacmd list-sinks | grep '^[[:space:]]muted:' | head -n $(( $sink + 1 )) | tail -n 1 ) )
-
-if [ "$muted" = "yes" ]; then
-  icon=""
-  printf "%s\n" "$icon"
-else
-  vol=$( pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $sink + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' )
-  if [ "$vol" -gt 60 ]; then
-    icon=""
-  elif [[ "$vol" -le 60 && "$vol" -gt 30 ]]; then
-    icon=""
-  else
-    icon=""
-  fi
-
-  printf "%s %s%%\n" "$icon" "$vol"
-fi