From 54f1b34a10aa7815afe27e30f9377d5a68a2d04a Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Thu, 3 Sep 2015 16:20:45 +0200 Subject: Added better theming infrastructure to HLWM --- herbstluftwm/.config/herbstluftwm/autostart | 42 +++++++++++--------- herbstluftwm/.config/herbstluftwm/hlwm-keybindings | 2 +- herbstluftwm/.config/herbstluftwm/hlwm-theming | 42 ++++++++++++++++---- .../.config/herbstluftwm/panel_indicators.sh | 10 ++--- herbstluftwm/.config/herbstluftwm/poligons.png | Bin 4592375 -> 0 bytes .../.config/herbstluftwm/populate_panel.sh | 14 +++---- herbstluftwm/.config/herbstluftwm/popup.sh | 4 +- herbstluftwm/.config/herbstluftwm/start_panel.sh | 12 +++--- herbstluftwm/.config/herbstluftwm/themes/purpur | 44 ++++++++++----------- .../.config/herbstluftwm/wallpapers/poligons.png | Bin 0 -> 4592375 bytes 10 files changed, 98 insertions(+), 72 deletions(-) delete mode 100644 herbstluftwm/.config/herbstluftwm/poligons.png create mode 100644 herbstluftwm/.config/herbstluftwm/wallpapers/poligons.png diff --git a/herbstluftwm/.config/herbstluftwm/autostart b/herbstluftwm/.config/herbstluftwm/autostart index 78a81b4..a436283 100755 --- a/herbstluftwm/.config/herbstluftwm/autostart +++ b/herbstluftwm/.config/herbstluftwm/autostart @@ -9,37 +9,38 @@ export -f hc # The current directory export HLWM_CONF_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -#Include the theming script -source "$HLWM_CONF_DIR/themes/current" - -#Detect monitors -hc set auto_detect_monitors 1 -hc detect_monitors +source "$HLWM_CONF_DIR/hlwm-theming" -#Panel and window_p +#Panel and HLWM_WINDOW_PADDING monitor_w=($(hc list_monitors | sed 's/^[0-9]: \([0-9]*\)x.*$/\1/')) -panel_w=$(echo "$monitor_w - (2 * $window_p)" | bc) -dmenu_opts="-h $panel_h -w $panel_w -x $window_p -y $window_p -p Run: -nb $color_bg -nf $color_fg -sb $color_accent -sf $color_bg" +panel_w=$(echo "$monitor_w - (2 * $HLWM_WINDOW_PADDING)" | bc) +dmenu_opts="-h $HLWM_PANEL_HEIGHT -w $panel_w -x $HLWM_WINDOW_PADDING -y $HLWM_WINDOW_PADDING -p Run: -nb $HLWM_BG_COLOR -nf $HLWM_FG_COLOR -sb $HLWM_ACCENT_COLOR -sf $HLWM_BG_COLOR" # Tags tag_names=() tag_keys=({1..9} 0) for key in ${tag_keys[@]}; do - if [ $key -eq 0 ]; then key=10; fi - key=$(echo "$key - 1" | bc) + if [ $key -eq 0 ]; then + key=10 + else + key=$(echo "$key - 1" | bc) + fi + name=$(echo "obase=2;$key" | bc | awk '{ printf "%04d", $0 }') tag_names+=($name) done; # Source hlwm-config-files source "$HLWM_CONF_DIR/hlwm-keybindings" -source "$HLWM_CONF_DIR/hlwm-theming" source "$HLWM_CONF_DIR/hlwm-rules" # Unlock, just to be sure hc unlock -herbstclient set tree_style '╾│ ├└╼─┐' + +#Detect monitors +hc set auto_detect_monitors 1 +hc detect_monitors # Start panel in all monitors panel=$HLWM_CONF_DIR/start_panel.sh @@ -51,11 +52,16 @@ done pulseaudio --start $HLWM_CONF_DIR/start.sh "xautolock -time 5 -locker $HLWM_CONF_DIR/lock.sh" -$HLWM_CONF_DIR/start.sh "feh --bg-fill $wallpaper" -$HLWM_CONF_DIR/start.sh "compton --config $HOME/.compton" -$HLWM_CONF_DIR/start.sh "xrdb -load $HOME/.Xresources" -$HLWM_CONF_DIR/start.sh "xset +fp /usr/share/fonts/local" -$HLWM_CONF_DIR/start.sh "xset fp rehash" + +if $HLWM_COMPOSITING; then + $HLWM_CONF_DIR/start.sh "compton --config $HOME/.compton" +else + pkill compton +fi + +xset +fp /usr/share/fonts/local +xset fp rehash + #$HLWM_CONF_DIR/start.sh "$HLWM_CONF_DIR/notify.sh $HLWM_CONF_DIR/popup.sh" # vim: set ts=4 sw=4 tw=0 et : diff --git a/herbstluftwm/.config/herbstluftwm/hlwm-keybindings b/herbstluftwm/.config/herbstluftwm/hlwm-keybindings index 4a6a614..cc40515 100644 --- a/herbstluftwm/.config/herbstluftwm/hlwm-keybindings +++ b/herbstluftwm/.config/herbstluftwm/hlwm-keybindings @@ -7,7 +7,7 @@ hc keyunbind --all Mod=Mod4 # Use the super key as the main modifier hc keybind $Mod-Shift-q quit -hc keybind $Mod-Shift-r reload +hc keybind $Mod-Shift-r chain , spawn echo "!! HLWM reload config !!" , reload hc keybind $Mod-Shift-c close hc keybind $Mod-Return spawn xterm hc keybind $Mod-grave spawn dmenu_run $dmenu_opts diff --git a/herbstluftwm/.config/herbstluftwm/hlwm-theming b/herbstluftwm/.config/herbstluftwm/hlwm-theming index 0ffd366..aca737f 100644 --- a/herbstluftwm/.config/herbstluftwm/hlwm-theming +++ b/herbstluftwm/.config/herbstluftwm/hlwm-theming @@ -1,6 +1,29 @@ #!/usr/bin/env bash +# Add alpha channel to a hexadecimal color +add_alpha_channel(){ + echo "$1" | \ + sed "s/.*#\([0-9a-fA-F]*\).*/#ff\1/" +} + +#Include the theming script +source "$HLWM_CONF_DIR/themes/current" + +feh --bg-scale "$HLWM_WALLPAPER" + # Theme +xrdb -load $HOME/.Xresources + +for color in "${!colors[@]}"; do + echo "*$color: ${colors[$color]}" | xrdb -override +done + +echo "XTerm*background: $HLWM_BG_COLOR" | xrdb -override + +export HLWM_FG_ACOLOR=$(add_alpha_channel $HLWM_FG_COLOR) +export HLWM_ACCENT_ACOLOR=$(add_alpha_channel $HLWM_ACCENT_COLOR) +export HLWM_BG_ACOLOR=$(add_alpha_channel $HLWM_BG_COLOR) + hc attr theme.tiling.reset 1 hc attr theme.floating.reset 1 hc set frame_border_width 0 @@ -11,21 +34,24 @@ hc set frame_active_opacity 0 hc set frame_transparent_width 0 hc set frame_gap 0 -hc attr theme.active.color $color_accent -hc attr theme.normal.color $color_bg +hc attr theme.active.color $HLWM_ACCENT_COLOR +hc attr theme.normal.color $HLWM_BG_COLOR hc attr theme.urgent.color orange hc attr theme.inner_width 1 -hc attr theme.inner_color $color_bg +hc attr theme.inner_color $HLWM_BG_COLOR hc attr theme.border_width 3 hc attr theme.floating.border_width 4 hc attr theme.floating.outer_width 1 -hc attr theme.floating.outer_color $color_bg -hc attr theme.active.inner_color $color_bg -hc attr theme.active.outer_color $color_bg -hc attr theme.background_color $color_bg +hc attr theme.floating.outer_color $HLWM_BG_COLOR +hc attr theme.active.inner_color $HLWM_BG_COLOR +hc attr theme.active.outer_color $HLWM_BG_COLOR +hc attr theme.background_color $HLWM_BG_COLOR -hc set window_gap $window_p +hc set window_gap $HLWM_WINDOW_PADDING hc set frame_padding 0 hc set smart_window_surroundings 0 hc set smart_frame_surroundings 1 hc set mouse_recenter_gap 1 +hc set tree_style '╾│ ├└╼─┐' + +# vim: set ts=4 sw=4 tw=0 et : diff --git a/herbstluftwm/.config/herbstluftwm/panel_indicators.sh b/herbstluftwm/.config/herbstluftwm/panel_indicators.sh index a9e71da..487cda3 100755 --- a/herbstluftwm/.config/herbstluftwm/panel_indicators.sh +++ b/herbstluftwm/.config/herbstluftwm/panel_indicators.sh @@ -46,11 +46,11 @@ volume() if [ -z $vol ] ; then vol_status="off" elif [ $vol -eq 0 ]; then - vol_status="%{F$acolor_fg}${volume_icon[0]} $vol%%{F-}" + vol_status="%{F$HLWM_FG_ACOLOR}${volume_icon[0]} $vol%%{F-}" elif [ $vol -lt 33 ]; then - vol_status="%{F$acolor_fg}${volume_icon[1]} $vol%%{F-}" + vol_status="%{F$HLWM_FG_ACOLOR}${volume_icon[1]} $vol%%{F-}" else - vol_status="%{F$acolor_fg}${volume_icon[2]} $vol%%{F-}" + vol_status="%{F$HLWM_FG_ACOLOR}${volume_icon[2]} $vol%%{F-}" fi echo -e "volume\t$vol_status" else @@ -116,7 +116,7 @@ battery() if [ $bat_state == "Charging" ] ; then bat_status="${battery_icon[5]}" elif [ $bat_lvl -lt 10 ] ; then - bat_status="${F$acolor_accent}${battery_icon[0]}${F-}" + bat_status="${F$HLWM_ACCENT_ACOLOR}${battery_icon[0]}${F-}" elif [ $bat_ -lt 25 ] ; then bat_status="${battery_icon[1]}" elif [ $bat_ -lt 50 ] ; then @@ -134,7 +134,7 @@ battery() clock() { - echo -e $(date +$"date\t%{F$acolor_fg}%H:%M:%S %{F$acolor_fg}(%d-%m-%Y)%{F-}") + echo -e $(date +$"date\t%{F$HLWM_FG_ACOLOR}%H:%M:%S %{F$HLWM_FG_ACOLOR}(%d-%m-%Y)%{F-}") } # vim: set ts=4 sw=4 tw=0 et : diff --git a/herbstluftwm/.config/herbstluftwm/poligons.png b/herbstluftwm/.config/herbstluftwm/poligons.png deleted file mode 100644 index e5c7cda..0000000 Binary files a/herbstluftwm/.config/herbstluftwm/poligons.png and /dev/null differ diff --git a/herbstluftwm/.config/herbstluftwm/populate_panel.sh b/herbstluftwm/.config/herbstluftwm/populate_panel.sh index 7afa0c3..ddeb8c8 100755 --- a/herbstluftwm/.config/herbstluftwm/populate_panel.sh +++ b/herbstluftwm/.config/herbstluftwm/populate_panel.sh @@ -1,8 +1,6 @@ #!/usr/bin/env bash -source "$HLWM_CONF_DIR/themes/current" source "$HLWM_CONF_DIR/panel_indicators.sh" - monitor=$1 if awk -Wv 2>/dev/null | head -1 | grep -q '^mawk'; then @@ -50,26 +48,26 @@ fi net="" windowtitle="" - separator="%{F$acolor_accent}|%{F-}" + separator="%{F$HLWM_ACCENT_ACOLOR}|%{F-}" while true ; do for i in "${tags[@]}" ; do case ${i:0:1} in '#') - echo -n "%{U$acolor_accent+u}%{F$acolor_fg}" + echo -n "%{U$HLWM_ACCENT_ACOLOR+u}%{F$HLWM_FG_ACOLOR}" ;; '+') - echo -n "%{U$acolor_fg+u}%{F$acolor_fg}" + echo -n "%{U$HLWM_FG_ACOLOR+u}%{F$HLWM_FG_ACOLOR}" ;; ':') - echo -n "%{F$acolor_fg}" + echo -n "%{F$HLWM_FG_ACOLOR}" ;; '!') - echo -n "%{B$acolor_accent}%{U$acolor_accent+u}%{F$acolor_bg}" + echo -n "%{B$HLWM_ACCENT_ACOLOR}%{U$HLWM_ACCENT_ACOLOR+u}%{F$HLWM_BG_ACOLOR}" ;; *) - echo -n "%{F$acolor_fg}" + echo -n "%{F$HLWM_FG_ACOLOR}" ;; esac echo -n "%{A:tag,${i:1}:} ${i:1} %{A}%{F-}%{U-u}%{B-}" diff --git a/herbstluftwm/.config/herbstluftwm/popup.sh b/herbstluftwm/.config/herbstluftwm/popup.sh index eda37f5..b9980e2 100755 --- a/herbstluftwm/.config/herbstluftwm/popup.sh +++ b/herbstluftwm/.config/herbstluftwm/popup.sh @@ -29,7 +29,7 @@ if test ! $message; then help else - bar_opts="-f $font,$font_sec -B $acolor_bg -F $acolor_fg -g ${popup_width}x${height}+${popup_x}+${popup_y} -u 2" + bar_opts="-f $HLWM_PANEL_FONT,$font_sec -B $HLWM_BG_ACOLOR -F $HLWM_FG_ACOLOR -g ${popup_width}x${height}+${popup_x}+${popup_y} -u 2" t=$(date +%T) @@ -40,7 +40,7 @@ else fi { - echo "%{F$acolor_accent} $prefix %{F$acolor_fg}$message %{F$acolor_fg}($t)%{F-}" + echo "%{F$HLWM_ACCENT_ACOLOR} $prefix %{F$HLWM_FG_ACOLOR}$message %{F$HLWM_FG_ACOLOR}($t)%{F-}" sleep $timeout } | bar $bar_opts fi diff --git a/herbstluftwm/.config/herbstluftwm/start_panel.sh b/herbstluftwm/.config/herbstluftwm/start_panel.sh index 42e33fd..13ea6e2 100755 --- a/herbstluftwm/.config/herbstluftwm/start_panel.sh +++ b/herbstluftwm/.config/herbstluftwm/start_panel.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source "$HLWM_CONF_DIR/themes/current" + source "$HLWM_CONF_DIR/panel_indicators.sh" # Check for valid monitors @@ -19,16 +19,16 @@ for pid in $pids; do done # Geometry has the format W H X Y -x=$(echo "${geometry[0]} + $window_p" | bc) -y=$(echo "${geometry[1]} + $window_p" | bc) -panel_width=$(echo "${geometry[2]} - (2 * $window_p)" | bc) +x=$(echo "${geometry[0]} + $HLWM_WINDOW_PADDING" | bc) +y=$(echo "${geometry[1]} + $HLWM_WINDOW_PADDING" | bc) +panel_width=$(echo "${geometry[2]} - (2 * $HLWM_WINDOW_PADDING)" | bc) # Apply padding to make room for the panel -hc pad $monitor $(echo "$panel_h + $window_p" | bc) +hc pad $monitor $(echo "$HLWM_PANEL_HEIGHT + $HLWM_WINDOW_PADDING" | bc) # Start the panel $HLWM_CONF_DIR/populate_panel.sh $monitor | -lemonbar -g ${panel_width}x${panel_h}+${x}+${y} -f "$font" -f "$icon_font" -u2 -B$acolor_bg -F$acolor_fg | +lemonbar -g ${panel_width}x${HLWM_PANEL_HEIGHT}+${x}+${y} -f "$HLWM_PANEL_FONT" -f "$icon_font" -u2 -B$HLWM_BG_ACOLOR -F$HLWM_FG_ACOLOR | $HLWM_CONF_DIR/panel_handler.sh # vim: set ts=4 sw=4 tw=0 et : diff --git a/herbstluftwm/.config/herbstluftwm/themes/purpur b/herbstluftwm/.config/herbstluftwm/themes/purpur index 5fedc6d..88a5758 100644 --- a/herbstluftwm/.config/herbstluftwm/themes/purpur +++ b/herbstluftwm/.config/herbstluftwm/themes/purpur @@ -1,34 +1,30 @@ #!/usr/bin/env bash -# Get color from ~/.Xresources -get_x_color() { - xresources=$(cat ~/.Xresources) - color=$(echo $xresources | sed "s/.*\*color$1: \(\#[0-9A-Fa-f]*\).*/\1/") - echo $color -} - -# Add alpha channel to a hexadecimal color -add_alpha_channel(){ - echo "$1" | \ - sed "s/.*#\([0-9a-fA-F]*\).*/#ff\1/" -} +declare -A colors +colors=(["background"]="#2d2d2d" ["foreground"]="#f9f9f9" + ["color0"]="#2d2d2d" ["color8"]="#333333" + ["color1"]="#690a03" ["color9"]="#d64937" + ["color2"]="#13a43b" ["color10"]="#6dfb2d" + ["color3"]="#f5a711" ["color11"]="#ffdc00" + ["color4"]="#0f6cc9" ["color12"]="#32abd8" + ["color5"]="#93116b" ["color13"]="#c61f93" + ["color6"]="#3cb691" ["color14"]="#53b4bd" + ["color7"]="#d9d9d9" ["color15"]="#f9f9f9") # Wallpaper -wallpaper="$HOME/.config/herbstluftwm/poligons.png" +export HLWM_WALLPAPER="$HOME/.config/herbstluftwm/wallpapers/poligons.png" + +# Shadow +export HLWM_COMPOSITING=true # Padding -window_p=20 +export HLWM_WINDOW_PADDING=20 # Panel -panel_h=25 -font="DejaVu Sans Mono-10" +export HLWM_PANEL_HEIGHT=25 +export HLWM_PANEL_FONT="DejaVu Sans Mono-10" # Colors -color_fg=$(get_x_color 15) -color_accent=$(get_x_color 5) -color_bg=$(get_x_color 0) - -# Alpha Colors for use with bar -acolor_fg=$(add_alpha_channel $color_fg) -acolor_accent=$(add_alpha_channel $color_accent) -acolor_bg=$(add_alpha_channel $color_bg) +export HLWM_FG_COLOR=${colors["color15"]} +export HLWM_ACCENT_COLOR=${colors["color5"]} +export HLWM_BG_COLOR=${colors["color0"]} diff --git a/herbstluftwm/.config/herbstluftwm/wallpapers/poligons.png b/herbstluftwm/.config/herbstluftwm/wallpapers/poligons.png new file mode 100644 index 0000000..e5c7cda Binary files /dev/null and b/herbstluftwm/.config/herbstluftwm/wallpapers/poligons.png differ -- cgit v1.2.3