commit - 0b2693ea5b37862e2b02c5e1313ec82d5b197298
commit + ea40b928a936e70e1db17036e68180ad81511a84
blob - fd77c0fdc772ae2f210854afc8b3872ccf9ae103
blob + 07059db5cfc036b7a7520dfbfcbd7913d4686e42
--- README.md
+++ README.md
dtoggle
=======
-Small bash script that uses xrandr to configure internal/external displays. I use it here with Arch Linux and i3 whenever I connect one or more external displays2
+Small bash script that uses xrandr to configure internal/external displays. I use it here with Arch Linux and i3 whenever I connect one or more external displays.
Command Line Options
--------------------
```
-dtoogle.sh [-ceix] [-hmnv] [-lr] -p profile
+dtoogle [-ceix] [-hmntv] [-lr] -p profile
Display Options:
-c Clone screen on all displays
-x Extend screen to all displays [default]
General Options:
- -h Show this help
+ -h Show this help
-m Show all available modes
-n Dry run. Do not run xrand. Implies -v
+ -t Toggle different options"
-v Be more verbose
Position:
blob - a9e1b249b00101c566c0d775643ad49c68720dfa
blob + de4bc0b27945ecc5ac650a55ede8546d1a871e20
--- dtoogle
+++ dtoogle
# Quick-n-dirty script to turn external/internal displays on/off with xrandr
#
-# 2013 by Matthias Schmidt <xhr giessen.ccc.de>
+# 2013-14 by Matthias Schmidt <xhr giessen.ccc.de>
#
# License GNU GPL
+function get_last_option()
+{
+ # Check if dtoggle saved the last state
+ if [ -f ${DTCONF} ]; then
+ . ${DTCONF}
+ fi
+}
+
+function write_last_option()
+{
+ echo "STATE=${STATE}" > ${DTCONF}
+}
+
+function toggle_option()
+{
+ STATE=$(((${STATE} + 1) % 4))
+}
+
function choose_profile()
{
local PROFILE=$1
exit 1
;;
esac
+
+ # Set options deliberatly if toogle mode is on
+ if [ ${TFLAG} -eq 1 ]; then
+ # 0 = extend
+ # 1 = mirror
+ # 2 = internal only
+ # 3 = external only
+ case "${STATE}" in
+ 0)
+ # Do nothing here
+ ;;
+ 1)
+ CFLAG=1
+ ;;
+ 2)
+ IFLAG=1
+ ;;
+ 3)
+ EFLAG=1
+ ;;
+ esac
+ fi
# Only enable the internal display
if [ $IFLAG -eq 1 ]; then
function usage()
{
- echo "`basename $0` [-ceix] [-hmnv] [-lr] -p profile"
+ echo "`basename $0` [-ceix] [-hmntv] [-lr] -p profile"
echo
echo "Display Options:"
echo " -c Mirror screen on all displays"
echo " -h Show this help"
echo " -m Show all available modes"
echo " -n Dry run. Do not run xrand. Implies -v"
+ echo " -t Toggle different options"
echo " -v Be more verbose"
echo
echo "Position:"
EFLAG=0
# Enable only the internal display
IFLAG=0
+# Toggle different modes
+TFLAG=0
# Verbosity
VERBOSE=0
# Display n is right of display (n+1) [default]
RIGHTOF=1
# Additional options for xrandr
XRANDROPTS=""
+# dtoggle state file
+DTCONF=$HOME/.dtoogle
+# Default status
+STATE=0
-while getopts "ciehmnrlp:vx" opt; do
+while getopts "ciehmnrlp:vxt" opt; do
case $opt in
c)
CFLAG=1
e)
EFLAG=1
;;
+ t)
+ TFLAG=1
+ ;;
v)
VERBOSE=1
;;
exit 1
fi
+if [ ${TFLAG} -eq 1 ]; then
+ get_last_option
+ toggle_option
+ write_last_option
+fi
+
choose_profile $PROFILE
run_xrandr