3 # startx configuration file.
5 # Copyright (C) 2011-2013 Simon Ruderich
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # Some systems don't set the LANG environment variable when starting xinitrc,
22 # this causes problems for rxvt-unicode-256color which fails to display UTF-8
23 # characters correctly when LANG is missing and for notify.py which also needs
24 # LANG set (for Python's decode() function). Therefore load my general shell
25 # environment which also includes $LANG.
26 if test -f "$HOME/.shell/env"; then
27 # Debug function used in ~/.shell/env.
38 type "$1" >/dev/null 2>&1
41 if installed xmessage; then
44 # Log message to a file which is displayed by my Zsh setup on startup.
45 echo "$@" >> "$HOME/.xinitrc.errors"
48 # Save PID of the most recently started background process. Used to terminate
49 # them when logging out to prevent unused background processes. On some
50 # systems this is only necessary for some programs (like ssh-agent), haven't
51 # yet figured out why.
52 save_background_pid() {
53 background_pids="$background_pids $!"
58 # Options, can be modified in ~/.xinitrc.local. To disable a boolean option
59 # set it to an empty value.
61 # Default to use a background image.
63 # Lock screen after x minutes of inactivity, requires `xautolock` to be
66 # Locker program to lock the screen, used below with `xautolock`.
69 # Load settings for the local system.
70 if test -f "$HOME/.xinitrc.local"; then
71 . "$HOME/.xinitrc.local"
75 # Start ssh-agent if we have private keys, thanks to
76 # http://code.haskell.org/XMonadContrib/scripts/xinitrc (read on 2011-06-19).
77 if test -x /usr/bin/ssh-agent && test -f "$HOME/.ssh/id_rsa"; then
78 # -s to force bourne shell output. This file is a bourne shell script even
79 # if the environment might suggest otherwise.
80 eval `/usr/bin/ssh-agent -s` >/dev/null
83 # Use a black background for the root window.
86 # Force English keyboard layout.
87 if installed setxkbmap; then
91 # Use my X11 key bindings.
92 xmodmap "$HOME/.xmodmaprc"
94 # Change the background if available.
95 if test -f "$HOME/.background" && test -n "$set_background"; then
96 if installed hsetroot; then
97 hsetroot -full "$HOME/.background"
98 elif installed feh; then
99 feh --bg-scale "$HOME/.background"
100 # Remove the unnecessary ~/.fehbg file created by `feh`. I don't want
101 # to restore the background, I just run `feh` on each startx run.
102 # --no-fehbg is only available in recent feh releases.
107 # Display timed reminders and recheck the file for changes every minute (-z1).
108 if installed remind && test -f "$HOME/.reminders"; then
109 remind -z1 -k'.shell/bin/notify.py %s &' "$HOME/.reminders" &
113 # Set color temperature of display according to time of day.
114 if installed redshift; then
115 redshift -l 49.9:10.9 -t 5500:4500 >/dev/null &
118 # Automatically lock the screen after x minutes of inactivity if `xautolock`
119 # is available. Warn if locker wasn't found.
120 if installed xautolock; then
121 if installed "$screen_locker"; then
122 xautolock -secure -time "$screen_lock_time" -locker "$screen_locker" &
124 error "Locker '$screen_locker' not installed. Auto lock won't work!"
129 # XMonad doesn't start a terminal emulator on its own, start one when I login.
130 (urxvt || rxvt || xterm) &
132 # Start window manager.
137 # Kill ssh-agent to prevent unused background processes.
138 if test -x /usr/bin/ssh-agent; then
139 /usr/bin/ssh-agent -k >/dev/null
140 # No `eval` necessary, we terminate anyway.
142 # Kill remaining background processes.
143 kill $background_pids