Last active
April 4, 2017 08:35
-
-
Save schtibe/2239eab753be7c8fa4fba14ae4289e6b to your computer and use it in GitHub Desktop.
Screen changer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# LAYOUT SWITCHER | |
# This script provides following functionality: | |
# - When detect is given, the | |
# - When no argument is given, make a dmenu list of the available screen layouts | |
# Last two options are mostly used by the udev system | |
BASE_PATH="/home/sh/.screenlayout" | |
AVAILABLE_LAYOUTS=$(ls -1 $BASE_PATH | awk -F '.' '{ print $1 }') | |
export DISPLAY=":0" | |
export XAUTHORITY=/home/sh/.Xauthority | |
# apparently we don't have any env vars, so make sure path is set for subsequent | |
# scripts | |
export PATH="$PATH:/usr/bin" | |
if [[ $1 == "detect" ]]; then | |
state=$(cat /sys/class/drm/card0/card0-HDMI-A-1/status) | |
if [[ $state == 'disconnected' ]]; then | |
layout="laptop_only.sh" | |
else | |
/usr/bin/xrandr --query | |
# TODO this is *very* static... | |
# What if the monitor is plugged somewhere else? | |
# maybe we could loop and see what is connected? | |
model=$(cat /sys/class/drm/card0/card0-HDMI-A-1/edid | parse-edid | grep 'ModelName') | |
# echo is needed to strip from leading and trailing whitespace | |
if [[ $(echo $model) == 'ModelName "DELL U2715H"' ]]; then | |
layout="liip.sh" | |
else | |
exit 1 | |
fi | |
fi | |
else | |
layout=$(echo -n "$AVAILABLE_LAYOUTS" | dmenu -l 10) | |
layout="$layout.sh" | |
fi | |
/usr/bin/bash "$BASE_PATH/$layout" | |
/usr/bin/bash /home/sh/.fehbg | |
/usr/bin/setxkbmap -layout ch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment