From 81cfd3da96c91aa5f231230d9de1d84610094d66 Mon Sep 17 00:00:00 2001 From: Dmitry Fedotov Date: Fri, 5 Mar 2021 10:24:22 +0300 Subject: [PATCH] Add volume control script. --- config/i3blocks/config | 3 ++- config/sxhkd/sxhkdrc | 40 +++++++++++++++++++++++------------ scripts/sound/vc | 30 ++++++++++++++++++++++++++ scripts/{ => sound}/volume.sh | 0 4 files changed, 58 insertions(+), 15 deletions(-) create mode 100755 scripts/sound/vc rename scripts/{ => sound}/volume.sh (100%) diff --git a/config/i3blocks/config b/config/i3blocks/config index 52afcb6..9e0a97e 100644 --- a/config/i3blocks/config +++ b/config/i3blocks/config @@ -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% diff --git a/config/sxhkd/sxhkdrc b/config/sxhkd/sxhkdrc index 661903a..4643fdd 100644 --- a/config/sxhkd/sxhkdrc +++ b/config/sxhkd/sxhkdrc @@ -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 index 0000000..1ccc455 --- /dev/null +++ b/scripts/sound/vc @@ -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/volume.sh b/scripts/sound/volume.sh similarity index 100% rename from scripts/volume.sh rename to scripts/sound/volume.sh -- 2.39.5