0

I'm working on a plank plugin recently, I want this plugin to display current desktop number and total number of desktops under current monitor.

I'm trying to get above numbers by examing root window's properties such as _NET_CURRENT_DESKTOP, _NET_NUMBER_OF_DESKTOPS, _NET_DESKTOP_NAMES, below is an example output of xprop command under linux:

>> xprop -frame
_NET_WM_ICON_NAME(UTF8_STRING) = 
_NET_ACTIVE_WINDOW(WINDOW): window id # 0x3c005d0
_NET_CLIENT_LIST(WINDOW): window id # 0x3c005d0, 0x4200003, 0x3200002, 0x3c00007, 0x2a00003, 0x1c00003, 0x2800003
_NET_CLIENT_LIST_STACKING(WINDOW): window id # 0x1c00003, 0x3200002, 0x2800003, 0x2a00003, 0x3c00007, 0x4200003, 0x3c005d0
XIM_SERVERS(ATOM) = @server=fcitx5
XFree86_DDC_EDID1_RAWDATA(INTEGER) = ......
AT_SPI_BUS(STRING) = "unix:path=/run/user/974/at-spi/bus_0,guid=d2b64617d145d6b9bd20e88d6332dce1"
_NET_CURRENT_DESKTOP(CARDINAL) = 2
_NET_NUMBER_OF_DESKTOPS(CARDINAL) = 6
_NET_DESKTOP_NAMES(UTF8_STRING) = "Work", "Work", "Work", "2", "2", "3"
_NET_SUPPORTING_WM_CHECK(WINDOW): window id # 0x400005

And I've finished a demo like this, W is first desktop name's first letter, 2 is second desktop's name:

Demo

But there is still some problems:

  • PROBLEM 1 I'm using vala to subscribe signal of workspace change, but I can not get callback while the newly create Desktop is empty, in other ways, I can only get callback when there is at least one window in newly created desktop.
Wnck.Screen screen = Wnck.Screen.get_default ();
// will not be invoked in handle_workspace_changed
// if the newly created desktop is empty
screen.active_workspace_changed.connect_after (handle_workspace_changed);
  • PROBLEM 2 I want get current desktop and total desktop numbers for each monitor, but the windows properties above is the total number of all my 3 monitors. Such as I have these desktops of each monitor:

Monitor 1: Work

Monitor 2: Work、2、3

Monitor 3: Work、2

Assume I'm currently on Monitor 3 desktop 2(empty desktop).

The root window actual properties will be :

_NET_CURRENT_DESKTOP(CARDINAL) = 2
_NET_NUMBER_OF_DESKTOPS(CARDINAL) = 6
_NET_DESKTOP_NAMES(UTF8_STRING) = "Work", "Work", "Work", "2", "2", "3"

These is not the correct behavior I want, what expect is:

_NET_CURRENT_DESKTOP(CARDINAL) = 1  // because I'm currently on desktop 2, but this value will not change until I put some window in desktop 2 (problem 1)
_NET_NUMBER_OF_DESKTOPS(CARDINAL) = 2 // Monitor 3 has 2 desktops which are: Work、2
_NET_DESKTOP_NAMES(UTF8_STRING) = "Work", "2" // Monitor 3 has 2 desktops which are: Work、2

So I'm current on _NET_CURRENT_DESKTOP(CARDINAL) = 1 desktop with name _NET_DESKTOP_NAMES(UTF8_STRING)[1] = "2", and there are _NET_NUMBER_OF_DESKTOPS(CARDINAL) = 2 desktops on this monitor.

So any suggestions to solve problem 1&2 ?

Hacksign
  • 416
  • 2
  • 7
  • 17

0 Answers0