bklaase icon

hlwm autostart

bklaase | PRO | 11/25/16 03:51:40 PM UTC | 0 ⭐ | 600 👁️ | Never ⏰ | []
Bash |

8.79 KB

|

None

|

0 👍

/

0 👎

#!/usr/bin/env bash
 
#alias the client
hc() {
    herbstclient "$@"
}
 
hc emit_hook reload
 
#imediately hide default frame
hc set frame_border_width 0
hc set always_show_frame 0
hc set frame_bg_transparent 1
hc set frame_transparent_width 0
 
# global settings
herbstclient pad 0 27 2 27 2
hc set update_dragged_clients 1
hc set raise_on_focus 1
hc set focus_crosses_monitor_boundaries 0
hc set swap_monitors_to_get_tag 0
hc set default_frame_layout 1
 
#some constants
scriptdir=/home/$(whoami)/.config/herbstluftwm/scripts
 
# remove all existing keybindings
hc keyunbind --all
 
# keybindings
# if you have a super key you will be much happier with Mod set to Mod4
#Mod=Mod1    # Use alt as the main modifier
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-c close_and_remove
hc keybind $Mod-Return spawn ${TERMINAL:-xfce4-terminal} #
 
#create an overlay monitor called float
hc keybind $Mod-Shift-m spawn /home/$(whoami)/.config/herbstluftwm/scripts/floatingMonitor
hc keybind $Mod-Control-m remove_monitor float
 
# basic movement
# focusing clients
hc keybind $Mod-h     focus left
hc keybind $Mod-j     focus down
hc keybind $Mod-k     focus up
hc keybind $Mod-l     focus right
 
# note: moving in floating tag, moves to edge
#therefore, with manual center window, we can do all
# moving clients
hc keybind $Mod-m           spawn $scriptdir/wmutils/wu-move-center
 
hc keybind $Mod-Shift-h     shift left
hc keybind $Mod-Shift-j     shift down
hc keybind $Mod-Shift-k     shift up
hc keybind $Mod-Shift-l     shift right
 
# splitting frames
# create an empty frame at the specified direction
hc keybind $Mod-u       chain , split   bottom  0.5 , focus -e down
hc keybind $Mod-Shift-u chain , split   top     0.5 , focus -e up
hc keybind $Mod-o       chain , split   right   0.5 , focus -e right
hc keybind $Mod-Shift-o chain , split   left    0.5 , focus -e left
 
# let the current frame explode into subframes
hc keybind $Mod-Control-space chain . split explode 0.5 . cycle_layout +1 vertical horizontal . emit_hook framelayout_changed
 
 
# resizing frames and also in floating mode, resize to presets
resizestep=0.05
 
hc keybind $Mod-Control-h                               \
    or  , and   . compare tags.focus.floating = false   \
                . resize left +$resizestep              \
                , spawn $scriptdir/wmutils/wu-resize-custom 50 50
 
hc keybind $Mod-Control-j                               \
    or  , and   . compare tags.focus.floating = false   \
                . resize down +$resizestep              \
                , spawn $scriptdir/wmutils/wu-resize-custom 63 60
hc keybind $Mod-Control-k                               \
    or  , and   . compare tags.focus.floating = false   \
                . resize up +$resizestep                \
                , spawn $scriptdir/wmutils//wu-resize-custom 79 75
hc keybind $Mod-Control-l                               \
    or  , and   . compare tags.focus.floating = false   \
                . resize right +$resizestep             \
                , spawn $scriptdir/wmutils/wu-resize-custom 99 99
 
#other resize presets
hc keybind $Mod-Control-b spawn $scriptdir/wmutils/wu-resize-custom 95 92
hc keybind $Mod-Control-z spawn $scriptdir/wmutils/wu-resize-custom 50 95
hc keybind $Mod-Control-e spawn $scriptdir/wmutils/wu-resize-custom 65 85
hc keybind $Mod-Control-v spawn $scriptdir/wmutils/wu-resize-custom "1152" "648" "a"
 
#########
# tags  #
#########
tag_names=( {1..9} )
tag_keys=( {1..9} 0 )
 
hc rename default "${tag_names[0]}" || true
for i in ${!tag_names[@]} ; do
    hc add "${tag_names[$i]}"
    hc floating "${tag_names[$i]}" on
    key="${tag_keys[$i]}"
    if ! [ -z "$key" ] ; then
        hc keybind "$Mod-$key" use_index "$i"   # go there without window
        hc keybind "$Mod-Shift-$key" move_index "$i" # send window there without following
        hc keybind "$Mod-Control-$key" chain , move_index "$i" , use_index "$i" # send window there and follow
    fi
done
 
# cycle through tags
hc keybind $Mod-period use_index +1 --skip-visible
hc keybind $Mod-comma  use_index -1 --skip-visible
 
 
# navigate through tags represented as a WxH grid
tagCols=3
tagRows=3
 
hc keybind Control-Alt-Left spawn $scriptdir/navigateTagGrid left $tagCols $tagRows
hc keybind Control-Alt-Right spawn $scriptdir/navigateTagGrid right $tagCols $tagRows
hc keybind Control-Alt-Down spawn $scriptdir/navigateTagGrid down $tagCols $tagRows
hc keybind Control-Alt-Up spawn $scriptdir/navigateTagGrid up $tagCols $tagRows
 
hc keybind Control-Alt-h spawn $scriptdir/navigateTagGrid left $tagCols $tagRows
hc keybind Control-Alt-l spawn $scriptdir/navigateTagGrid right $tagCols $tagRows
hc keybind Control-Alt-j spawn $scriptdir/navigateTagGrid down $tagCols $tagRows
hc keybind Control-Alt-k spawn $scriptdir/navigateTagGrid up $tagCols $tagRows
 
#############
# layouting #
#############
hc keybind $Mod-r remove
hc keybind $Mod-s chain , floating toggle , emit_hook floating_toggle
hc keybind $Mod-Shift-f fullscreen toggle
hc keybind $Mod-p pseudotile toggle
# The following cycles through the available layouts within a frame, but skips
# layouts, if the layout change wouldn't affect the actual window positions.
# I.e. if there are two windows within a frame, the grid layout is skipped.
 
#hc keybind $Mod-space                                                           \
#            or , and . compare tags.focus.curframe_wcount = 2                   \
#                     . cycle_layout +1 vertical horizontal max vertical grid    \
#               , cycle_layout +1
hc keybind $Mod-space chain . cycle_layout +1 vertical horizontal \
                            . emit_hook framelayout_changed
hc keybind $Mod-g chain . set_layout grid . emit_hook framelayout_changed
hc keybind $Mod-f chain . set_layout max . emit_hook framelayout_changed
 
#########
# mouse #
#########
hc mouseunbind --all
hc mousebind $Mod-Button1 move
hc mousebind $Mod-Button2 zoom
hc mousebind $Mod-Control-Button1 resize
 
#########
# focus #
#########
hc keybind $Mod-BackSpace   cycle_monitor
hc keybind $Mod-Tab         cycle_all --skip-invisible +1
hc keybind $Mod-Shift-Tab   cycle_all --skip-invisible -1
hc keybind $Mod-bracketright cycle +1
hc keybind $Mod-bracketleft cycle -1
hc keybind $Mod-grave use_previous
hc keybind $Mod-i jumpto urgent
 
#########
# theme #
#########
hc attr theme.tiling.reset 1
hc attr theme.floating.reset 1
hc set frame_border_active_color '#6833ff'
hc set frame_border_normal_color '#000000'
hc set frame_bg_normal_color '#565656'
hc set frame_bg_active_color '#345F0C'
hc set frame_border_width 0
 
 
hc set frame_gap 0
hc set snap_gap 0 #gap on monitor border stuff snaps to
 
hc attr theme.active.color '#6833ff'
#hc attr theme.floating.active.color '#6833ff'
hc attr theme.normal.color '#3d2582'
hc attr theme.urgent.color '#6833ff'
hc attr theme.inner_width 1
hc attr theme.outer_width 1
hc attr theme.inner_color black
hc attr theme.outer_color black
hc attr theme.border_width 4
 
#hc attr theme.floating.border_width 4
#hc attr theme.floating.outer_width 1
#hc attr theme.floating.inner_width 1
#hc attr theme.floating.outer_color black
 
hc attr theme.active.inner_color black
hc attr theme.active.outer_color black
hc attr theme.background_color '#141414'
 
hc set window_gap 2
hc set frame_padding 0
hc set smart_window_surroundings 0
hc set smart_frame_surroundings 1
hc set mouse_recenter_gap 0
 
 
 
#########
# rules #
#########
hc unrule -F
#hc rule class=XTerm tag=3 # move all xterms to tag 3
hc rule focus=on # normally focus new clients
#hc rule focus=off # normally do not focus new clients
# give focus to most common terminals
#hc rule class~'(.*[Rr]xvt.*|.*[Tt]erm|Konsole)' focus=on
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' pseudotile=on
hc rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off
 
#custom rules
hc rule instance='gmrun' pseudotile=on
hc rule instance='workrave' pseudotile=on focus=off tag=9
hc rule not windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' hook='window_created'
 
 
 
####################################
# finally some tricks and autoload #
####################################
 
# unlock, just to be sure
hc unlock
herbstclient set tree_style '╾│ ├└╼─┐'
 
 
# find the panel
#panel=~/.config/herbstluftwm/panel.sh
#[ -x "$panel" ] || panel=/etc/xdg/herbstluftwm/panel.sh
#for monitor in $(herbstclient list_monitors | cut -d: -f1) ; do
#start it on each monitor
#"$panel" $monitor &
#done
 
## autostart progs
if hc silent new_attr bool my_not_first_autostart ; then
    compton --config /home/$(whoami)/dotfiles/compton/compton-$(hostname).cfg &
    (autostart-progs && sleep 1 && /home/$(whoami)/.fehbg && sleep 2 && hc detect_monitors) &
    (sleep 8 && /home/$(whoami)/.config/herbstluftwm/scripts/panelLemonbar.sh) &
 
    #start listening to hooks:
    herbstclient -i | /home/$(whoami)/.config/herbstluftwm/scripts/hookListener &
fi
 
# do multi monitor setup here, e.g.:
# hc set_monitors 1280x1024+0+0 1280x1024+1280+0
# or simply:
hc detect_monitors

Comments