Switch to dotbot

This commit is contained in:
2017-08-26 10:56:11 +02:00
parent 7c4f9c28d0
commit 4faeb99007
30 changed files with 73 additions and 158 deletions

2
i3/scripts/appmenu Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
i3-dmenu-desktop --dmenu="dmenu -fn 'DejaVu Sans:size=11' -i -p '>' -nb '#000000' -nf '#ffffff' -sb '#e16b40' -sf '#000000'"

86
i3/scripts/i3exit Executable file
View File

@@ -0,0 +1,86 @@
#!/bin/bash
### From http://www.archlinux.org/index.php/i3
_logfile="$LOGDIR/i3/i3exit.log"
LOCKSCREEN="$LIBDIR/wallpaper/lockscreen"
_fallback_color=000000
touch "$_logfile"
log()
{
echo "$*"
echo "[$(date +%FT%T)] $*" >> "$_logfile"
}
lock()
{
if [[ -f "$LOCKSCREEN" ]] ; then
i3lock --nofork --show-failed-attempts --ignore-empty-password \
--pointer win --image "$LOCKSCREEN"
else
i3lock --nofork --show-failed-attempts --ignore-empty-password \
--color "$_fallback_color"
fi
}
screen_off() {
xset dpms force off
}
reset_screen() {
xset -dpms
xset s off
}
lock_and_screen_off() {
lock &
_pid=$!
screen_off
wait $_pid
reset_screen
}
signal="$1"
log "[I] Received signal \"$signal\"."
case "$signal" in
lock)
log "[I] Locking session."
lock_and_screen_off
;;
logout)
log "[I] Exiting i3."
i3-msg exit
;;
suspend)
log "[I] Suspending."
lock_and_screen_off &
systemctl suspend
;;
hibernate)
log "[I] Hibernating."
systemctl hibernate
;;
reboot)
log "[I] Rebooting."
systemctl reboot
;;
shutdown)
log "[I] Shutting down."
systemctl poweroff
;;
screen-off)
log "[I] Turning screen off."
lock_and_screen_off
;;
*)
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
log "[E] Signal \"$signal\" unknown. Aborting."
exit 2
esac
log "[I] Done."
exit 0

116
i3/scripts/pa-volume Executable file
View File

@@ -0,0 +1,116 @@
#!/bin/bash
# name of the sink. execute pactl list sinks to get a list
SINKNAME="alsa_output.pci-0000_00_1b.0.analog-stereo"
# this is the worst
SINK=$(( $(pactl list sinks | grep "Name: " | grep -n "${SINKNAME}"$ | grep -o "^[[:digit:]]*") -1))
getvol() {
echo $(pactl list sinks | grep "^[[:space:]]*Volume" | head -n $(( $SINK + 1 )) | tail -n 1 | grep -o "[[:digit:]]*%" | head -n 1 | cut -d "%" -f 1)
}
setvol() {
if [[ $1 =~ [+-][0-9]+ ]] ; then
oldvol="$(getvol)"
echo "oldvol $oldvol"
delta="$(echo "$1" | cut -c 2-)"
echo "delta $delta"
if [[ "$(echo "$1" | cut -c 1)" == "+" ]] ; then
echo "+"
newvol=$(( $oldvol + $delta ))
else
echo "-"
newvol=$(( $oldvol - $delta ))
echo $newvol
fi
if [[ $newvol -gt 100 ]]; then
echo "capping at 100 percent"
newvol=100
fi
if [[ $newvol -lt 0 ]]; then
echo "capping at 0 percent"
newvol=0
fi
echo "newvol $newvol"
else
newvol="$1"
fi
pactl set-sink-volume $SINKNAME $(( $newvol * 65536 / 100 ))
}
ismuted() {
muted=$(pactl list sinks | grep "^[[:space:]]*Mute" | head -n $(( $SINK + 1 )) | tail -n 1 | cut -d " " -f 2)
if [[ $muted == "no" ]]; then
echo 0
else
echo 1
fi
}
mute() {
pactl set-sink-mute $SINK 1
}
unmute() {
pactl set-sink-mute $SINK 0
}
mute-toggle() {
pactl set-sink-mute $SINK toggle
}
status() {
if [[ $(ismuted) == "1" ]] ; then
echo "mute"
return
fi
echo "$(getvol)%"
}
usage() {
echo "Usage:"
echo
echo "$0 get-vol"
echo "$0 set-vol VOL_PERC"
}
case "$1" in
"get-vol")
echo $(getvol)
;;
"set-vol")
if [[ -z "$2" ]] ; then
usage
else
setvol "$2"
fi
hook="$3"
;;
"mute")
mute
hook="$2"
;;
"unmute")
unmute
hook="$2"
;;
"mute-toggle")
mute-toggle
hook="$2"
;;
"is-muted")
echo $(ismuted)
;;
"status")
echo $(status)
;;
*)
usage
;;
esac
if [[ -n "$hook" ]] ; then
echo "volume changed, executing hook: $hook"
$hook
fi

19
i3/scripts/shutdown-menu Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
options=(
"lock"
"logout"
"suspend"
"hibernate"
"reboot"
"shutdown"
"screen-off")
i=1
output=$(
for option in "${options[@]}"; do
echo "($i) $option"
(( i++ ))
done | dmenu -fn 'DejaVu Sans Mono:size=11' -b -i -l 10 -p '>' -nb '#222222' -nf '#ffffff' -sb '#e16b40' -sf '#000000')
[[ "$output" ]] && "$(dirname "$0")"/i3exit "${output#(*) }"