commit - ab022475b817408db50711133f962d76581e3a63
commit + 94fd26e60361c277ecaa7675b75d581142755e2f
blob - 0afdbfdd1a0ab8509124c13dc407a485fc0dc5a5
blob + e126e6aee66573471f4a6b60cf6e44767f3e4c98
--- 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 displays.
+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.
-I use the toggle option with the XF86Display key (Fn + F7) on my Thinkpad:
+I use the toggle option with the `XF86Display` key (Fn + F7) on my Thinkpad:
```
bindsym XF86Display exec "~/Documents/bin/dtoogle -p home -t"
```
+Config File
+-----------
+
+dtoogle can read the to be used profile from a config file in `$HOME/.dtoggle.conf`. If the config file is not present you have to specify the profile using the -p option. The file looks as follows:
+
+```
+# Set your desired profile here
+PROFILE=home
+```
+
Command Line Options
--------------------
blob - de4bc0b27945ecc5ac650a55ede8546d1a871e20
blob + ae8522a77e880a8c5d64d16e94aac261fa10fac6
--- dtoogle
+++ dtoogle
#
# 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
function run_xrandr()
{
echo "$CMD $XRANDROPTS" | sh
+}
+
+function read_config()
+{
+ if [ -f ${DTCONF} ]; then
+ . ${DTCONF}
+ fi
+}
+
+function get_last_option()
+{
+ # Check if dtoggle saved the last state
+ if [ -f ${DTSTATE} ]; then
+ . ${DTSTATE}
+ fi
}
+function write_last_option()
+{
+ echo "STATE=${STATE}" > ${DTSTATE}
+}
+
+function toggle_option()
+{
+ STATE=$(((${STATE} + 1) % 4))
+}
+
function usage()
{
echo "`basename $0` [-ceix] [-hmntv] [-lr] -p profile"
# Additional options for xrandr
XRANDROPTS=""
# dtoggle state file
-DTCONF=$HOME/.dtoogle
+DTSTATE=$HOME/.dtoogle
+# dtoggle state file
+DTCONF=$HOME/.dtoogle.conf
# Default status
STATE=0
exit 1
fi
+read_config
+
+exit
if [ ${TFLAG} -eq 1 ]; then
get_last_option
toggle_option
blob - /dev/null
blob + 785d2e087e7047dd10697a08529a5c7f358c05b4 (mode 644)
--- /dev/null
+++ dtoogle.conf.sample
+# Set your desired profile here
+PROFILE=home