Xfce Forum

Sub domains
 

You are not logged in.

#1 2021-10-19 13:14:03

PseudAnonymous
Member
Registered: 2021-04-05
Posts: 42

[SOLVED] It's All Gang Agley

It has - it's all gang very agley indeed sad



=============================================

Background:

1. https://forum.xfce.org/viewtopic.php?pid=62336#p62336

2. https://forum.xfce.org/viewtopic.php?id=14859

3. https://forum.xfce.org/viewtopic.php?id=14864

=============================================



It's all been going well since then and, for the most part, I've been a happy bunny, passing the name parameter to the script run by the genmon applet.

The workspace number : name  correspondences were

  1 : 5
  2 : 4
  3 : 3
  4 : 2
  5 : 1
  6 : 0
  7 : 1
  8 : 2
  9 : 3
10 : 4
11 : 5

The genmon applet displayed the name of workspaces 1 to 5 in red, of workspace 6 in blue and of workspaces 7 to 11 in green - all was good.


I've had a couple of hiccups when adding a workspace switcher applet to the panel for the purposes of testing out a couple of ideas: afterwards, the colour displayed in the genmon applet no longer  corresponded to the name of the workspace. For some reason, each time I added a workspace switcher, the number of workspaces was reset to 10. I don't know if that happened after adding it or after removing it, but the solution was to add the eleventh workspace back by increasing the count, quitting the X session and starting it again.


This time, however, things have gone seriously awry.

I increased the number of workspaces to 19.

But  forgot to edit the script the genmon applet runs.

So, of course, things weren't right.

It didn't immediately occur to me that I needed to edit the script, so I just confirmed that there were indeed 19 workspaces, quit the session and restarted X again.


Naturally, there was no improvement.

So, I double-checked what was going on, slapped myself, edited the script, quit, restarted and ...

.... and whaaaaaaaat!?


Not only were the colours wrong, the names of the workspaces were wrong too!


I reset the number of workspaces back to 11, edited the script back the way it was, quit the session, restarted it and ..

... it's still all horribly horribly messed up.



For the purposes of troubleshooting, I've

1. renamed the workspaces;

2. passed the both parameter to the script executed by the genmon applet;

3. added a second panel containing a workspace switcher displaying both the number and name of the workspaces.


As can be seen in the image below, the genmon applet is displaying some pretty random stuff.

It thinks that:

workspace  1 (name 'A') is named 'H'
workspace  2 (name 'B') is named 'J'
workspace  3 (name 'C') is named 'K'
workspace  4 (name 'D') is named '2
workspace  5 (name 'E') is named '3'
workspace  6 (name '#') is named '4'
workspace  7 (name 'F') is named '5'
workspace  8 (name 'G') is named '6' (Not shown in image)
workspace  9 (name 'H') is named '7' (Not shown in image)
workspace 10 (name 'J') is named '8' (Not shown in image)
workspace 11 (name 'K') is named '9'

desktop-woes.png

Full size image here



====================================================================================

The script run by the genmon applet


#!/bin/bash

# requires wmctrl

# If you just want the number (or name or both) of the current workspace only, add the xfce4-genmon-plugin to the panel.
# In the properties, uncheck the label option, change the font to suit if you want, set the cycle to 1 second and
# for the command, point to the following script:

CURRENT_DESKTOP=$(( $(wmctrl -d | grep "*" | awk '{print $1}') +1))
CURRENT_DESKTOP_NAME=$(xfconf-query -c xfwm4 -p /general/workspace_names |\
    tail -$(xfconf-query -c xfwm4 -p /general/workspace_count) |\
    awk -v i=$CURRENT_DESKTOP 'NR==i')

case $CURRENT_DESKTOP in
    [1-5]) COLOR="red" ;;
    [6]) COLOR="blue" ;;
    [7-9] | 1[0-1]) COLOR="green" ;;
esac

case $1 in
    number)
        echo "<txt> <span foreground='$COLOR'>$CURRENT_DESKTOP</span> </txt>"
        echo "<tool></tool>"
    ;;
    name)
        echo "<txt> <span foreground='$COLOR'>$CURRENT_DESKTOP_NAME</span> </txt>"
        echo "<tool></tool>"       
    ;;
    both)
        echo "<txt> <span foreground='$COLOR'>$CURRENT_DESKTOP : $CURRENT_DESKTOP_NAME</span> </txt>"
        echo "<tool></tool>"
    ;;
esac

exit 0

# ...and make sure to make the script executable.
# For the Command entry in genmon's properties, you'll need to pass a parameter, one of "number", "name" or "both".
# So the command should be something like:
#
# /path/to/script number


====================================================================================




In the Session and Startup settings, XFCE does not (and never has) automatically saved the session on logout.

There is only one saved session ( ' Default ' ) ... which was last accessed on Tue Dec 22 09:12:24 2020

[Perhaps relevant: when I start my X / XFCE session, it starts on workspace 1 and then automatically switches to workspace 6 - this has not, however been a problem before and is in fact desired behaviour (I originally saved my default session on workspace 6)]



Something has clearly been  saved somewhere and the wrong values are being passed to something as a result, but I have no idea where to begin looking.


I've tried logging out of and back into my user account.

I've tried logging out of my user account, logging in and out of root and back into my user account,

I've tried rebooting.

I've tried powering off, waiting a few seconds and restarting the machine.


But the problem persists sad




Help would be greatly appreciated.

Thamks.



[ETA: although the session is not automatically saved when I quit X / XFCE, any changes made to panels/applets/etc. are recalled the next time I start X - I don't know if that's because they aren't stored as part of the session files though, so it may not be relevant]

Last edited by PseudAnonymous (2021-10-22 01:33:45)


Don't dance like nobody's watching, dance like a toddler instead - they don't even care if there's any music!

Offline

#2 2021-10-19 23:18:19

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: [SOLVED] It's All Gang Agley

I wonder if the "#" workspace name is confusing the script. What happens if you rename the workspaces to your original naming scheme:

1 : 5
  2 : 4
  3 : 3
  4 : 2
  5 : 1
  6 : 0
  7 : 1
  8 : 2
  9 : 3
10 : 4
11 : 5


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2021-10-20 01:35:07

PseudAnonymous
Member
Registered: 2021-04-05
Posts: 42

Re: [SOLVED] It's All Gang Agley

The numbers being out of kilter was the reason I changed the names to letters, to see if that would shed some light as to what was going on - each is unique, so there was no chance of it picking the 'wrong J' of two.

Didn't help though.



The workspace switcher displays the correct name.

The genmon applet displays the correct colours but, as you can see, is utterly confused about the name.



Actual    Workspace    Genmon
                Switcher

   1                 5                  3         (Red)
   2                 4                  4         (Red)
   3                 3                  5         (Red)
   4                 2                  2         (Red)
   5                 1                  3         (Red)
   6                 0                  4         (Blue)
   7                 1                  5         (Green)
   8                 2                  6         (Green)
   9                 3                  7         (Green)
  10                4                  8         (Green)
  11                5                  9         (Green)





If I pass the number parameter to the script, the genmon applet reports the correct workspace number.

If I pass the both parameter, it reports the correct number, but the incorrect name in the same sequence as above.



The last time I saw it do anything quite so wrong in a '2.5D matrix' kind of way was when I was playing around with a workspace switcher and had it arrange things in more than  a single row.

But, the fix I described above resolved it as usual. Furthermore, this time all I did was add extra workspaces, not change the dimensionality of them.

Last edited by PseudAnonymous (2021-10-20 01:54:09)


Don't dance like nobody's watching, dance like a toddler instead - they don't even care if there's any music!

Offline

#4 2021-10-20 01:59:31

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: [SOLVED] It's All Gang Agley

PseudAnonymous wrote:

But, the fix I described above resolved it as usual. Furthermore, this time all I did was add extra workspaces, not change the dimensionality of them.

So is it working again now?

If not, what does the following return?

xfconf-query -c xfwm4 -p /general/workspace_names

Edit: Maybe try slowing the cycle down to see if it helps. Set it 1 or 2 seconds. Maybe with too many workspaces the .25 cycle is too fast

Last edited by ToZ (2021-10-20 02:08:14)


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2021-10-20 20:15:08

PseudAnonymous
Member
Registered: 2021-04-05
Posts: 42

Re: [SOLVED] It's All Gang Agley

As said, I changed it back to eleven desktops, but it hasn't fixed it.

Tried changing it to 2 s, but it didn't resolve the problem either.


xfconf-query -c xfwm4 -p /general/workspace_names

Value is an array with 19 items:

5
4
3
2
1
0
1
2
3
4
5
2
3
4
5
6
7
8
9

But my workspace switcher only show eleven - and they're all correctly numbered and named on it.


Don't dance like nobody's watching, dance like a toddler instead - they don't even care if there's any music!

Offline

#6 2021-10-20 23:11:59

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: [SOLVED] It's All Gang Agley

It looks like Xfce doesn't delete the names from the array when it lowers the number of workspaces. This will confuse the script because it starts counting from the bottom.

Try this version of the script:

#!/bin/bash

# requires wmctrl

# If you just want the number (or name or both) of the current workspace only, add the xfce4-genmon-plugin to the panel.
# In the properties, uncheck the label option, change the font to suit if you want, set the cycle to 1 second and
# for the command, point to the following script:

CURRENT_DESKTOP=$(( $(wmctrl -d | grep "*" | awk '{print $1}') +1))
CURRENT_DESKTOP_NAME=$(xfconf-query -c xfwm4 -p /general/workspace_names |\ 
    tail -n +3 |\
    head -$(xfconf-query -c xfwm4 -p /general/workspace_count) |\
    awk -v i=$CURRENT_DESKTOP 'NR==i')

case $CURRENT_DESKTOP in
    [1-5]) COLOR="red" ;;
    [6]) COLOR="blue" ;;
    [7-9] | 1[0-1]) COLOR="green" ;;
esac

case $1 in
    number)
        echo "<txt> <span foreground='$COLOR'>$CURRENT_DESKTOP</span> </txt>"
        echo "<tool></tool>"
    ;;
    name)
        echo "<txt> <span foreground='$COLOR'>$CURRENT_DESKTOP_NAME</span> </txt>"
        echo "<tool></tool>"       
    ;;
    both)
        echo "<txt> <span foreground='$COLOR'>$CURRENT_DESKTOP : $CURRENT_DESKTOP_NAME</span> </txt>"
        echo "<tool></tool>"
    ;;
esac

exit 0

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#7 2021-10-21 03:01:42

PseudAnonymous
Member
Registered: 2021-04-05
Posts: 42

Re: [SOLVED] It's All Gang Agley

ToZ wrote:

It looks like Xfce doesn't delete the names from the array when it lowers the number of workspaces.

Tut, tut  - someone needs to look at that.

And by 'look at' I mean 'atone for their inadequacy before they bring shame upon their family, community, nation and the planet (possibly even the galaxy).'

Insofar as that's possible, that is: not flushing, resizing and repopulating  the array? Embarrassing wink

This will confuse the script because it starts counting from the bottom.

Not the script's fault, is it?

Try this version of the script:

Yup , that got it.

Thankyou!



Now.

About those extra workspaces I wanted.

Will the new script work with them, if I modify it as follows?

case $CURRENT_DESKTOP in
    [1-9]) COLOR="red" ;;
    [10]) COLOR="blue" ;;
    1[1-9]) COLOR="green" ;;
esac

Don't dance like nobody's watching, dance like a toddler instead - they don't even care if there's any music!

Offline

#8 2021-10-21 06:32:19

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: [SOLVED] It's All Gang Agley

PseudAnonymous wrote:


Now.

About those extra workspaces I wanted.

Will the new script work with them, if I modify it as follows?

case $CURRENT_DESKTOP in
    [1-9]) COLOR="red" ;;
    [10]) COLOR="blue" ;;
    1[1-9]) COLOR="green" ;;
esac

Yes I think it should. Give it a go and let me know.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#9 2021-10-21 17:10:21

PseudAnonymous
Member
Registered: 2021-04-05
Posts: 42

Re: [SOLVED] It's All Gang Agley

Yes I think it should. Give it a go and let me know.

Okay, I'll guineapig it for you wink


It does, except for the '[10]'

It has to be as follows, to work properly

case $CURRENT_DESKTOP in
    [1-9]) COLOR="red" ;;
    1[0]) COLOR="blue" ;;
    1[1-9]) COLOR="green" ;;
esac

Unfortunately, there are only twelve available  Settings-Window Manager-Keyboard-Action/Shortcut  entries for 'Use Workspace' (or indeed any other workspace related shortcuts).

It does seem like a bit of an oversight not to have allowed for the idea that people would be happy to use other key combos - the only Function keys I've ever used in my life were F1/Help, F2/Rename, F3/Search and the dreaded F2/F5/F8/F10/F12-which-one-do-I-press-to-get-into-the-BIOS-select-a-boot-device-or-make-DOS-do-(whatever it used to be)-this-time?-*sigh*


But, nevertheless, such limitations are now academic as far as my next question is concerned:

What do I have to do, to get it to work with 21 desktops?


No doubt, something along the lines of :


case $CURRENT_DESKTOP in
    [1-9] | 1[0]) COLOR="red" ;;
    1[0]) COLOR="blue" ;;
    1[1-9] | 2[0-1]) COLOR="green" ;;
esac

But, I'm scared to try, because I don't actually know how your script works, I'm only 'reverse engineering' it, so to speak, and it could all go even agleyer, if I get it wrong - and things already turned pretty ugly when it went agley last time (I shudder to imagine what might happen if I got it wrong with 21!).


And what happens if I get ambitious and want to try for 31?

What will that last line look like then?

Is

1[7-9] | 2[0-9] | 3[0-1])

even possible?

Last edited by PseudAnonymous (2021-10-21 17:32:20)


Don't dance like nobody's watching, dance like a toddler instead - they don't even care if there's any music!

Offline

#10 2021-10-21 18:17:57

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: [SOLVED] It's All Gang Agley

I'm not sure if there are any limits on the number of workspaces one can have (though I must admit, you win the prize for most workspaces as far as I know).

The only way to know for sure is to try. Not sure if you have a second install (maybe in a VM) or even via https://distrotest.net/ where you could try the script without impacting your main system.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#11 2021-10-22 01:33:04

PseudAnonymous
Member
Registered: 2021-04-05
Posts: 42

Re: [SOLVED] It's All Gang Agley

ToZ wrote:

I'm not sure if there are any limits on the number of workspaces one can have

Yet another undocumented matter, huh?


ToZ wrote:

(though I must admit, you win the prize for most workspaces as far as I know).

I have needs wink

I have a lot of different things on the go at any one time: a minimum of five different email accounts open, various system level things on the go, multiple webbrowsers (each with multiple windows full of multiple tabs) in which I'm researching all kinds of things (from operating systems to scripting techniques to hardware to music hardware and software to psychology to education to  various multilingual resources, by way of whatever else has occurred to me in a moment of inspiration/desperation), wordprocessors, spreadsheets, filemanagers, all kinds of stuff ... and I need around three-to-five desktops for each 'activity set' (a core focus and one or two each side for related, but different resources) - I need a lot of workspaces.


ToZ wrote:

The only way to know for sure is to try.

Why do I get the impression I'm the one doing all the work here?  tongue


ToZ wrote:

Not sure if you have a second install (maybe in a VM)

Sadly not. Right now, for various reason, I'm down from around eleven systems to one Linux, and one Windows, laptop.

Tthe Linux laptop just isn't powerful enough for a VM: 4GB, core2-duo that's the last spare standing after three others bit the dust in the last two years. Technologically, my world has been slowly crumbling around me during the Great Lockdown and it looks set to get worse here as the government is probably gonna put us all in lockdown again soon enough (and even cancel Christmas again,) due to (ongoing) incompetence. Couple that with supply chain issues, world chip shortages and all the rest and I doubt I'm gonna be in  a happier place than I am right now for some time to come (technologically speaking at least). So, I daren't risk putting this laptop under the strain of trying to run a VM either, just in case I can't get a new one any time soon (it took three months for a USB dongle from Germany to clear customs here, never mind a laptop!) - it' had some horrible overheating problems in the not too distant past and, whilst it seems okay now, too much of a good thing might kill it (and if this laptop goes futsch too, I'll be screwed).

And the Windows one is dedicated to music production - nothing else goes anywhere near it at even the best of times, but the NAS was already full, and then my backup drive blew up three days ago  (or at least the dock it was in did and I'm waiting on a new one before I find out whether it took the drive with it)  - so I wouldn't dare risk it anyway.


ToZ wrote:

or even via https://distrotest.net/ where you could try the script without impacting your main system.

Looks fun.

Gave it a quick look, but was busy.

Would try Arch as it's what I know, but the idea of installing it and then X + XFCE, just to test this, doesn't thrill me right now. I'm already gonna have to rebuild this laptop imminently anyway, because last time I did it, I didn't anticipate having to make it my main workhorse and only assigned 20GB to '/', which isn't enough, on a daily driver, even for a minimalist like me - I'm down to 600MB free and terrified it'll collapse under weight of another update before I've done the necessary prep for building it on a new drive. I'm gonna have to do a whole Arch build in the next four to six weeks already ... I don't wanna do one that'll disappear again after only five minutes' use.


You've helped me out enough as it is already, thanks, and rescued me from the hell of having to sacrifice even more of my measly 766 pixels vertical to a worskapce switcher. I'll just have to be satisfied with 19 workspaces for now and close the ticket  wink

Last edited by PseudAnonymous (2021-10-22 01:36:38)


Don't dance like nobody's watching, dance like a toddler instead - they don't even care if there's any music!

Offline

#12 2021-10-22 18:11:16

PseudAnonymous
Member
Registered: 2021-04-05
Posts: 42

Re: [SOLVED] It's All Gang Agley

Just to let you know:

The following works with 21 desktops.

case $CURRENT_DESKTOP in
    [1-9] | 1[0]) COLOR="red" ;;
    1[1]) COLOR="blue" ;;
    1[2-9] | 2[0-1]) COLOR="green" ;;
esac

I'm not gonna try 31 right now - I don't think even I have a use for 31 just yet wink

But your script appears to accommodate all eventualities - masterful and thankyou very much!


Don't dance like nobody's watching, dance like a toddler instead - they don't even care if there's any music!

Offline

Board footer

Powered by FluxBB