Instantly share code, notes, and snippets.

Embed
What would you like to do?
herbstluftwm, PowerShell config
#! /usr/bin/env pwsh-preview
herbstclient emit_hook reload
herbstclient keyunbind --all
herbstclient mouseunbind --all
$Mod = 'Mod1'
$terminal = 'uxterm'
$resizestep = 0.05
$wallpaper = '~/Pictures/background.png'
$resources = '~/.Xresources'
function write-ok {
Write-Host -ForegroundColor Green ' [OK]'
}
function Set-HerbstKeybind($keybind, $action) {
& herbstclient keybind $keybind ($action -split '\s+')
}
function Set-HerbstMousebind($mousebind, $action) {
& herbstclient mousebind $mousebind ($action -split '\s+')
}
$keyBindings = @{
"$Mod-Control-q" = 'quit';
"$Mod-Control-r" = 'reload';
"$Mod-Control-c" = 'close';
"$Mod-Return" = "spawn $terminal";
# basic movement
# focusing clients
"$Mod-Left" = 'focus left';
"$Mod-Down" = 'focus down';
"$Mod-Up" = 'focus up';
"$Mod-Right" = 'focus right';
# moving clients
"Control-Left" = 'shift left';
"Control-Down" = 'shift down';
"Control-Up" = 'shift up';
"Control-Right" = 'shift right';
# resizing frames
"$Mod-Control-Left" = "resize left +$resizestep";
"$Mod-Control-Down" = "resize down +$resizestep";
"$Mod-Control-Up" = "resize up +$resizestep";
"$Mod-Control-Right" = "resize right +$resizestep";
# splitting frames
"$Mod-u" = 'split bottom 0.5';
"$Mod-o" = 'split right 0.5';
"$Mod-Control-space" = 'split explode 0.5';
# layouting
"$Mod-r" = 'remove';
"$Mod-s" = 'floating toggle';
"$Mod-f" = 'fullscreen toggle';
"$Mod-p" = 'pseudotile toggle';
# focus
"$Mod-BackSpace" = 'cycle_monitor';
"$Mod-Control-Tab" = 'cycle_all +1';
"$Mod-Shift-Tab" = 'cycle_all +1';
"$Mod-c" = 'cycle';
"$Mod-i" = 'jumpto urgent';
}
$mouseBindings = @{
"$Mod-Button1" = 'move';
"$Mod-Button2" = 'zoom';
"$Mod-Button3" = 'resize';
}
write-host -NoNewline 'setting up key- and mousebindings'
($keyBindings).GetEnumerator() |% { Set-HerbstKeybind $_.Key $_.Value }
($mouseBindings).GetEnumerator() |% { Set-HerbstMousebind $_.Key $_.Value }
write-ok
# tags
$defaultTagName = "etc"
$tags = @{
"dev" = "1";
"web" = "2";
}
write-host -NoNewline 'setting up tags'
herbstclient rename default $defaultTagName
($tags).GetEnumerator() |% {
herbstclient add $_.Key
Set-HerbstKeybind "$Mod-$($_.Value)" "use $($_.Key)"
}
Set-HerbstKeybind "$Mod-0" "use $defaultTagName"
write-ok
$theme = @{
'frame_border_active_color' = '#222222';
'frame_border_normal_color' = '#101010';
'frame_bg_normal_color' = '#565656';
'frame_bg_active_color' = '#345F0C';
'frame_border_width' = 1;
'always_show_frame' = 1;
'frame_bg_transparent' = 1;
'frame_transparent_width' = 5;
'frame_gap' = 4;
'window_gap' = 0;
'frame_padding' = 0;
'smart_window_surroundings' = 0;
'smart_frame_surroundings' = 0;
'mouse_recenter_gap' = 0;
}
write-host -NoNewline 'setting up theme'
herbstclient attr theme.tiling.reset 1
herbstclient attr theme.floating.reset 1
($theme).GetEnumerator() |% { herbstclient set $_.Key $_.Value }
write-ok
write-host -NoNewline 'setting up wallpaper'
feh --bg-scale $wallpaper
write-ok
write-host -NoNewline 'call xrdb -merge'
xrdb -merge $resources
write-ok
$attrs = @{
'theme.active.color' = '#9FBC00';
'theme.normal.color' = '#454545';
'theme.urgent.color' = 'orange';
'theme.inner_width' = 1;
'theme.inner_color' = 'black';
'theme.border_width' = 3;
'theme.floating.border_width' = 4;
'theme.floating.outer_width' = 1;
'theme.floating.outer_color' = 'black';
'theme.active.inner_color' = '#3E4A00';
'theme.background_color' = '#141414';
}
write-host -NoNewline 'setting up some attrs'
($attrs).GetEnumerator() |% { herbstclient attr $_.Key $_.Value }
write-ok
$rules = @(
'focus=on';
"windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' pseudotile=on";
"windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on";
"windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off";
)
write-host -NoNewline 'setting up rules'
herbstclient unrule -F
$rules |% { herbstclient rule ($_ -split '\s+') }
write-ok
write-host -NoNewline 'unlock herbstluftwm'
herbstclient unlock
write-ok
write-host ''
write-host -foreground Blue "herbstluftwm is ready"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment