Blob


1 # dtoggle
3 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.
5 I use the toggle option with the `XF86Display` key (Fn + F7) on my Thinkpad:
7 ```
8 bindsym XF86Display exec "~/Documents/bin/dtoggle -t"
9 ```
11 ## Usage Scenarios
13 ### Connected to a projector
15 You connect your laptop to a projector and you do not have (the time to cerate) a profile. Just use the -t option to switch between all displays options on all connected displays.
17 ```
18 dtoggle -t
19 ```
21 ### Switch between the laptop display and a docking station with connected displays
23 Add a profile named *foo* and use -p foo once you dock in or out.
25 ```
26 dtoggle -p foo -e
27 ```
29 ## Config File
31 dtoggle 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:
33 ```
34 # Set your desired profile here
35 PROFILE=home
36 ```
38 ## Command Line Options
40 ```
41 dtoggle [-ceix] [-hmntv] [-lr] -p profile
43 Display Options:
44 -c Clone screen on all displays
45 -e Enable external display(s) and disable internal
46 -i Enable only the internal display
47 -x Extend screen to all displays [default]
49 General Options:
50 -h Show this help
51 -m Show all available modes
52 -n Dry run. Do not run xrand. Implies -v
53 -t Toggle different options"
54 -v Be more verbose
56 Position:
57 -l Display n is left of display (n+1)
58 -r Display n is right of display (n+1) [default]
60 Profile:
61 -p profile Enable the specified profile
62 ```
64 ## Add a new Profile
66 1. Clone the repository and copy dtoggle to a location in your `$PATH`
67 2. Open the file in a text editor, look for the `choose_profile()` function and change the profiles to your needs or add new ones. I included my profiles for home, work and projector. In order to get the names of the displays, connect them and run `dtoggle -m`. Look for the strings that say "connected". Add the name of your internal display to `INTERN` and all names of your external displays to `EXTERN[0]` up to `EXTERN[n]`. Note: The order of the entries is important, i.e. entry number n is either left of right (depending on the option) of number (n+1)!
69 ```bash
70 function choose_profile()
71 {
72 [...]
73 case "$PROFILE" in
74 # Home profile: Internal on, external extended
75 home)
76 INTERN="LVDS1"
77 EXTERN[0]="HDMI1"
78 ;;
79 [...]
80 # -----------------------------------------------------------------------
81 # Add your own profiles here.
82 # -----------------------------------------------------------------------
83 # name)
84 # INTERN="LVDS1"
85 # EXTERN[0]="VGA1"
86 # ...
87 # EXTERN[n]="VGAn"
88 # ;;
89 # -----------------------------------------------------------------------
90 ```
92 3. Check the command line options with `dtoggle -h` and enjoy.
94 ## Bugs
96 None. Nevertheless, I you find something annoying, send me an email.
98 ## License
100 GNU GPL.
102 ## Author
104 Matthias Schmidt (xhr giessen.ccc.de)