From ba4a9bca449de7e0f9ad0b1d2ebc104a45036638 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Wed, 12 Nov 2014 23:09:37 +0100 Subject: Put theme vars in a separate file --- herbstluftwm/.config/herbstluftwm/autostart | 63 ++++++++----------------- herbstluftwm/.config/herbstluftwm/panel.sh | 72 +++++++++++------------------ herbstluftwm/.config/herbstluftwm/theme | 35 ++++++++++++++ 3 files changed, 82 insertions(+), 88 deletions(-) create mode 100644 herbstluftwm/.config/herbstluftwm/theme (limited to 'herbstluftwm') diff --git a/herbstluftwm/.config/herbstluftwm/autostart b/herbstluftwm/.config/herbstluftwm/autostart index 1cce1ba..9ec12f8 100755 --- a/herbstluftwm/.config/herbstluftwm/autostart +++ b/herbstluftwm/.config/herbstluftwm/autostart @@ -6,36 +6,17 @@ hc() { herbstclient "$@" } -get_x_color() { - xresources=$(cat ~/.Xresources) - color=$(echo $xresources | sed "s/.*\*color$1: \(#[0-9A-Fa-f]*\).*/\1/") - echo $color -} - -hlwm_scripts="$HOME/.config/herbstluftwm" - -#wallpaper -wallpaper="/home/tom/Pictures/fall1.jpg" - -#Numix color palette -export WM_LIGHT=$(get_x_color 15) -export WM_LLIGHT=$(get_x_color 7) -export WM_ACCENT=$(get_x_color 9) -export WM_LDARK=$(get_x_color 8) -export WM_DARK=$(get_x_color 0) +dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +source "$dir/theme" #Detect monitors hc set auto_detect_monitors 1 hc detect_monitors #Panel and window_p -window_p=20 monitor_w=($(hc list_monitors | sed 's/^[0-9]: \([0-9]*\)x.*$/\1/')) -panel_h=24 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 $WM_DARK -nf $WM_LIGHT -sb $WM_ACCENT -sf $WM_DARK" - -hc emir_hook reload +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" # remove all existing keybindings hc keyunbind --all @@ -135,10 +116,6 @@ hc set focus_follows_mouse 1 # theme hc attr theme.tiling.reset 1 hc attr theme.floating.reset 1 -hc set frame_border_active_color $WM_LDARK -hc set frame_border_normal_color $WM_DARK -hc set frame_bg_normal_color $WM_LDARK -hc set frame_bg_active_color $WM_DARK hc set frame_border_width 0 hc set always_show_frame 0 hc set frame_bg_transparent 1 @@ -147,18 +124,18 @@ hc set frame_active_opacity 0 hc set frame_transparent_width 0 hc set frame_gap 0 -hc attr theme.active.color $WM_ACCENT -hc attr theme.normal.color $WM_DARK +hc attr theme.active.color $color_accent +hc attr theme.normal.color $color_bg hc attr theme.urgent.color orange hc attr theme.inner_width 1 -hc attr theme.inner_color $WM_DARK +hc attr theme.inner_color $color_bg 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 $WM_DARK -hc attr theme.active.inner_color $WM_DARK -hc attr theme.active.outer_color $WM_DARK -hc attr theme.background_color $WM_DARK +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 set window_gap $window_p hc set frame_padding 0 @@ -185,12 +162,12 @@ herbstclient set tree_style '╾│ ├└╼─┐' #Start panel in all monitors start_panel() { for monitor in $(herbstclient list_monitors | cut -d: -f1) ; do - "$1" $monitor $panel_h $window_p & + "$1" $monitor& done } # find the panel -panel=$hlwm_scripts/panel.sh +panel=$dir/panel.sh [ -x "$panel" ] || panel=/etc/xdg/herbstluftwm/panel.sh if pgrep panel.sh >> /dev/null then @@ -202,11 +179,11 @@ fi pulseaudio --start -$hlwm_scripts/start.sh "xautolock -time 5 -locker $hlwm_scripts/lock.sh" -$hlwm_scripts/start.sh "feh --bg-fill $wallpaper" -$hlwm_scripts/start.sh "compton --config $HOME/.compton" -$hlwm_scripts/start.sh "xrdb -load $HOME/.Xresources" -$hlwm_scripts/start.sh "xset +fp /usr/share/fonts/local" -$hlwm_scripts/start.sh "xset fp rehash" -$hlwm_scripts/start.sh "dropboxd" -$hlwm_scripts/start.sh "$hlwm_scripts/notify.sh $monitor_w $window_p $panel_h $hlwm_scripts/popup.sh" +$dir/start.sh "xautolock -time 5 -locker $dir/lock.sh" +$dir/start.sh "feh --bg-fill $wallpaper" +$dir/start.sh "compton --config $HOME/.compton" +$dir/start.sh "xrdb -load $HOME/.Xresources" +$dir/start.sh "xset +fp /usr/share/fonts/local" +$dir/start.sh "xset fp rehash" +$dir/start.sh "dropboxd" +#$dir/start.sh "$dir/notify.sh $monitor_w $window_p $panel_h $dir/popup.sh" diff --git a/herbstluftwm/.config/herbstluftwm/panel.sh b/herbstluftwm/.config/herbstluftwm/panel.sh index 3af00c5..9b8fb48 100755 --- a/herbstluftwm/.config/herbstluftwm/panel.sh +++ b/herbstluftwm/.config/herbstluftwm/panel.sh @@ -4,28 +4,10 @@ hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ; } -add_alpha_channel(){ - echo "$1" | \ - sed "s/.*#\([0-9a-fA-F]*\).*/#ff\1/" -} +dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +source "$dir/theme" monitor=${1:-0} -panel_height=$2 -padding=$3 - -light=$(add_alpha_channel $WM_LIGHT) -llight=$(add_alpha_channel $WM_LLIGHT) -accent=$(add_alpha_channel $WM_ACCENT) -ldark=$(add_alpha_channel $WM_LDARK) -dark=$(add_alpha_channel $WM_DARK) - -font="-*-fixed-medium-*-*-*-14-*-*-*-*-*-*-*" -font2="-*-stlarch-medium-*-*-*-10-*-*-*-*-*-*-*" -selected_bg=$accent -normal_bg=$dark -selected_txt=$dark -normal_txt=$light -inactive_txt=$llight geometry=( $(herbstclient monitor_rect "$monitor") ) if [ -z "$geometry" ] ;then @@ -33,12 +15,12 @@ if [ -z "$geometry" ] ;then exit 1 fi # geometry has the format W H X Y -x=$(echo "${geometry[0]} + $padding" | bc) -y=$(echo "${geometry[1]} + $padding" | bc) -panel_width=$(echo "${geometry[2]} - (2 * $padding)" | bc) -bar_opts="-g ${panel_width}x${panel_height}+${x}+${y} -f $font,$font2 -u 2 -B $normal_bg -F $normal_txt" +x=$(echo "${geometry[0]} + $window_p" | bc) +y=$(echo "${geometry[1]} + $window_p" | bc) +panel_width=$(echo "${geometry[2]} - (2 * $window_p)" | bc) +bar_opts="-g ${panel_width}x${panel_h}+${x}+${y} -f $font,$font_sec -u 2 -B $acolor_bg -F $acolor_fg" -hc pad $monitor $(echo "$panel_height + $padding" | bc) +hc pad $monitor $(echo "$panel_h + $window_p" | bc) if awk -Wv 2>/dev/null | head -1 | grep -q '^mawk'; then # mawk needs "-W interactive" to line-buffer stdout correctly @@ -77,9 +59,9 @@ fi scrolling=$current fi - echo -e "music\t\ue05c ${scrolling:0:24}" + echo -e "music\t\ue05c ${scrolling:0:24}" else - echo -e "music\toff" + echo -e "music\toff" fi # Volume @@ -95,9 +77,9 @@ fi if [ -z $vol ] ; then echo -e "volume\toff" else - echo -e "volume\t%{F$normal_txt}\ue05d $vol%%%{F-}" + echo -e "volume\t%{F$acolor_fg}\ue05d $vol%%%{F-}" fi - else + else echo -e "volume\toff" fi @@ -106,12 +88,12 @@ fi if iwconfig $int1 >/dev/null 2>&1; then wifi=$int1 eth=$int2 - else + else wifi=$int2 eth=$int1 fi - - ip link show $eth | grep 'state UP' >/dev/null && int=$eth || int=$wifi + + ip link show $eth | grep 'state UP' >/dev/null && int=$eth || int=$wifi if [ $int == "wlp3s0" ] ; then iwconfig=$(iwconfig $int) @@ -124,12 +106,12 @@ fi if [ $ssid != "off/any" ] ; then echo -e "net\t\ue0f3 $ssid" - else + else echo -e "net\toff" fi elif [ $int == "enp2s0" ] ; then - echo -e "net\t\ue0af ethernet" + echo -e "net\t\ue0af ethernet" else echo -e "net\toff" fi @@ -138,18 +120,18 @@ fi if $(test -e /sys/class/power_supply/BAT1) ; then bat_lvl=$(cat /sys/class/power_supply/BAT1/capacity) if [ $bat_lvl -lt 15 ] ; then - bat_color=$accent + bat_color=$acolor_accent else - bat_color=$normal_txt + bat_color=$acolor_fg fi state=$(cat /sys/class/power_supply/BAT1/status) - echo -e "battery\t%{F$normal_txt}\ue03b %{F$bat_color}$bat_lvl%{F$normal_txt}%%%{F-}" + echo -e "battery\t%{F$acolor_fg}\ue03b %{F$bat_color}$bat_lvl%{F$acolor_fg}%%%{F-}" else echo -e "battery\toff" fi # Time - echo -e $(date +$"date\t%{F$normal_txt}%H:%M:%S %{F$inactive_txt}(%d-%m-%Y)%{F-}") + echo -e $(date +$"date\t%{F$acolor_fg}%H:%M:%S %{F$acolor_fg}(%d-%m-%Y)%{F-}") sleep 1 || break done > >(uniq_linebuffered) & childpid=$! @@ -165,24 +147,24 @@ fi net="" windowtitle="" while true ; do - separator="%{F$accent}|%{F-}" + separator="%{F$acolor_accent}|%{F-}" # draw tags for i in "${tags[@]}" ; do case ${i:0:1} in '#') - echo -n "%{U$accent+u}%{F$normal_txt}" + echo -n "%{U$acolor_accent+u}%{F$acolor_fg}" ;; '+') - echo -n "%{U$normal_txt+u}%{F$normal_txt}" + echo -n "%{U$acolor_fg+u}%{F$acolor_fg}" ;; ':') - echo -n "%{F$normal_txt}" + echo -n "%{F$acolor_fg}" ;; '!') - echo -n "%{B$accent}%{U$accent+u}%{F$normal_bg}" + echo -n "%{B$acolor_accent}%{U$acolor_accent+u}%{F$acolor_bg}" ;; *) - echo -n "%{F$inactive_txt}" + echo -n "%{F$acolor_fg}" ;; esac echo -n "%{A:tag,${i:1}:} ${i:1} %{A}%{F-}%{U-u}%{B-}" @@ -196,7 +178,7 @@ fi #DO NOT REMOVE THIS ECHO echo - + # wait for next event IFS=$'\t' read -ra cmd || break case "${cmd[0]}" in diff --git a/herbstluftwm/.config/herbstluftwm/theme b/herbstluftwm/.config/herbstluftwm/theme new file mode 100644 index 0000000..810c5d2 --- /dev/null +++ b/herbstluftwm/.config/herbstluftwm/theme @@ -0,0 +1,35 @@ +#!/bin/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/" +} + +# Wallpaper +wallpaper="/home/tom/Pictures/fall1.jpg" + +# Padding +window_p=20 + +# Panel +panel_h=24 +font="-*-fixed-medium-*-*-*-14-*-*-*-*-*-*-*" +font_sec="-*-stlarch-medium-*-*-*-10-*-*-*-*-*-*-*" + +# Colors +color_fg=$(get_x_color 15) +color_accent=$(get_x_color 9) +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) -- cgit v1.2.3