lhark
7 years ago
commit
d978c129d2
6 changed files with 197 additions and 0 deletions
@ -0,0 +1,10 @@ |
|||
This is just a bunch of usefull little scripts when you don't have a fully fledged |
|||
desktop environment on hand and are relying on the elegant simplicity of a window |
|||
manager like for example [[dwm|dwm.suckless.org]]. |
|||
|
|||
## List ## |
|||
* dpass : dmenu password entry (WIP) |
|||
* loopdwm : easy dwm restarting, supports multiple versions |
|||
* touchtog : toggle synaptics touchpad |
|||
* volcont : pulsaudio volume control and synchronisation |
|||
* clipqr : display primary clipboard with a QRcode (text transfer to phone) |
@ -0,0 +1,3 @@ |
|||
#!/bin/sh |
|||
|
|||
xsel -p -o | qrencode -o - | feh -. - |
@ -0,0 +1,2 @@ |
|||
#!/bin/bash |
|||
dmenu -nf '#000' -p "$1" <&- && echo |
@ -0,0 +1,16 @@ |
|||
#!/bin/sh |
|||
|
|||
while true; do |
|||
# Chose version to use dynamically |
|||
case "$(cat ~/.dwm-exec)" in |
|||
dwm) |
|||
dwm=/usr/bin/dwm |
|||
;; |
|||
dwm-dev) |
|||
dwm=~/suckless/dwm |
|||
;; |
|||
esac |
|||
$dwm 2> ~/.dwm.log |
|||
# No error logging |
|||
#$dwm >/dev/null 2>&1 |
|||
done |
@ -0,0 +1,9 @@ |
|||
#!/bin/sh |
|||
|
|||
off=$(synclient -l | awk -F '= ' '/TouchpadOff/{print $2}') |
|||
|
|||
if [ $off = 0 ]; then |
|||
synclient TouchpadOff=1 |
|||
else |
|||
synclient TouchpadOff=0 |
|||
fi |
@ -0,0 +1,157 @@ |
|||
#!/bin/sh |
|||
|
|||
# finds the active sink for pulse audio and increments the volume. useful when you have multiple audio outputs and have a key bound to vol-up and down |
|||
# Taken from http://customlinux.blogspot.fr/2013/02/pavolumesh-control-active-sink-volume.html |
|||
# and slightly adapted by lhark to work with notify-send |
|||
|
|||
notify='yes' |
|||
notiftime='400' |
|||
inc='5' |
|||
capvol='yes' |
|||
maxvol='200' |
|||
autosync='no' |
|||
|
|||
main_sink=$(pacmd list-sinks |awk '/* index:/{print $3}') |
|||
active_sinks=$(pacmd list-sinks |awk '/index:/{print $NF}' | tr '\n' ' ' | sed 's/ $/\n/g') |
|||
limit=$((100 - inc)) |
|||
maxlimit=$((maxvol - inc)) |
|||
|
|||
updateSinks () { |
|||
active_sinks=$(pacmd list-sinks |awk '/index:/{print $NF}' | tr '\n' ' ' | sed 's/ $/\n/g') |
|||
} |
|||
|
|||
|
|||
volUp () { |
|||
updateSinks |
|||
getCurVol |
|||
|
|||
for sink in ${active_sinks}; do |
|||
if [ ${capvol} = 'yes' ]; then |
|||
if [ "${curVol}" -le 100 ] && [ "${curVol}" -ge ${limit} ]; then |
|||
pactl set-sink-volume "${sink}" 100% |
|||
elif [ "${curVol}" -lt ${limit} ]; then |
|||
pactl set-sink-volume "${sink}" +${inc}% |
|||
fi |
|||
elif [ "${curVol}" -le ${maxvol} ] && [ "${curVol}" -ge ${maxlimit} ]; then |
|||
pactl set-sink-volume "${sink}" ${maxvol}% |
|||
elif [ "${curVol}" -lt ${maxlimit} ]; then |
|||
pactl set-sink-volume "${sink}" +${inc}% |
|||
fi |
|||
done |
|||
|
|||
getCurVol |
|||
|
|||
if [ ${notify} = 'yes' ] |
|||
then |
|||
notify-send "Volume : ${curVol}%" -t ${notiftime} |
|||
fi |
|||
|
|||
if [ ${autosync} = 'yes' ] |
|||
then |
|||
volSync |
|||
fi |
|||
} |
|||
|
|||
volDown () { |
|||
updateSinks |
|||
for sink in ${active_sinks}; do |
|||
pactl set-sink-volume "${sink}" -${inc}% |
|||
done |
|||
getCurVol |
|||
|
|||
if [ ${notify} = 'yes' ]; then |
|||
notify-send "Volume : ${curVol}%" -t ${notiftime} |
|||
fi |
|||
|
|||
if [ ${autosync} = 'yes' ]; then |
|||
volSync |
|||
fi |
|||
} |
|||
|
|||
|
|||
volSync () { |
|||
updateSinks |
|||
getCurVol |
|||
|
|||
for each in ${active_sinks}; do |
|||
pactl set-sink-volume "${each}" "${curVol}"% |
|||
done |
|||
} |
|||
|
|||
|
|||
getCurVol () { |
|||
curVol=$(pacmd list-sinks |grep -A 15 'index: '"${main_sink}"'' |grep 'volume:' |egrep -v 'base volume:' |awk -F : '{print $3}' |grep -o -P '.{0,3}%'|sed s/.$// | tr -d ' ') |
|||
} |
|||
|
|||
|
|||
volMute () { |
|||
case "$1" in |
|||
mute) |
|||
for sink in ${active_sinks}; do |
|||
pactl set-sink-mute "${sink}" 1 |
|||
done |
|||
curVol=0 |
|||
status=1 |
|||
;; |
|||
unmute) |
|||
for sink in ${active_sinks}; do |
|||
pactl set-sink-mute "${sink}" 0 |
|||
done |
|||
getCurVol |
|||
status=0 |
|||
;; |
|||
esac |
|||
|
|||
if [ ${notify} = 'yes' ]; then |
|||
notify-send "$([ "${status}" = 1 ] && echo "Sound muted" || echo "Sound unmuted")" -t ${notiftime} |
|||
fi |
|||
} |
|||
|
|||
volMuteStatus () { |
|||
curStatus=$(pacmd list-sinks |grep -A 15 'index: '"${main_sink}"'' |awk '/muted/{ print $2}') |
|||
|
|||
if [ "${curStatus}" = 'yes' ]; then |
|||
volMute unmute |
|||
else |
|||
volMute mute |
|||
fi |
|||
} |
|||
|
|||
|
|||
volHelp () { |
|||
echo "Finds the active sink for pulse audio and manages the volume." |
|||
echo "Options :" |
|||
echo "" |
|||
echo " --down" |
|||
echo " --help" |
|||
echo " --mute" |
|||
echo " --sync Sync all sinks volumes" |
|||
echo " --toggle" |
|||
echo " --unmute" |
|||
echo " --up" |
|||
} |
|||
|
|||
|
|||
case "$1" in |
|||
--up) |
|||
volUp |
|||
;; |
|||
--down) |
|||
volDown |
|||
;; |
|||
--toggle) |
|||
volMuteStatus |
|||
;; |
|||
--help) |
|||
volHelp |
|||
;; |
|||
--mute) |
|||
volMute mute |
|||
;; |
|||
--unmute) |
|||
volMute unmute |
|||
;; |
|||
--sync) |
|||
volSync |
|||
;; |
|||
esac |
Loading…
Reference in new issue