Update volume script to proper standard
This commit is contained in:
@@ -36,7 +36,7 @@ interval = 5
|
|||||||
sink = alsa_output.pci-0000_00_1f.3.analog-stereo
|
sink = alsa_output.pci-0000_00_1f.3.analog-stereo
|
||||||
use-ui-max = false
|
use-ui-max = false
|
||||||
|
|
||||||
format-volume = %{A1:pavucontrol:}%{A2:$HOME/.scripts/mediacontrol.sh set 0:}%{A3:$HOME/.scripts/mediacontrol.sh toggle:}<ramp-volume> <label-volume>%{A}%{A}%{A}
|
format-volume = %{A1:pavucontrol:}%{A2:$HOME/.scripts/volctl.sh s 0:}%{A3:$HOME/.scripts/volctl.sh t:}<ramp-volume> <label-volume>%{A}%{A}%{A}
|
||||||
format-volume-foreground = ${colors.white-bright}
|
format-volume-foreground = ${colors.white-bright}
|
||||||
|
|
||||||
ramp-volume-0 =
|
ramp-volume-0 =
|
||||||
@@ -46,7 +46,7 @@ ramp-volume-3 =
|
|||||||
|
|
||||||
label-volume = %percentage%%
|
label-volume = %percentage%%
|
||||||
|
|
||||||
format-muted = %{A1:pavucontrol:}%{A2:$HOME/.scripts/mediacontrol.sh set 0:}%{A3:$HOME/.scripts/mediacontrol.sh toggle:}<label-muted>%{A}%{A}%{A}
|
format-muted = %{A1:pavucontrol:}%{A2:$HOME/.scripts/volctl.sh s 0:}%{A3:$HOME/.scripts/volctl.sh t:}<label-muted>%{A}%{A}%{A}
|
||||||
format-muted-foreground = ${wmcolors.fgcolor-inactive}
|
format-muted-foreground = ${wmcolors.fgcolor-inactive}
|
||||||
|
|
||||||
label-muted = %percentage%%
|
label-muted = %percentage%%
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ super + {F2,F3}
|
|||||||
|
|
||||||
# Volume
|
# Volume
|
||||||
XF86Audio{LowerVolume,RaiseVolume,Mute}
|
XF86Audio{LowerVolume,RaiseVolume,Mute}
|
||||||
mediacontrol.sh {down 5,up 5,toggle}
|
volctl.sh {dec 5,inc 5,toggle}
|
||||||
|
|
||||||
# Touchpad toggle
|
# Touchpad toggle
|
||||||
XF86HomePage
|
XF86HomePage
|
||||||
|
|||||||
+1
-1
@@ -133,8 +133,8 @@ alias gdc="git diff --cached"
|
|||||||
alias gl="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d %C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all"
|
alias gl="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d %C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all"
|
||||||
|
|
||||||
# Scripts
|
# Scripts
|
||||||
alias mc="$HOME/.scripts/mediacontrol.sh"
|
|
||||||
alias nw="$HOME/.scripts/network.sh"
|
alias nw="$HOME/.scripts/network.sh"
|
||||||
|
alias vc="$HOME/.scripts/volctl.sh"
|
||||||
alias vp="$HOME/.scripts/vimplugin.sh"
|
alias vp="$HOME/.scripts/vimplugin.sh"
|
||||||
alias mpvshuffle="$HOME/.scripts/mpv.sh shuffle"
|
alias mpvshuffle="$HOME/.scripts/mpv.sh shuffle"
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# General audio management
|
|
||||||
|
|
||||||
RELOAD="$HOME/.scripts/panel/volume.sh"
|
|
||||||
|
|
||||||
[ -z "$2" ] && NUM="2" || NUM="$2"
|
|
||||||
|
|
||||||
help() {
|
|
||||||
B=$(tput bold)
|
|
||||||
N=$(tput sgr0)
|
|
||||||
|
|
||||||
cat << EOF
|
|
||||||
${B}NAME${N}
|
|
||||||
mediacontrol - control the volume of the system
|
|
||||||
|
|
||||||
${B}SYNOPSIS${N}
|
|
||||||
./mediacontrol.sh <command> [<arg1>]
|
|
||||||
|
|
||||||
${B}DESCRIPTION${N}
|
|
||||||
Commands can be truncated, i.e.
|
|
||||||
\`${B}mediacontrol.sh t${N}\` for \`${B}mediacontrol.sh toggle${N}\`
|
|
||||||
|
|
||||||
Arguments need to be of numeric value.
|
|
||||||
|
|
||||||
${B}COMMANDS${N}
|
|
||||||
${B}u*, up <amount>${N}
|
|
||||||
|
|
||||||
${B}d*, down <amount>${N}
|
|
||||||
|
|
||||||
${B}s*, set <volume>${N}
|
|
||||||
|
|
||||||
${B}t*, toggle${N}
|
|
||||||
|
|
||||||
${B}m*, mute${N}
|
|
||||||
|
|
||||||
${B}n*, notmute${N}
|
|
||||||
|
|
||||||
${B}getv*, getvolume${N}
|
|
||||||
|
|
||||||
${B}getm*, getmute${N}
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
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
|
|
||||||
Executable
+109
@@ -0,0 +1,109 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Control the volume
|
||||||
|
# Depends: pamixer
|
||||||
|
|
||||||
|
help() {
|
||||||
|
B=$(tput bold)
|
||||||
|
U=$(tput smul)
|
||||||
|
N=$(tput sgr0)
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
|
${B}NAME${N}
|
||||||
|
volctl.sh - control the volume
|
||||||
|
|
||||||
|
${B}SYNOPSIS${N}
|
||||||
|
${B}volctl.sh${N} [${U}OPTION${N}] [${U}COMMAND${N}] [<${U}ARG${N}>]
|
||||||
|
|
||||||
|
${B}DESCRIPTION${N}
|
||||||
|
${B}volctl.sh${N} uses pamixer to change the volume of the system.
|
||||||
|
|
||||||
|
Commands can be truncated, i.e. "${B}volctl.sh t${N}" for "${B}volctl.sh toggle${N}"
|
||||||
|
Arguments need to be of numeric value.
|
||||||
|
|
||||||
|
${B}OPTIONS${N}
|
||||||
|
${B}-h${N} Display usage message and exit.
|
||||||
|
|
||||||
|
${B}COMMANDS${N}
|
||||||
|
${B}i${N} <${U}AMOUNT${N}>, ${B}inc${N} <${U}AMOUNT${N}>
|
||||||
|
Increase volume by ${U}AMOUNT${N}, default of 2.
|
||||||
|
|
||||||
|
${B}d${N} <${U}AMOUNT${N}>, ${B}dec${N} <${U}AMOUNT${N}>
|
||||||
|
Decrease volume by ${U}AMOUNT${N}, default of 2.
|
||||||
|
|
||||||
|
${B}s${N} <${U}LEVEL${N}>, ${B}set${N} <${U}LEVEL${N}>
|
||||||
|
Set volume to ${U}LEVEL${N}, default of 0.
|
||||||
|
|
||||||
|
${B}t${N}, ${B}toggle${N}
|
||||||
|
Toggle mute.
|
||||||
|
|
||||||
|
${B}m${N}, ${B}mute${N}
|
||||||
|
Mute volume.
|
||||||
|
|
||||||
|
${B}u${N}, ${B}unmute${N}
|
||||||
|
Unmute volume.
|
||||||
|
|
||||||
|
${B}getv${N}, ${B}getvolume${N}
|
||||||
|
Get volume level.
|
||||||
|
|
||||||
|
${B}getm${N}, ${B}getmute${N}
|
||||||
|
Get mute status.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# Exit if no option is provided
|
||||||
|
[ "$#" -eq 0 ] && help && exit 1
|
||||||
|
|
||||||
|
SCRIPT="$(basename "$0")"
|
||||||
|
|
||||||
|
# Option handling
|
||||||
|
while getopts ':h?' opt; do
|
||||||
|
case $opt in
|
||||||
|
h)
|
||||||
|
help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "$SCRIPT: invalid option '$OPTARG'"
|
||||||
|
echo "Try '$SCRIPT -h' for more information."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Command handling
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
case "$1" in
|
||||||
|
i*)
|
||||||
|
NUM=${2:-2}
|
||||||
|
pamixer --increase "$NUM"
|
||||||
|
;;
|
||||||
|
d*)
|
||||||
|
NUM=${2:-2}
|
||||||
|
pamixer --decrease "$NUM"
|
||||||
|
;;
|
||||||
|
s*)
|
||||||
|
NUM=${2:-0}
|
||||||
|
pamixer --set-volume "$NUM"
|
||||||
|
;;
|
||||||
|
t*)
|
||||||
|
pamixer --toggle-mute
|
||||||
|
;;
|
||||||
|
m*)
|
||||||
|
pamixer --mute
|
||||||
|
;;
|
||||||
|
n*)
|
||||||
|
pamixer --unmute
|
||||||
|
;;
|
||||||
|
getv*)
|
||||||
|
pamixer --get-volume
|
||||||
|
;;
|
||||||
|
getm*)
|
||||||
|
pamixer --get-mute
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "$SCRIPT: invalid command '$1'"
|
||||||
|
echo "Try '$SCRIPT -h' for more information."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Reference in New Issue
Block a user