General cleanup for readability, Move all display and touchscreen configuration to srandrd config, Add a harder failure case for when srandrd is not installed, Use a case statement instead of multiple if statements for host-specific configuration

This commit is contained in:
David Thurstenson 2017-02-16 02:29:56 -06:00
parent 72ffcb2e24
commit 5a43d3eba2
2 changed files with 62 additions and 33 deletions

View File

@ -1,12 +1,44 @@
#!/bin/bash
maptouchscreen() {
# maptouchscreen <name> <output>
# <name> should be a full name from the output of `xinput list`
# <output> should be an xrandr output name
xinput --map-to-output $(xinput list --idonly "$1") $2
}
case "$SRANDRD_ACTION" in
"HDMI-1 connected") xrandr --output HDMI-1 --auto --right-of eDP-1
xinput --map-to-output $(xinput list --id-only "ELAN Touchscreen") eDP-1
pacmd set-default-sink 0;;
"HDMI-1 disconnected") xrandr --output HDMI-1 --off --output eDP-1 --auto
xinput --map-to-output $(xinput list --id-only "ELAN Touchscreen") eDP-1
pacmd set-default-sink 1;;
setpasink() {
# setpasink <name>
# Find a unique string in the output of `pacmd list short` to use for <name>
pacmd set-default-sink $(pacmd list short | grep $1 | grep -o "^\S\+")
}
case "$(hostname)" in
"thurstybook")
tsid="ELAN Touchscreen"
mainoutput="eDP-1"
hdmi="HDMI-1"
case "$SRANDRD_ACTION" in
"$hdmi connected") xrandr --output $hdmi --auto --right-of $mainoutput
maptouchscreen $tsid $mainoutput
setpasink hdmi
;;
"$hdmi disconnected") xrandr --output $hdmi --off --output $mainoutput --auto
maptouchscreen $tsid $mainoutput
setpasink analog
;;
esac
;;
"dtarchaio")
tsid="Advanced Silicon S.A CoolTouch(TM) System"
mainoutput="eDP1"
hdmi="HDMI1"
xrandr --output $mainoutput --auto --output $hdmi --right-of $mainoutput
maptouchscreen $tsid $mainoutput
;;
esac

View File

@ -22,48 +22,45 @@ fi
#== Thurstylark additions below ==#
# Reference: https://wiki.thurstylark.com/Xinitrc.html
# Set st up as the default terminal for i3-sensible-terminal
export TERMINAL=st
# Default screen locker
# Set DPMS timeout to 10 sec, force DPMS off,
# lock with i3lock without forking, then when
# unlocked, disable DPMS timeout.
SCREEN_LOCKER="xset dpms 0 0 10 dpms force off; i3lock --nofork -befc 000000; xset dpms 0 0 0"
# Default screen lock timeout in minutes
locktime=30
screen_locker="xset dpms 0 0 10 dpms force off; i3lock --nofork -befc 000000; xset dpms 0 0 0"
locktime=30 # Default screen lock timeout in minutes
# Start ssh agent
eval $(ssh-agent)
xset +dpms dpms 0 0 0 # Set DPMS features on, but disabled
eval $(ssh-agent) # Start ssh agent
# If srandrd is installed, start it up
[ -s /usr/bin/srandrd ] && srandrd ~/.config/srandrd.conf
# Thurstybook-specific config:
if [ "$(hostname)" == "thurstybook" ]; then
true # Add stuff here if I need it
# ALL display/xrandr and touchscreen setup should be configured in ~/.config/srandrd.conf!
if [ -s /usr/bin/srandrd ]; then
srandrd ~/.config/srandrd.conf
else
printf "==== FATAL: srandrd does not appear to be installed! ===="
exit 1
fi
# dtarchaio-specific config:
if [ "$(hostname)" == "dtarchaio" ]; then
# Set screen lock timout to 15 minutes
locktime=15
# Set HDMI1 to be right of eDP1
xrandr --output eDP1 --auto --output HDMI1 --right-of eDP1
# Set the bell to be different from Matt's
xset b 75 750 50
# Set Touchscreen to only work on main display
xinput --map-to-output $(xinput list --id-only "Advanced Silicon S.A CoolTouch(TM) System") eDP1
fi
# Host-specific config
case "$(hostname)" in
"dtarchaio")
locktime=15 # Screen lock timeout
xset b 75 750 50 # Set the bell to be different from Matt's
;;
esac
# Automatically lock after $locktime minutes using i3lock
xautolock -time $locktime -locker "$SCREEN_LOCKER" -detectsleep &
# Set DPMS features on, but disabled
xset +dpms dpms 0 0 0
xautolock -time $locktime -locker "$screen_locker" -detectsleep &
# If numlockx is installed, turn numlock on
[ -s /usr/bin/numlockx ] && numlockx on
# Set st up as the default terminal for i3-sensible-terminal
export TERMINAL=st
# If $1 isn't set, use "i3"
session=${1:-i3}