From 83c3c752c0a538e53b80fb6eee6ce829538345c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pankowski?= Date: Mon, 1 Sep 2025 21:56:44 +0200 Subject: [PATCH] add dk and polybar --- dk/.config/dk/dkrc | 179 +++++++++++++++++++++++++++ dk/.config/dk/sxhkdrc | 110 +++++++++++++++++ polybar/.config/polybar/config.ini | 187 +++++++++++++++++++++++++++++ xsession/.xsession | 16 ++- 4 files changed, 488 insertions(+), 4 deletions(-) create mode 100755 dk/.config/dk/dkrc create mode 100644 dk/.config/dk/sxhkdrc create mode 100644 polybar/.config/polybar/config.ini diff --git a/dk/.config/dk/dkrc b/dk/.config/dk/dkrc new file mode 100755 index 0000000..a3457a6 --- /dev/null +++ b/dk/.config/dk/dkrc @@ -0,0 +1,179 @@ +#!/bin/sh + +# example dkrc to provide a close-to-default setup and +# show some basic command usage with 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" + +# load sxhkd for keybinds +pgrep sxhkd || sxhkd -c "$HOME/.config/dk/sxhkdrc" & + +# spawn a scratchpad terminal if not already (see sxhkdrc and rules for binds/setup) +# pgrep -f "st -c scratchpad" || st -c scratchpad & + +# adjust border widths based on the DPI of the monitor +px=$(xrandr | grep ' connected' | tail -n1 | grep -o '[0-9]\+x[0-9]\+' | cut -d'x' -f2) +mm=$(xrandr | grep ' connected' | tail -n1 | grep -o '[0-9]\+mm' | tail -n1 | sed 's/mm//') +dpi=$(( (px / mm) * 25 )) + +if [ $dpi -ge 140 ]; then + border_width=5 + border_outer_width=3 +elif [ $dpi -ge 120 ]; then + border_width=4 + border_outer_width=2 +else + border_width=2 + border_outer_width=1 +fi + +{ # compound command to redirect all output + + # workspace settings + # ------------------------ + + # initialize 6 workspaces (1-6) (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 last workspace + #dkcmd set ws=6 layout=grid pad left=200 right=200 top=100 bottom=100 gap=50 + + # change workspace names (default: number == name -> 1:1, 2:2, 3:3....) + # dkcmd set \ + # ws=1 name="edit" \ + # ws=2 name="web" \ + # ws=3 name="😀" \ + # ws=4 name="😠" \ + # ws=5 name="5" \ + # ws=6 name="6" \ + + # enable static workspaces assigned to monitors (relevant for multiple monitors) + #echo $(polybar -m | sed 's/+/:/g' | awk -F: '{print $3, $1}' | sort -n | cut -d' ' -f2) | read mon1 mon2 mon3 + monitors=$(polybar -m | sed 's/+/:/g' | awk -F: '{print $3, $1}' | sort -n | cut -d' ' -f2) + mon1=$(echo $monitors | cut -d' ' -f1) + mon2=$(echo $monitors | cut -d' ' -f2) + mon3=$(echo $monitors | cut -d' ' -f3) + if [ -z "$mon2" ]; then + mon2="$mon1" + mon3="$mon1" + elif [ -z "$mon3" ]; then + mon3="$mon1" + fi + dkcmd set static_ws=true \ + ws=1 mon=$mon2 \ + ws=2 mon=$mon2 \ + ws=3 mon=$mon2 \ + ws=4 mon=$mon2 \ + ws=5 mon=$mon2 \ + ws=6 mon=$mon2 \ + ws=7 mon=$mon2 \ + ws=8 mon=$mon2 \ + ws=9 mon=$mon1 \ + ws=10 mon=$mon3 + + # 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=mod4 move=button1 resize=button3 + + # obey motif border hints on windows that draw their own (steam, easyeffects, etc.) + dkcmd set obey_motif=true + + + # borders + # --------- + + # traditional + # set border width and colour for each window state + # dkcmd set border width=$border_width 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=$border_width outer_width=$border_outer_width \ + colour \ + focus='#6699cc' \ + unfocus='#444444' \ + urgent='#ee5555' \ + outer_focus='#222222' \ + outer_unfocus='#222222' \ + outer_urgent='#222222' + + + # window rules + # -------------- + + # rule class, instance, and title regex are *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_cfg=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_cfg=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 ignore_msg=true to avoid focus being grabbed and changing workspace + # dkcmd rule class="^TelegramDesktop$" ignore_msg=true + + # define some terminals and allow them to be absorbed by spawned windows + dkcmd rule class="^(st|st-256color|urxvt|kitty|alacritty|xterm|xterm-256color)$" terminal=true + + # set a window to never absorb other windows, like the xev event tester + dkcmd rule title="^Event Tester$" no_absorb=true + + # send a window to the scratchpad + dkcmd rule class="^scratchpad$" scratch=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 (used mainly for WM restart) + 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(/ + +label-volume = %percentage%% + +label-muted = muted +label-muted-foreground = ${colors.disabled} + +[module/xkeyboard] +type = internal/xkeyboard +blacklist-0 = num lock + +label-layout = %layout% +label-layout-foreground = ${colors.primary} + +label-indicator-padding = 2 +label-indicator-margin = 1 +label-indicator-foreground = ${colors.background} +label-indicator-background = ${colors.secondary} + +[module/memory] +type = internal/memory +interval = 2 +format-prefix = "RAM " +format-prefix-foreground = ${colors.primary} +label = %percentage_used:2%% + +[module/cpu] +type = internal/cpu +interval = 2 +format-prefix = "CPU " +format-prefix-foreground = ${colors.primary} +label = %percentage:2%% + +[network-base] +type = internal/network +interval = 5 +format-connected = +format-disconnected = +label-disconnected = %{F#F0C674}%ifname%%{F#707880} disconnected + +[module/wlan] +inherit = network-base +interface-type = wireless +label-connected = %{F#F0C674}%ifname%%{F-} %essid% %local_ip% + +[module/eth] +inherit = network-base +interface-type = wired +label-connected = %{F#F0C674}%ifname%%{F-} %local_ip% + +[module/date] +type = internal/date +interval = 1 + +date = %H:%M +date-alt = %Y-%m-%d %H:%M:%S + +label = %date% +label-foreground = ${colors.primary} + +[settings] +screenchange-reload = true +pseudo-transparency = true + +; vim:ft=dosini diff --git a/xsession/.xsession b/xsession/.xsession index f467e53..b71e222 100755 --- a/xsession/.xsession +++ b/xsession/.xsession @@ -6,8 +6,8 @@ fi xset b off xrandr --auto -xrandr --output HDMI1 --right-of DP1 -xrandr --output DP-0 --left-of DP-2 +xrandr --output DP-0 --left-of DP-2 --primary +xrandr --output HDMI-0 --left-of DP-0 xrdb -merge ~/.Xresources setxkbmap pl -option ctrl:nocaps @@ -30,8 +30,12 @@ xsetroot -cursor_name left_ptr picom -b -I 1 -O 1 -i 1 -e 1 --no-fading-openclose || compton -b --no-fading-openclose -if which awesome > /dev/null; then - exec awesome +if which dk > /dev/null; then + for m in $(polybar --list-monitors | cut -d: -f1); do + MONITOR=$m polybar --reload bar & + done +fi + exec dk fi if which dwm > /dev/null; then @@ -39,6 +43,10 @@ if which dwm > /dev/null; then exec dwm fi +if which awesome > /dev/null; then + exec awesome +fi + if which xmonad > /dev/null && test -f ~/.config/xmonad/xmonad.hs; then exec xmonad fi