Dk workspaces and multi monitor

How are you guys handling multi monitor with dk?

I want it to wok like this:

  • 10 workspaces - 5 on HDMI-A-0 (monitor one) 5 on DisplayPort-0 (monitor two)
  • certain apps to open on workspaces 1-5 others 6-7

This is my dkrc, I am confused. I am not sure I have the monitor bit at the bottom correct or not.

#!/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 &
fi

{ # compound command to redirect all output

	# workspace settings
	# ------------------------

	# initialize 10 workspaces (1-10)
	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=10 msplit=0.5 ssplit=0.5

	# change workspace names
	dkcmd set \
		ws=1  name="" \
		ws=2  name="" \
		ws=3  name="" \
		ws=4  name="" \
		ws=5  name="" \
		ws=6  name="" \
		ws=7  name="" \
		ws=8  name="" \
		ws=9  name="" \
		ws=10 name=""


	# 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

	# use static workspaces (not default)
	dkcmd set static_ws=true

	# assign workspaces to monitors (requires static_ws=true)
	 mon1='HDMI-A-0'
	 mon2='DisplayPort-0'
	 dkcmd set \
	 	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
	# ---------

	# set border width and colour for each window state
	# dkcmd set border width=1 colour focus='#6699cc' unfocus='#000000' urgent='#ee5555'

	# alternatively, enable split borders and colours
	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 are always case insensitive

	# open window(s) on a specific workspace (assigned monitor)
	dkcmd rule class="^Firefox$" ws=1
	dkcmd rule class="^Qutebrowser$" ws=1
	dkcmd rule class="^Surf$" ws=1
	dkcmd rule class="^gimp-2.10$" ws=2
	dkcmd rule class="^St$" ws=2
	dkcmd rule class="^alacritty$" ws=2
	dkcmd rule class="^transmission-gtk$" ws=3
	dkcmd rule class="^SoulseekQt$" ws=3
	dkcmd rule class="^ncmpcpp$" ws=6
	dkcmd rule class="^thunar$" ws=7
	dkcmd rule class="^mpv$" ws=7
	dkcmd rule class="^subl$" ws=8
	dkcmd rule class="^emacs$" ws=8
	dkcmd rule class="^gpick$" ws=8
	dkcmd rule class="^Slack$" ws=9
	dkcmd rule class="^easytag$" ws=9
	dkcmd rule class="^Xfce4-taskmanager$" ws=10
	dkcmd rule class="^pavucontrol$" ws=10
	dkcmd rule class="^blueman-manager$" ws=10
	dkcmd rule class="^nitrogen$" ws=10
	dkcmd rule class="^steam$" ws=10
	
	# open window(s) on a monitor by number or name (active workspace on monitor)
	dkcmd rule class="^chromium$" mon="DisplayPort-0"

	# open window(s) and use a callback function (defined in config.h)
	# we also ignore to stop the window from being resized on it's own
	# 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="^(scratchpad|nitrogen|MuPDF|File-roller|GPick|Xfce4-appearance-settings|mpv|sxiv|ncmpcpp|pavucontrol|steam|blueman-manager|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
	dkcmd rule class="^firefox$" title="^Picture-in-Picture$" float=true w=150 h=40
	dkcmd rule class="^st$" title="^scratchpad$" float=true w=150 h=40

	# 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

	# focus window and workspace on opening
	dkcmd rule class="^Firefox$" ws=1 focus=true
	dkcmd rule class="^Qutebrowser$" ws=1 focus=true
	dkcmd rule class="^Surf$" ws=1 focus=true
	dkcmd rule class="^St$" ws=2 focus=true
	dkcmd rule class="^alacritty$" ws=2 focus=true
	dkcmd rule class="^transmission-gtk$" ws=3 focus=true
	dkcmd rule class="^SoulseekQt$" ws=3 focus=true
	dkcmd rule class="^ncmpcpp$" ws=4 focus=true
	dkcmd rule class="^thunar$" ws=5 focus=true
	dkcmd rule class="^mpv$" ws=5 focus=true
	dkcmd rule class="^subl$" ws=7 focus=true
	dkcmd rule class="^emacs$" ws=7 focus=true
	dkcmd rule class="^Slack$" ws=8 focus=true
	dkcmd rule class="^easytag$" ws=9 focus=true
	dkcmd rule class="^Xfce4-taskmanager$" ws=9 focus=true
	dkcmd rule class="^blueman-manager$" ws=9 focus=true
	dkcmd rule class="^nitrogen$" ws=10 focus=true
	dkcmd rule class="^steam$" ws=10 focus=true
	
	# update or remove an existing rule with the same match patterns
	dkcmd rule class="^firefox$" mon="HDMI-A-0"
	dkcmd rule class="^Qutebrowser$" mon="HDMI-A-0"
	dkcmd rule class="^Surf$" mon="HDMI-A-0"
	dkcmd rule class="^gimp-2.10$" 
	dkcmd rule class="^St$" mon="HDMI-A-0"
	dkcmd rule class="^alacritty$" mon="HDMI-A-0"
	dkcmd rule class="^transmission-gtk$" mon="HDMI-A-0"
	dkcmd rule class="^SoulseekQt$" mon="HDMI-A-0"
	dkcmd rule class="^ncmpcpp$" mon="DisplayPort-0"
	dkcmd rule class="^thunar$" mon="DisplayPort-0"
	dkcmd rule class="^mpv$" mon="DisplayPort-0"
	dkcmd rule class="^subl$" mon="DisplayPort-0"
	dkcmd rule class="^emacs$" mon="DisplayPort-0"
	dkcmd rule class="^gpick$" mon="DisplayPort-0"
	dkcmd rule class="^Slack$" mon="DisplayPort-0"
	dkcmd rule class="^easytag$" mon="DisplayPort-0"
	dkcmd rule class="^Xfce4-taskmanager$" mon="DisplayPort-0"
	dkcmd rule class="^pavucontrol$" mon="DisplayPort-0"
	dkcmd rule class="^blueman-manager$" mon="DisplayPort-0"
	dkcmd rule class="^nitrogen$" mon="DisplayPort-0"
	dkcmd rule class="^steam$" mon="DisplayPort-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

This is what I have for the workspaces:

	# use static workspaces (not default)
	# dkcmd set static_ws=false
	dkcmd set static_ws=true

	# change workspace names
	dkcmd set \
		ws=1  name="1" \
		ws=2  name="2" \
		ws=3  name="3" \
		ws=4  name="4" \
		ws=5  name="5" \
		ws=6  name="6" \
		ws=7  name="7" \
		ws=8  name="8" \
		ws=9  name="9" \
		ws=10 name="10"

	# assign workspaces to monitors (requires static_ws=true)
	mon1='HDMI1'
	mon2='VGA1'
	dkcmd set \
	 	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

Then I open applications on a specified workspace and have them grab focus -

# open window(s) on a specific workspace (assigned monitor)
	dkcmd rule class="^gimp$" ws=6 focus=true

# focus window and workspace on opening
	dkcmd rule class="^firefox$" ws=4 focus=true

I have not tried to open an application on a specific monitor and open on the current workspace. Your rules look right, maybe try mon1, mon2 instead of the actual monitor name.

You planning to use a status bar like polybar? I have yet to figure out how to get polybar to function properly on two monitors with dk. Interested to see what you come up with (but that should probably be another thread).

1 Like

Polybar is driving me up the fucking wall to say the least. I’ll persevere for now with it though.

I thought about that, haven’t tried it yet though. Will report back.

@PackRat I forgot to ask, what bar are you using again? If it is lemonbar or something else can you please share the config.

I just use polybar, and tried to set it up for each monitor like I do with bspwm:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; dk
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[bar/dk-bar]
inherit = bar/master

modules-left = appmenu dk-workspaces dklayouts
modules-center = chronos
modules-right = coregraph ramgraph lan-network

; Position of the system tray window
; If empty or undefined, tray support will be disabled
; NOTE: A center aligned tray will cover center aligned modules
;
; Available positions:
;   left
;   center
;   right
;   none
;tray-position = right

; If true, the bar will not shift its
; contents when the tray changes
;tray-detached = false

; Tray icon max size
;tray-maxsize = 16

; Background color for the tray container 
; ARGB color (e.g. #f00, #ff992a, #ddff1023)
; By default the tray container will use the bar
; background color.
;tray-background = ${root.background}

; Tray offset defined as pixel value (e.g. 35) or percentage (e.g. 50%)
tray-offset-x = 0
;tray-offset-y = 0

; Pad the sides of each tray icon
;tray-padding = 0

; Scale factor for tray clients
;tray-scale = 1.0

[bar/dkvga-bar]
inherit = bar/master-02

modules-left = appmenu dk-workspaces dklayouts
modules-center = chronos
modules-right = filesystem

; Position of the system tray window
; If empty or undefined, tray support will be disabled
; NOTE: A center aligned tray will cover center aligned modules
;
; Available positions:
;   left
;   center
;   right
;   none
;tray-position = right

; If true, the bar will not shift its
; contents when the tray changes
;tray-detached = false

; Tray icon max size
;tray-maxsize = 16

; Background color for the tray container 
; ARGB color (e.g. #f00, #ff992a, #ddff1023)
; By default the tray container will use the bar
; background color.
;tray-background = ${root.background}

; Tray offset defined as pixel value (e.g. 35) or percentage (e.g. 50%)
tray-offset-x = 0
;tray-offset-y = 0

; Pad the sides of each tray icon
;tray-padding = 0

; Scale factor for tray clients
;tray-scale = 1.0

bar/master is set up to use monitor HDMI

[bar/master]
; Use either of the following command to list available outputs:
; If unspecified, the application will pick the first one it finds.
; $ polybar -m | cut -d ':' -f 1
; $ xrandr -q | grep " connected" | cut -d ' ' -f1
monitor = HDMI1

; Use the specified monitor as a fallback if the main one is not found.
monitor-fallback = HDMI1

; Require the monitor to be in connected state
; XRandR sometimes report my monitor as being disconnected (when in use)
monitor-strict = false

bar/master-02 is set to use monitor VDA1

[bar/master-02]
; Use either of the following command to list available outputs:
; If unspecified, the application will pick the first one it finds.
; $ polybar -m | cut -d ':' -f 1
; $ xrandr -q | grep " connected" | cut -d ' ' -f1
monitor = VGA1

; Use the specified monitor as a fallback if the main one is not found.
monitor-fallback = VGA1

; Require the monitor to be in connected state
; XRandR sometimes report my monitor as being disconnected (when in use)
monitor-strict = false

Everything else is the normal polybar configurations.

In bspwm it works just fine; functioning polybar on each monitor. In dk one polybar will function like you would expect a bar to function, the other bar acts more like a floating window - sometimes it’s above the windows, sometimes below.

1 Like

I was having the same issue. Makes sense now. It did work okay for me a while ago on both monitors.

No luck on that.

I did notice I had the focus section of the rules wrong, the workspaces didn’t match. Corrected those and still no luck.

I think I sorted it, well mostly.

I removed all the entries from # update or remove an existing rule with the same match patterns then I updated the monitors in this section # open window(s) on a monitor by number or name (active workspace on monitor).

All seem to be working as they should except for Sublime Text which just refuses to play ball.

Update:

Yeah shit is all fucked up. After a restart it is back to as it was. Not doing what it should be.

Further update.

All seems okay now. Restarted dk and all apps are opening on the correct workspaces. Sublime text has been given the boot as it has just been a pain in the arse since the version 4 release.

Just need to sort a bar now with workspaces working as they should. Hopefully someone has an idea.

I feel your pain.

Here’s a shot of polybar glitch:

the bar on the left (HDMI) monitor functions as expected. On the right (VGA) the window goes below the bar. I have not found a way to fix that.

Mine was doing the exact same. I might play around with just one polybar session and see how it goes.

That works fine on my end and is my current working configuration.

Interesting.

If I launch the polybars individually from a terminal after dk loads, both work as expected.

That is interesting. Can confirm the same happens here.

Now my workspace labels in polybar don’t want to match the workspace labels in dkrc. Grrrr!!

1 Like

I’ve known about the bar issue for a few days now and I’ve been looking into it but other things were more important at the time but now I’d like to focus on it. There’s an open issue on bitbucket if possible please submit the output from the following two commands

Edit

xrandr

dkcmd status type=full num=1

Anything else? Just let me know

2 Likes

Sweet as, added my output at Bitbucket.

Any idea why my workspace icons aren’t as they should be? They are seeming to follow what I have for dwm. I created a completely separate config for dk and still the same.

1 Like

Added the information.

@PackRat & @Dobbie03 Thanks, I’m toast for the night but I’ll get to it this weekend at the latest.

1 Like

Thanks. No rush, enjoy your weekend.

1 Like

No worries here, I’m gonna run barless for a few days. I’m wondering if there is a dmenu/script out there for open windows? Easy switching and reminding myself what I have open and where.

1 Like