aboutsummaryrefslogtreecommitdiff
path: root/xsessionrc.dot.link
blob: a77b3a6a8e3ed6d93d73ffddbd82c73d5cdfc044 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
#
# .xsession: set basic X11 environment
#

# Background image
BACKGROUND=""

# Session applications
PROGRAMS="xconky"

# OS Version
OSVERSION="`cut -d . -f 1 /etc/debian_version`"

# Hostname
HOSTNAME="`cat /etc/hostname`"

# Output
# Example: OUTPUT="VGA-1"
OUTPUT=""

# Custom config
if [ -e "$HOME/.custom/xsession" ]; then
  . $HOME/.custom/xsession
fi

# Set output display if defined in custom configuration
if [ ! -z "$OUTPUT" ] && xrandr | grep -q "^$OUTPUT connected"; then
  # Disable all other outputs
  for device in `xrandr | grep " connected " | cut -d ' ' -f 1 | xargs`; do
    if [ "$device" != "$OUTPUT" ]; then
      xrandr --output $device --off
    fi
  done

  # Turn on the desired device
  xrandr --output $OUTPUT --auto
fi

# Start xscreensaver
if [ -e "/usr/bin/xscreensaver" ]; then
  xscreensaver -no-splash &
fi

# Set background
if [ "$BACKGROUND" = "all" ]; then
  feh --bg-scale --randomize $HOME/.config/themes/backgrounds/*
elif [ ! -z "$BACKGROUND" ] && [ "$BACKGROUND" != "unset" ]; then
  #Esetroot -scale $HOME/.config/themes/backgrounds/$BACKGROUND
  feh --bg-scale $HOME/.config/themes/backgrounds/$BACKGROUND
elif [ "$BACKGROUND" != "unset" ]; then
  #xsetroot -solid black
  xsetroot -solid '#1C1C1C'
fi

# See https://wiki.archlinux.org/index.php/Compton
if which compton > /dev/null 2>&1; then
  if [ -e "$HOME/.config/compton.conf" ]; then
    compton --config $HOME/.config/compton.conf -b
  else
    compton -b
  fi
fi

# See https://wiki.archlinux.org/index.php/Xcompmgr
if which xcompmgr > /dev/null 2>&1; then
  xcompmgr -c &
fi

# Set window manager
if [ -z "$WINDOW_MANAGER" ]; then
  WINDOW_MANAGER='awesome'
fi

# Custom SSH_ASKPASS config
# See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=606934
#export SSH_ASKPASS="/usr/bin/ssh-askpass-fullscreen"
#export SSH_ASKPASS="/usr/lib/pssh/pssh-askpass"
#export SSH_ASKPASS=""
export SSH_ASKPASS="/usr/lib/ssh/x11-ssh-askpass"

# SSH and GPG Agents
#if [ -x "$HOME/apps/utils-ssh/ssh-agent-loadkeys" ]; then
#  . $HOME/apps/utils-ssh/ssh-agent-loadkeys
#fi

# Make sure to load the profile
. $HOME/.profile

# Additional applications depending on the machine type
#if laptop-detect; then
#  PROGRAMS="$PROGRAMS xwicd"
#else
#  PROGRAMS="$PROGRAMS"
#fi

# Start session applications
for program in $PROGRAMS; do
  $program &
done

# Apply default keyboard configuration
if [ -f "$HOME/.Xmodmap" ]; then
  xmodmap $HOME/.Xmodmap
fi

# Apply custom keyboard configuration
if [ -f "$HOME/.Xmodmaps/$HOSTNAME" ]; then
  xmodmap $HOME/.Xmodmaps/$HOSTNAME

  # Why xmodmap has to run twice to some changes take place?
  # https://faq.i3wm.org/question/558/xmodmap-loading/
  # https://bugs.launchpad.net/ubuntu/+source/gdm/+bug/700309
  xmodmap $HOME/.Xmodmaps/$HOSTNAME
fi

# Fix mumble configuration, which varies depending on machine audio
if [ -f "$HOME/.config/Mumble/Mumble-$HOSTNAME.conf" ]; then
  (
    cd $HOME/.config/Mumble
    mv Mumble.conf Mumble-$HOSTNAME.conf.backup
    ln -s Mumble-$HOSTNAME.conf Mumble.conf
  )
fi

# Clipboard management
# See http://mutelight.org/subtleties-of-the-x-clipboard
#if which autocutsel > /dev/null 2>&1; then
#  autocutsel -fork &
#  autocutsel -selection PRIMARY -fork &
#fi
if which parcellite > /dev/null 2>&1; then
  parcellite -n &
fi

# Keyring
if [ "$OSVERSION" != "6" ] && which gnome-keyring-daemon > /dev/null; then
  # See https://bugzilla.redhat.com/show_bug.cgi?id=783568
  #     https://bugs.launchpad.net/ubuntu/+source/gnome-keyring/+bug/932177
  #     http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=653011
  #     https://bugzilla.gnome.org/show_bug.cgi?id=660240
  #unset GNOME_KEYRING_PID
  #unset GNOME_KEYRING_CONTROL
  #eval $(gnome-keyring-daemon --start --components=pkcs11,gpg,secrets)
  #eval $(gnome-keyring-daemon --start --components=pkcs11,secrets)
  true
fi

# Polkit agent
# See https://leap.se/en/docs/client/known-issues#no-polkit-agent-available-error
if [ -e "/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1" ]; then
  /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 &
fi

# Make sure to finish all background processes
#trap 'kill $(jobs -p)' EXIT

# Pulse audio
if [ "$OSVERSION" = "9" ] && which pulseaudio > /dev/null 2>&1; then
  # Works on stretch backwards, but not on buster onwards
  pulseaudio --start
elif which start-pulseaudio-x11 > /dev/null 2>&1; then
  start-pulseaudio-x11
fi

# Start spice-vdagent if needed
if [ -e "/dev/virtio-ports/com.redhat.spice.0" ] && [ -x "/usr/bin/spice-vdagent" ]; then
  spice-vdagent
fi

# Check for unclutter
if [ -x "/usr/bin/unclutter" ]; then
  /usr/bin/unclutter &
fi

# Kill any previous powerline-awesome instance
# A window manager like Awesome may later start a new instance so it can appear at the wibar
kill `pidof -x /usr/share/powerline/bindings/awesome/powerline-awesome.py` > /dev/null 2>&1

# Java config
# See http://stackoverflow.com/questions/29494915/android-sdk-on-debian-linux-has-blank-windows
#     https://wiki.archlinux.org/index.php/Java#Non-reparenting_window_managers
export _JAVA_AWT_WM_NONREPARENTING=1

# Next window config (keyringer)
export XDOTOOL_NEXT_WINDOW="Super_L+Tab"

# Start window manager
if [ "$OSVERSION" = "7" ] || [ "$START_WINDOW_MANAGER" = "true" ]; then
  $WINDOW_MANAGER
fi

# Post processing
if [ -e "$HOME/.custom/xsession-ready" ]; then
  . $HOME/.custom/xsession-ready
fi

# Run startup scripts
#if [ -d "$HOME/.custom/xsessionrc.d" ];
#  run-parts $HOME/.custom/xsessionrc.d
#fi