forked from kalbasit/MultiWmXinitrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Xinitrc.in
471 lines (427 loc) · 11.4 KB
/
Xinitrc.in
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
#!/usr/bin/env bash
#
# Script executed by startx (run your window manager from here)
#
# vim:ft=sh:fenc=UTF-8:ts=4:sts=4:sw=4:expandtab:foldmethod=marker:foldlevel=0:
#
# A little script to make mplayer a totem-like player from One point of vue of course
# This little script will open an mplayer window at the far top/left of the screen
# with a fixed (320 pixel) size, and will use it for all the next videos to play,
# very usefull, and saves a lot of headaches when opening Video Clips while working
# or surfing the net :)
#
# Copyright (c) 2009 Wael Nasreddine <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
# Software version
VERSION="@VERSION@"
# Software Author
AUTHOR="Wael Nasreddine <[email protected]>"
# Determine the location of the functions file and source it.
if [ -f "@BASHLIBDIR@/functions/scripts" ]; then
source "@BASHLIBDIR@/functions/scripts"
else
echo "$0: The required functions file could not be found, Aborting..."
exit 54
fi
####
# Functions
Conky() {
if which conky &> /dev/null; then
if [ -f "${HOME}/.conkyrc.0" ]; then
(
# Sleep 15 seconds to allow the window manager
# to be loaded properly or in some cases (like fvwm)
# conky will stay on top!
sleep 15
# Launch a conky process for each config file
for i in ${HOME}/.conkyrc.?; do
while ! conky -d -c "${i}"; do
continue
done
done &
) & > /dev/null
elif [ -f "${HOME}/.conkyrc" ]; then
# See the above note.
( sleep 10 && conky -d & )
fi
fi
}
Xmodmap() {
if [ -f ${HOME}/.Xmodmap -a -x "`which xmodmap`" ]; then
print_info 0 "Loading Xmodmap..."
xmodmap ${HOME}/.Xmodmap || print_error 0"Failed to load Xmodmap."
else
print_error 0 "Can't load Xmodmap due to missing files."
fi
}
Xbindkeys() {
if [ -f ${HOME}/.xbindkeysrc -a -x "`which xbindkeys`" ]; then
print_info 0 'Launching xbindkeys...'
LC_ALL=C xbindkeys || print_error 0 'Failed to launch xbindkeys'
fi
}
Pidgin() {
if [ -x "`which pidgin`" ]; then
print_info 0 "Launching Pidgin."
needNet pidgin
fi
}
Skype() {
if [ -x "`which skype`" ]; then
print_info 0 "Launching Skype"
needNet skype
fi
}
Xscreensaver() {
if [ -x "`which xscreensaver`" ]; then
print_info 0 "Launching xscreensaver..."
xscreensaver -nosplash &
fi
}
Rand_background() {
if [ -x ${HOME}/bin/rand_background ]; then
print_info 0 "Launching Random Background."
${HOME}/bin/rand_background || print_error 0 "Failed to launch Random Background."
if [ $? -ne 0 -a -f ${HOME}/.fehbg -a -x "`which feh`" ]; then
print_info 0 "Setting static background..."
eval $(cat ${HOME}/.fehbg) || print_error 0 "Failed to set static background."
fi
fi
}
Autocutsel() {
if [ -x "`which autocutsel`" ]; then
print_info 0 "Launching autocutsel..."
#this will keep the clipboard in sync
# with the primary buffer
autocutsel -selection CLIPBOARD -fork || print_error 0 "Failed to launch autocutsel"
fi
}
Urxvtd() {
# Run urxvt daemon
if [ -x "`which urxvtd`" ]; then
print_info 0 "Launching urxvt daemon..."
urxvtd --opendisplay --fork || print_error 0 "Failed to launch urxvt daemon"
fi
}
Urxvt() {
if [ -x "` which urxvt`" ]; then
print_info 0 "Launching urxvt"
urxvt &
fi
}
Urxvtc() {
if [ -x "` which urxvtc`" ]; then
print_info 0 "Launching urxvt"
(sleep 3; urxvtc) &
fi
}
Syndaemon() {
if [ -x "`which syndaemon`" ]; then
print_info 0 "Launching syndaemon..."
# This willl prevent mouse from moving when keyboard
# is being used, prevents accidental jumps
syndaemon -k -d -i '0.5' || print_error 0 "Failed to launch syndaemon"
fi
}
XsetFont() {
# Add My personal font directory
[ -x "`which xset`" ] && \
xset +fp $HOME/.fonts
}
Xset() {
if [ -x "`which xset`" ]; then
print_info 0 'Configuring X...'
xset dpms 600 1200 4200 s 300 600 -b r 66 r rate 400 30 || print_error 0 'Failed to configure X'
# Activate Ctrl+Alt+Backspace
#setxkbmap -option terminate:ctrl_alt_bksp
fi
}
Xrdb() {
if [ -x "`which xrdb`" ]; then
print_info 0 'Loading X ressources...'
xrdb -merge ~/.Xdefaults || print_error 0 'Failed to load X ressources'
fi
}
WMLauncher() {
print_info "Welcome to MultiWmXinitrc version ${VERSION}, written by ${AUTHOR}"
WMPath="${1}"
if [ -x "${WMPath}" ]; then
exec ${use_consolekit} ${use_dbus} "${WMPath}" &> "${HOME}/.Xinitrc-session"
elif [ -x "$(which ${WMPath})" ]; then
exec ${use_consolekit} ${use_dbus} "$(which ${WMPath})" &> "${HOME}/.Xinitrc-session"
else
print_error 0 "Sorry but ${WMPath} is either invalid or not installed."
exit 1
fi
}
NumlockX() {
if [ -x "`which numlockx`" ]; then
print_info 0 "Launching numlockx..."
numlockx || print_error 0 "Failed to launch numlockx"
fi
}
Unclutter() {
if [ -x "`which unclutter`" ]; then
print_info 0 "Launching unclutter..."
unclutter -idle 2 &
else
print_warning 0 "unclutter not found."
fi
}
Mouse() {
xset m '4/1' '4'
}
MousePointer() {
if [ -x "`which xsetroot`" ]; then
print_info 0 'Setting pointer...'
xsetroot -cursor_name left_ptr || print_error 0 'Failed to set pointer'
fi
}
GnomeObexServer() {
if which gnome-obex-server &> /dev/null; then
gnome-obex-server &
fi
}
Dbus() {
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
if which dbus-launch >/dev/null; then
print_info 0 'Launching D-BUS per-session daemon...'
eval `dbus-launch --sh-syntax --exit-with-session` || print_error 0 "Failed to launch D-Bus session daemon"
print_info 1 "D-BUS per-session daemon address: ${DBUS_SESSION_BUS_ADDRESS}"
fi
fi
}
Xcomposite() {
if [ -x "`which xcompmgr`" ]; then
print_info 0 'Launching composite manager...'
xcompmgr -c -C -o0.2 -t1 -l1 -r2 || print_error 0 'Failed to launch composite manager' &
fi
}
NmApplet() {
if [ -x "`which nm-applet`" ]; then
print_info 0 "Launching nm-applet"
nm-applet &
fi
}
GnomePowerManager() {
if [ -x "`which gnome-power-manager`" ]; then
print_info 0 "Launching gnome power manager"
gnome-power-manager &
fi
}
GnomeSettingsDaemon() {
for gsd in /usr/libexec/gnome-settings-daemon /usr/local/libexec/gnome-settings-daemon; do
if [ -x "${gsd}" ]; then
"${gsd}"
break
fi
done
}
Xtrlock() {
if [ -x "`which xtrlock`" ]; then
print_info 0 "Launching xtrlock"
xtrlock &
fi
}
Default() {
Dbus
Xrdb
Xset
Xmodmap
Xbindkeys
Xscreensaver
Autocutsel
XsetFont
Syndaemon
Unclutter
Conky
NumlockX
Rand_background
#Mouse
MousePointer
NmApplet
}
AwesomeStartup() {
GnomeSettingsDaemon
Pidgin
Skype
Xtrlock
Urxvtd
Urxvtc
}
#
####
#
# Windows Manager
#
# Determine if we want to use dbus or not
# This makes gnome (and other apps) works properly
# NOTE: This is disabled because dbus should be launched
# as a daemon not invoke the session itself
use_dbus=""
# Determine if we want to launch using ck-launch-session
if [ -x "`which ck-launch-session`" ]; then
use_consolekit="`which ck-launch-session`"
else
use_consolekit=""
fi
# Auto launch depending on the symlink
if echo "${1}" | grep -q -- '--wm='; then
wm="${1##--wm=}"
shift
fi
if [ -z "${wm}" -a -L "${HOME}/.xinitrc" ]; then
self="`readlink ${HOME}/.xinitrc`"
wm="$(basename ${self})"
fi
print_info 0 "Launching the window manager ${wm}."
# WM
case "${wm}" in
gnome)
# Gnome
#Conky
Xmodmap
XsetFont
#Syndaemon
#GnomeObexServer
WMLauncher gnome-session
;;
awesome)
# Awesome
Default
AwesomeStartup
WMLauncher awesome
;;
e16)
# E16
Xmodmap
Xbindkeys
XsetFont
NumlockX
WMLauncher e16
;;
xfce|xfce4|xfce4-session)
# XFCE4
Xmodmap
Xbindkeys
Xscreensaver
XsetFont
NumlockX
Conky
if [ "$(hostname)" = "phoenix" ]; then
Syndaemon
GnomeObexServer
fi
if ! ps -edf | grep -v grep | grep -q 'xfwm4'; then
xfwm4 --daemon
fi
WMLauncher xfce4-session
;;
fvwm)
# fvwm
Default
WMLauncher fvwm
;;
fvwm-crystal)
# fvwm-crystal
Default
WMLauncher fvwm-crystal
;;
xfce)
# xfce
Default
WMLauncher startxfce4
;;
wmaker)
# wmaker
Default
WMLauncher wmaker
;;
kde)
# KDE
WMLauncher startkde
;;
kde_3.5)
# KDE 3.5
Conky
WMLauncher /usr/kde/3.5/bin/startkde
;;
kde_4.0)
# KDE 4.0
WMLauncher /usr/kde/4.0/bin/startkde
;;
icewm)
# icewm
Default
WMLauncher icewm
;;
blackbox)
# Blackbox
Default
WMLauncher blackbox
;;
fluxbox)
# Fluxbox
Default
WMLauncher fluxbox
;;
mplayer)
# Mplayer video session
if [ ! -e "${HOME}/.mplayer/input.fifo" ]; then
mkfifo "${HOME}/.mplayer/input.fifo"
fi
$(/usr/bin/which mplayer) -fs -zoom -slave -idle -input file="${HOME}/.mplayer/input.fifo" &> ${HOME}/.mplayer/output.txt
;;
wmii)
# wmii
Default
if [ -x "`which autocutsel`" ]; then
#this will keep the primary in sync
# with the clipboard buffer
autocutsel -selection PRIMARY -fork
fi
WMLauncher wmii
;;
ion)
# Ion
Default
WMLauncher ion
;;
ion3)
# Ion 3
Default
WMLauncher ion3
;;
rox|rox-start|rox-session)
# Rox Session
Default
WMLauncher rox-start
;;
ratpoison)
# Rat Poisin
Autocutsel
Rand_background
Xmodmap
Xscreensaver
WMLauncher ratpoison
;;
*)
print_error 0 "None of the valid wm has been selected, Aborting..."
exit 1
;;
esac