aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/x
blob: 653cfb0351c40f705b2e2e2fa642af8519404ecb (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
#!/bin/sh

# Return to homedir
cd || exit 3

# If an argument is given, check if we have an xinitrc for that
if [ -n "$1" ]
then
	if [ ! -f "$HOME/.local/etc/x/xinit.d/$1.rc" ]
	then
		printf "%s\n" "no valid config for $1" >&2
		exit 1
	fi

	# Remove the old config
	rm -f -- "$HOME/.xinitrc"

	# Add layout script, if one exists
	if [ -f "$HOME/.local/etc/x/layout.sh" ]
	then
		cat "$HOME/.local/etc/x/layout.sh" >> "$HOME/.xinitrc"
	fi

	# Add the base configuration
	cat -- "$HOME/.local/etc/x/xinitrc" "$HOME/.local/etc/x/xinit.d/$1.rc" \
		>> "$HOME/.xinitrc"
fi

# Make sure the xinitrc exists, just in case
if [ ! -f "$HOME/.xinitrc" ]
then
	printf "%s\n" "no xinitrc" >&2
	exit 2
fi

# start the X session
exec startx