You are not logged in.

#1 2018-07-21 14:24:54

AlmostSurelyRob
Member
From: UK
Registered: 2012-03-17
Posts: 77

Relative width for dzen2 in xmonad

On my laptop I have a relatively convenient setup with xmonad and dzen2, but recently I started using a large monitor and I find myself switching between laptop and the monitor screen. My problem is that the monitor is HiDPI and a lot of settings have to be adjusted. I now have a special Xresources that I run after connecting. It runs as part of the script which kills and resprawns two dzen2 bars with different settings to adjust for resolution change. I am wondering if there's a more elegant way of sorting out this problem. Ideally I would like to just replace this setting in .xmonad.hs

myXmonadBar = "dzen2 -x '0' -y '0' -h '30' -w '1200' -ta 'l' -fg '#FFFFFF' -bg '#1B1D1E'"
myStatusBar = "conky -c /home/rsa/.xmonad/conky.conf | dzen2 -x '1200' -y '0' -w '720' -h '30' -ta 'right' -bg '#1B1D1E' -fg '#FFFFFF'"

with some relative heights and widths and fontsize based on the screen resolution. I found a few suggestions on this forum about dzen2 configurations, but couldn't find anything that discusses this problem. Please let me know if you can point me in the right direciton. Thank you.

Offline

#2 2018-07-21 17:25:28

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Relative width for dzen2 in xmonad

I declare my dzen font setting (and -fg and -bg) in .Xresources, and then for individual instances only ever specifiy duration (-p): this works across both the laptop and external screens.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2018-07-21 18:42:43

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Relative width for dzen2 in xmonad

I think you can add an event hook to your xmonad config that matches on RRScreenChangeNotifyEvent. That seems to include the new width and height. You can have it run your script for you and/or kill/respawn dzen directly.

Last edited by Raynman (2018-07-21 18:42:56)

Offline

#4 2018-07-22 14:07:39

AlmostSurelyRob
Member
From: UK
Registered: 2012-03-17
Posts: 77

Re: Relative width for dzen2 in xmonad

Thanks for feedback. I think the screen notify event is what I am looking for. I need to investigate this a bit more. It would also let me run nitrogen --restore.

@jasonwryan I am not sure how to pull it out with Xresources. I thought you fix only parameters like foreground and font there and the settings are per application rather than application instance. How would I differentiate between two dzen bars?

Right now, the only setting I have there for dzen2 is

dzen2.font:     xft:inconsolata:size=10:antialias=true

Offline

#5 2018-07-22 18:24:05

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Relative width for dzen2 in xmonad

Ah. When you said "switching between" I read that literally (that's my workflow: when I am docked I disable the laptop monitor and just use the external display).


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#6 2018-07-23 20:11:54

AlmostSurelyRob
Member
From: UK
Registered: 2012-03-17
Posts: 77

Re: Relative width for dzen2 in xmonad

Sorry, I may have misexpressed myself. That is exactly what I mean by "switching between": I turn off laptop screen, turn on the monitor or vice versa. I just have two dzen bars and I don't know how Xresources could be utilised to change a specific one. How do I change a width, height or position of a specific dzen2 bar?

Offline

Board footer

Powered by FluxBB