This repository has been archived on 2024-09-01. You can view files and clone it, but cannot push or open issues or pull requests.
al-skel/dk-home/.config/dk/dkrc
2021-12-24 17:17:12 -08:00

160 lines
4.7 KiB
Bash
Executable File

#!/bin/sh
# example dkrc to show some basic command usage and error reporting
# determine where to place the log file
logfile="$HOME/.dkrc.log"
[ -d "$HOME/.local/share/xorg" ] && logfile="$HOME/.local/share/xorg/dkrc.log"
: > "$logfile"
# (re)load sxhkd for keybinds
if hash sxhkd >/dev/null 2>&1; then
pkill sxhkd
sxhkd -c "$HOME/.config/dk/sxhkdrc" &
fi
# (re)load sxhkd for keybinds
if hash lemonbar bar >/dev/null 2>&1; then
pkill lemonbar
bar &
fi
{ # compound command to redirect all output
# workspace settings
# ------------------------
# initialize 10 workspaces (1-10) (default: 1/monitor)
dkcmd set numws=10
# default workspace '_' values used when allocating new workspaces
# can be applied to all existing workspaces when passed 'apply' after ws=_
dkcmd set ws=_ apply layout=tile master=1 stack=3 gap=0 msplit=0.5 ssplit=0.5
# use grid layout, padding, and gaps on workspace 10
dkcmd set ws=10 layout=grid pad left=200 right=200 top=100 bottom=100 gap width=50
# change workspace names (default: number == name)
# dkcmd set \
# ws=1 name="edit" \
# ws=2 name="web" \
# ws=3 name="😀" \
# ws=4 name="😠" \
# ws=5 name="5" \
# ws=6 name="6" \
# ws=7 name="7" \
# ws=8 name="8" \
# ws=9 name="9" \
# ws=10 name="10"
# enable static workspaces and assign them to monitors (only relevant for multiple monitors)
# aside -
# many that come from other workspace models tried dk and requested this feature
# try embracing the default behaviour and allow access to any workspace from any monitor
# you might end up liking it :)
#
# mon1='DisplayPort-0'
# mon2='HDMI-A-0'
# dkcmd set static_ws=true \
# ws=1 mon=$mon1 \
# ws=2 mon=$mon1 \
# ws=3 mon=$mon1 \
# ws=4 mon=$mon1 \
# ws=5 mon=$mon1 \
# ws=6 mon=$mon2 \
# ws=7 mon=$mon2 \
# ws=8 mon=$mon2 \
# ws=9 mon=$mon2 \
# ws=10 mon=$mon2
# global settings
# ---------------------
# focus windows when receiving activation and enable focus-follows-mouse
dkcmd set focus_open=true focus_urgent=true focus_mouse=true
# place clients at the tail and ignore size hints on tiled windows
dkcmd set tile_tohead=0 tile_hints=false
# minimum width/height for resizing, and minimum allowed on-screen when moving
dkcmd set win_minwh=50 win_minxy=10
# disable gaps and borders in single window layouts
dkcmd set smart_gap=true smart_border=true
# define mouse mod and move/resize buttons
dkcmd set mouse mod=alt move=button1 resize=button3
# borders
# ---------
# traditional
# set border width and colour for each window state
# dkcmd set border width=1 colour focus='#6699cc' unfocus='#000000' urgent='#ee5555'
# alternative
# enable split borders and colours, width is overall width, outer width consumes some of width.
# outer width must be less than width, outer width of 0 will be single borders
dkcmd set border width=5 outer_width=3 \
colour \
focus='#6699cc' \
unfocus='#444444' \
urgent='#ee5555' \
outer_focus='#222222' \
outer_unfocus='#222222' \
outer_urgent='#222222'
# window rules
# --------------
# rule class, instance, and title regexes (*ALWAYS* CASE INSENSITIVE)
# open window(s) on a specific workspace (assigned monitor)
dkcmd rule class="^gimp$" ws=2
# open window(s) on a monitor by number or name (active workspace on monitor)
dkcmd rule class="^chromium$" mon="HDMI-A-0"
# open window(s) and use a callback function (user defined in config.h)
# we also ignore=true to stop the window from being resized on it's own from events
# eg. mpv --x11-name=albumart /path/to/media
dkcmd rule class="^mpv$" instance="^albumart$" float=true ignore=true callback=albumart bw=0
# open window(s) in a floating state
dkcmd rule class="^(pavucontrol|transmission-gtk|steam|lxappearance)$" float=true
# open window(s) with a specific geometry and coordinates (floating only!)
dkcmd rule class="^google-chrome$" title="^open files$" float=true w=1280 h=720
# open window(s) with sticky and floating enabled to view on all workspaces.
dkcmd rule class="^stickyterm$" stick=true float=true w=1280 h=720
dkcmd rule class="^scratchpad$" float=true
# focus window and workspace on opening
dkcmd rule class="^firefox$" ws=1 focus=true
# update or remove an existing rule with the same match patterns
dkcmd rule class="^firefox$" mon="HDMI-A-0"
dkcmd rule remove class="^firefox$"
# apply current rule set to all existing windows
dkcmd rule apply '*'
# delete all rules
# dkcmd rule remove '*'
} >> "$logfile" 2>&1 # append responses
# inform of any errors in a notification
if grep -q 'error:' "$logfile"; then
hash notify-send && notify-send -t 0 -u critical "dkrc has errors" \
"$(awk '/error:/ {sub(/^error: /, ""); gsub(/</, "\<"); print}' "$logfile")"
exit 1
fi
exit 0