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:
		
							parent
							
								
									72ffcb2e24
								
							
						
					
					
						commit
						5a43d3eba2
					
				| @ -1,12 +1,44 @@ | |||||||
| #!/bin/bash | #!/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 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 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 | 		case "$SRANDRD_ACTION" in | ||||||
| 	"HDMI-1 connected")	xrandr --output HDMI-1 --auto --right-of eDP-1 | 			"$hdmi connected")	xrandr --output $hdmi --auto --right-of $mainoutput | ||||||
| 				xinput --map-to-output $(xinput list --id-only "ELAN Touchscreen") eDP-1 | 						maptouchscreen $tsid $mainoutput | ||||||
| 				pacmd set-default-sink 0;; | 						setpasink hdmi | ||||||
| 	"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;; | 			"$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 | esac | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										49
									
								
								.xinitrc
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								.xinitrc
									
									
									
									
									
								
							| @ -22,48 +22,45 @@ fi | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| #== Thurstylark additions below ==# | #== 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 | # Default screen locker | ||||||
|  | 
 | ||||||
| # Set DPMS timeout to 10 sec, force DPMS off, | # Set DPMS timeout to 10 sec, force DPMS off, | ||||||
| # lock with i3lock without forking, then when  | # lock with i3lock without forking, then when  | ||||||
| # unlocked, disable DPMS timeout. | # unlocked, disable DPMS timeout. | ||||||
| SCREEN_LOCKER="xset dpms 0 0 10 dpms force off; i3lock --nofork -befc 000000; xset dpms 0 0 0" | 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 # Default screen lock timeout in minutes | ||||||
| locktime=30 |  | ||||||
| 
 | 
 | ||||||
| # Start ssh agent | xset +dpms dpms 0 0 0 # Set DPMS features on, but disabled | ||||||
| eval $(ssh-agent) | 
 | ||||||
|  | eval $(ssh-agent) # Start ssh agent | ||||||
| 
 | 
 | ||||||
| # If srandrd is installed, start it up | # If srandrd is installed, start it up | ||||||
| [ -s /usr/bin/srandrd ] && srandrd ~/.config/srandrd.conf | # ALL display/xrandr and touchscreen setup should be configured in ~/.config/srandrd.conf! | ||||||
| 
 | if [ -s /usr/bin/srandrd ]; then | ||||||
| # Thurstybook-specific config: | 	srandrd ~/.config/srandrd.conf | ||||||
| if [ "$(hostname)" == "thurstybook" ]; then | else | ||||||
| 	true # Add stuff here if I need it | 	printf "==== FATAL: srandrd does not appear to be installed! ====" | ||||||
|  | 	exit 1 | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| # dtarchaio-specific config: | # Host-specific config | ||||||
| if [ "$(hostname)" == "dtarchaio" ]; then | case "$(hostname)" in | ||||||
| 	# Set screen lock timout to 15 minutes | 	"dtarchaio") | ||||||
| 	locktime=15 | 		locktime=15 # Screen lock timeout | ||||||
| 	# Set HDMI1 to be right of eDP1 | 		xset b 75 750 50 # Set the bell to be different from Matt's  | ||||||
| 	xrandr --output eDP1 --auto --output HDMI1 --right-of eDP1 | 		;; | ||||||
| 	# Set the bell to be different from Matt's  | esac | ||||||
| 	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 |  | ||||||
| 
 | 
 | ||||||
| # Automatically lock after $locktime minutes using i3lock | # Automatically lock after $locktime minutes using i3lock | ||||||
| xautolock -time $locktime -locker "$SCREEN_LOCKER" -detectsleep & | xautolock -time $locktime -locker "$screen_locker" -detectsleep & | ||||||
| # Set DPMS features on, but disabled |  | ||||||
| xset +dpms dpms 0 0 0 |  | ||||||
| 
 | 
 | ||||||
| # If numlockx is installed, turn numlock on | # If numlockx is installed, turn numlock on | ||||||
| [ -s /usr/bin/numlockx ] && numlockx 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" | # If $1 isn't set, use "i3" | ||||||
| session=${1:-i3} | session=${1:-i3} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user