commit d294dcb0a720aedbae3bc81822563054b2fba97c
parent 00623577403e75352dad5bd3d1f3787454b50ac7
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Fri, 8 Mar 2019 09:41:21 +0100
Add and use slroot variable, fix shellcheck warnings
Diffstat:
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/links/bin/colortheme b/links/bin/colortheme
@@ -3,6 +3,7 @@ set -e
version="0.1.0"
themedir=~/.colors
+slroot=~/code/dotfiles/lib
function die {
printf '%s \n' "$1" >&2
@@ -15,9 +16,9 @@ function show_help {
echo " list: Show all color schemes available in $themedir"
echo " set: Write colors from THEMENAME to:"
echo " ~/.Xresources"
- echo " ~/code/st/config.h"
- echo " ~/code/tabbed/config.h"
- echo " ~/code/dwm/config.h"
+ echo " $slroot/st/config.h"
+ echo " $slroot/tabbed/config.h"
+ echo " $slroot/dwm/config.h"
echo " if they exist."
echo "Valid OPTIONS are:"
echo " -h, --help show this message"
@@ -36,8 +37,8 @@ function show_themes {
}
function get_theme_color {
- ! [ -f $path ] && die "Error: Could not find $path"
- grep --ignore-case "^\*\.*$1:" $path | awk '{ print $2 }'
+ ! [ -f "$path" ] && die "Error: Could not find $path"
+ grep --ignore-case "^\*\.*$1:" "$path" | awk '{ print $2 }'
}
function report_colors {
@@ -64,7 +65,7 @@ function report_colors {
function get_colors {
path="$themedir/$1"
- ! [ -f $path ] && die "Error: Could not find $path"
+ ! [ -f "$path" ] && die "Error: Could not find $path"
foreground=$(get_theme_color foreground)
background=$(get_theme_color background)
color0=$(get_theme_color color0)
@@ -120,14 +121,13 @@ function set_colors {
s/^\*\.color13: .*$/\*.color13: $color13/;\
s/^\*\.color14: .*$/\*.color14: $color14/;\
s/^\*\.color15: .*$/\*.color15: $color15/;\
- s/^\*\.color16: .*$/\*.color16: $color16/;\
s/^\*\.cursorColor: .*$/\*.cursorColor: $cursorColor/" ~/.Xresources
xrdb -merge ~/.Xresources
command -v i3-msg >/dev/null 2>&1 && (i3-msg restart || :)
[[ -x ~/bin/wallpaper.sh ]] && ~/bin/wallpaper.sh
fi
- if [ -f ~/code/st/config.h ]; then
+ if [ -f $slroot/st/config.h ]; then
sed -i "s/^\t\[257\] = \".*\",.*$/\t\[257\] = \"$foreground\",/;\
s/^\t\[256\] = \".*\",.*$/\t\[256\] = \"$background\",/;\
s/^\t\[0\] = \".*\",.*$/\t\[0\] = \"$color0\",/;\
@@ -146,29 +146,29 @@ function set_colors {
s/^\t\[13\] = \".*\",.*$/\t\[13\] = \"$color13\",/;\
s/^\t\[14\] = \".*\",.*$/\t\[14\] = \"$color14\",/;\
s/^\t\[258\] = \".*\",.*$/\t\[258\] = \"$cursorColor\",/"\
- ~/code/st/config.h
- (cd ~/code/st && sudo make install)
+ $slroot/st/config.h
+ (cd $slroot/st && sudo make install)
fi
- if [ -f ~/code/tabbed/config.h ]; then
+ if [ -f $slroot/tabbed/config.h ]; then
sed -i "s/normbgcolor \+= \".*\";/normbgcolor = \"$background\";/;\
s/normfgcolor \+= \".*\";/normfgcolor = \"$foreground\";/;\
s/selfgcolor \+= \".*\";/selfgcolor = \"$background\";/;\
s/selbgcolor \+= \".*\";/selbgcolor = \"$foreground\";/;\
s/urgbgcolor \+= \".*\";/urgbgcolor = \"$color9\";/;\
s/urgfgcolor \+= \".*\";/urgfgcolor = \"$color0\";/"\
- ~/code/tabbed/config.h
- (cd ~/code/tabbed && sudo make install)
+ $slroot/tabbed/config.h
+ (cd $slroot/tabbed && sudo make install)
fi
- if [ -f ~/code/dwm/config.h ]; then
+ if [ -f $slroot/dwm/config.h ]; then
sed -i "s/col_gray4\[\] *= \".*\";/col_gray4\[\] = \"$background\";/;\
s/col_cyan\[\] *= \".*\";/col_cyan\[\] = \"$foreground\";/;\
s/col_gray3\[\] *= \".*\";/col_gray3\[\] = \"$foreground\";/;\
s/col_gray1\[\] *= \".*\";/col_gray1\[\] = \"$background\";/;"\
- ~/code/dwm/config.h
- (cd ~/code/dwm && sudo make install)
+ $slroot/dwm/config.h
+ (cd $slroot/dwm && sudo make install)
fi
}