forked from regolith-linux/regolith-styles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regolith-look
executable file
·108 lines (92 loc) · 3.82 KB
/
regolith-look
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
#!/bin/bash
# This is a helper script to perform common tasks with regolith looks.
if [ "$#" -lt 1 ]; then
echo "Usage: regolith-look <command>"
echo "Actions: "
echo " refresh - Update the current session look based on Xresources values"
echo " list - Display currently installed looks in the /etc/regolith/styles directory"
echo " stage - Copy Xresource and i3 config files in the user directory"
echo " set <look> - Write a global override file in the user dir to specify the desired look"
exit 1
fi
COMMAND=$1
refresh() {
# File Locations - Optional User Overrides
USER_XRESOURCE_FILE="$HOME/.Xresources-regolith"
USER_XRESOURCE_OVERRIDE_FILE="$HOME/.config/regolith/Xresources"
USER_XRESOURCE_SEARCH_PATH="$HOME/.config/regolith/Xresources.d"
# File Locations - System Defaults
DEFAULT_XRESOURCE_FILE="/etc/regolith/styles/root"
if [ ! -f "$USER_XRESOURCE_FILE" ]; then
xrdb -merge $DEFAULT_XRESOURCE_FILE
else
# Avoid loading an early version of the Regolith Xresource file
BAD_XRES_HASH="6797c718fc4767653878ef9db5f68017"
HASH=$(md5sum $USER_XRESOURCE_FILE | cut -d " " -f1)
if [ -f "$USER_XRESOURCE_FILE" -a "$HASH" != "$BAD_XRES_HASH" ]; then
xrdb -I$USER_XRESOURCE_SEARCH_PATH -merge $USER_XRESOURCE_FILE
else
xrdb -merge $DEFAULT_XRESOURCE_FILE
fi
fi
# Check for user overrides of Xresources
if [ -f "$USER_XRESOURCE_OVERRIDE_FILE" ]; then
xrdb -I$USER_XRESOURCE_SEARCH_PATH -merge $USER_XRESOURCE_OVERRIDE_FILE
fi
# Change the quotes in workspace names from double to to single.
# Due to a limitation of the preprocessor they have double quotes.
# The i3-wm workspace command fails with double quotes in the name
xrdb -query | grep i3-wm.workspace. | sed "s/\"/'/g" | xrdb -merge
# Set the theme from Xresources values.
gsettings set org.gnome.desktop.interface gtk-theme "`xrescat gnome.gtk.theme Adwaita`"
gsettings set org.gnome.desktop.wm.preferences theme "`xrescat gnome.wm.theme Adwaita`"
gsettings set org.gnome.desktop.interface icon-theme "`xrescat gnome.icon.theme Adwaita`"
# Set the wallpaper
WALLPAPER_FILE=$(xrescat gnome.wallpaper)
if [[ ! -z $WALLPAPER_FILE ]]; then
gsettings set org.gnome.desktop.background picture-uri "file://$(eval echo $WALLPAPER_FILE)"
fi
if [ -f "/usr/bin/create-regolith-term-profile" ]; then
/usr/bin/create-regolith-term-profile
fi
# restart i3-wm after merging Xresources
i3-msg -q restart
}
stage() {
mkdir -p $HOME/.config/regolith/i3
cp -b /etc/regolith/i3/config $HOME/.config/regolith/i3/
cp -b /etc/regolith/styles/root $HOME/.Xresources-regolith
echo "Files $HOME/.config/regolith/i3/config and $HOME/.Xresources-regolith have been created, log back in for them to take effect."
}
set_look() {
if [ -f $HOME/.Xresources-regolith ]; then
echo "Regolith Xresources file ($HOME/.Xresources-regolith) already exists, aborting."
exit 1
fi
if [ -f "/etc/regolith/styles/$LOOK/root" ]; then
echo "#include \"/etc/regolith/styles/$LOOK/root\"" > $HOME/.Xresources-regolith
echo "Created $HOME/.Xresources-regolith pointing to $LOOK."
else
echo "Look $LOOK does not exist or export a root file at /etc/regolith/styles/$LOOK/root."
echo "Aborting."
exit 1
fi
}
if [ "$COMMAND" == "refresh" ]; then
refresh
elif [ "$COMMAND" == "stage" ]; then
stage
elif [ "$COMMAND" == "set" ]; then
LOOK=$2
if [ -z $LOOK ]; then
echo "Must specify a look to set."
exit 1
else
set_look
fi
elif [ "$COMMAND" == "list" ]; then
find /etc/regolith/styles/ -maxdepth 1 -mindepth 1 -type d -printf '%f\n'
else
echo "Unrecognized command: $COMMAND"
exit 1
fi