]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - xinitrc
xinitrc: Minor documentation update.
[config/dotfiles.git] / xinitrc
1 #!/bin/sh
2
3 # startx configuration file.
4
5 # Copyright (C) 2011-2013  Simon Ruderich
6 #
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.
11 #
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.
16 #
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/>.
19
20
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 set it here, might be
25 # overwritten by shell setup scripts.
26 LANG=en_US.UTF-8
27 export LANG
28
29
30 installed() {
31     type "$1" >/dev/null 2>&1
32 }
33
34
35 # Start ssh-agent if we have private keys, thanks to
36 # http://code.haskell.org/XMonadContrib/scripts/xinitrc (read on 2011-06-19).
37 if test -x /usr/bin/ssh-agent && test -f "$HOME/.ssh/id_rsa"; then
38     # -s to force bourne shell output. This file is a bourne shell script even
39     # if the environment might suggest otherwise.
40     eval `/usr/bin/ssh-agent -s`
41 fi
42
43 # Use a black background for the root window.
44 xsetroot -solid black
45
46 # Force English keyboard layout.
47 if installed setxkbmap; then
48     setxkbmap us
49 fi
50
51 # Use my X11 key bindings.
52 xmodmap "$HOME/.xmodmaprc"
53
54 # Default to use a background image. Can be disabled in .xinitrc.local.
55 set_background=yes
56
57 # Load settings for the local system.
58 if test -f "$HOME/.xinitrc.local"; then
59     . "$HOME/.xinitrc.local"
60 fi
61
62 # Change the background if available.
63 if test -f "$HOME/.background" && test -n "$set_background"; then
64     if installed hsetroot; then
65         hsetroot -full "$HOME/.background"
66     elif installed feh; then
67         feh --bg-scale "$HOME/.background"
68         # Remove the unnecessary ~/.fehbg file created by `feh`. I don't want
69         # to restore the background, I just run `feh` on each startx run.
70         # --no-fehbg is only available in recent feh releases.
71         rm -f "$HOME/.fehbg"
72     fi
73 fi
74
75 # Display timed reminders and recheck the file for changes every minute (-z1).
76 if installed remind && test -f "$HOME/.reminders"; then
77     remind -z1 -k'.shell/bin/notify.py %s &' "$HOME/.reminders" &
78 fi
79
80 # Set color temperature of display according to time of day.
81 if installed redshift; then
82     redshift -l 49.9:10.9 -t 5500:4500 &
83 fi
84
85
86 # XMonad doesn't start a shell on its own, start one when I login.
87 (urxvt || rxvt || xterm) &
88
89 # Start window manager.
90 xmonad