commit d978c129d28de955813fd7c27d2df43d90c1c04c Author: lhark Date: Mon Jan 23 20:46:57 2017 -0500 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..b8e6649 --- /dev/null +++ b/README.md @@ -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) diff --git a/clipqr b/clipqr new file mode 100755 index 0000000..46d7654 --- /dev/null +++ b/clipqr @@ -0,0 +1,3 @@ +#!/bin/sh + +xsel -p -o | qrencode -o - | feh -. - diff --git a/dpass b/dpass new file mode 100755 index 0000000..32aa82f --- /dev/null +++ b/dpass @@ -0,0 +1,2 @@ +#!/bin/bash +dmenu -nf '#000' -p "$1" <&- && echo diff --git a/loopdwm b/loopdwm new file mode 100755 index 0000000..41cb377 --- /dev/null +++ b/loopdwm @@ -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 diff --git a/touchtog b/touchtog new file mode 100755 index 0000000..6484e29 --- /dev/null +++ b/touchtog @@ -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 diff --git a/volcont b/volcont new file mode 100755 index 0000000..9faf644 --- /dev/null +++ b/volcont @@ -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