You are not logged in.
You can force the last workspace.
until [ $(xprop -root _NET_CURRENT_DESKTOP | cut -d' ' -f3) -eq "$LAST_WORKSPACE" ]; do
wmctrl -s $LAST_WORKSPACE
sleep 1
done
Prints the current workspace (-1 because it starts from 0)
xprop -root _NET_CURRENT_DESKTOP | cut -d ' ' -f 3
Prints number of workspaces
xprop -root _NET_NUMBER_OF_DESKTOPS | cut -d ' ' -f 3
Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c
Offline
Misko:
Thank you for the useful code.
On my slow machine, in my version of the script, LAST_WORKSPACE is set successful initially but, certainly to my surprise, some other process (xfdesktop or xfwm4 or maybe xfsettingsd?) forceably changes the workspace to the first workspace after about 1.3 seconds. So I have to wait until that happens before changing back to LAST_WORKSPACE. My code still works if LAST_WORKSPACE is actually is the first workspace.
This problem does not occur on my (very) fast machine, possibly (probably?) because the forced change to the first workspace takes place very quickly. So I think that my version is only suitable for a slow machine. On my fast machine I use ToZ's solution #41 above.
I don't suppose that there are many people using slow machines although xfce, being very lightweight, is especially suitable for old machines. So it wouldn't be a bad idea to enhance the underlying code so that on startup the last workspace could be selected. If you have any suggestions as to where the underlying problem lies then please let me know. As I've said above, I don't think there is much incentive to make this 'enhancement' as I don't suppose anybody has previously mentioned starting up with the last workspace in all these years!
Thank you Misko and, again, many thanks to ToZ who has done an amazing job!
Alan
Offline
Misko:
On my slow machine, in my version of the script, LAST_WORKSPACE is set successful initially but, certainly to my surprise, some other process (xfdesktop or xfwm4 or maybe xfsettingsd?) forceably changes the workspace to the first workspace after about 1.3 seconds. So I have to wait until that happens before changing back to LAST_WORKSPACE. My code still works if LAST_WORKSPACE is actually is the first workspace.
xprop has an option to spy on wm hints forever.
xprop -spy -root _NET_CURRENT_DESKTOP
If you run this in terminal and switch workspaces you'll see that this prints out the current workspace.
You could wait for this change to occur like this:
xprop -spy -root _NET_CURRENT_DESKTOP | read
when it does the script will continue.
The problem is when it doesn't happen the script will be stuck.
You can use timeout to handle this
timeout 3 xprop -spy -root _NET_CURRENT_DESKTOP | read
If workspace doesn't change in 3 seconds timeout will kill the command and the script will continue.
Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c
Offline
Misko:
That works well and is more succinct.
Thanks you,
Alan
Offline
Hello friends,
I have looked for this for a long time. How come this isn't implemented in the XFCE by default?
Anyway, I have MX Linux, and I would like to just confirm that Misko's version 2.1 is the newest and best one.
I also don't understand the part with Workspace icons folders. Are those folders that contain the .desktop files? Is this supposed to put the Documents, Pictures, etc. folders on the desktop? If I have a folder on the desktop, and that folder is in the Documents folder, then I should include the documents folder in the list? Aren't all the .desktop files and icons hidden deep somewhere where no one can find them? How come this folder is not on the list? I'm so confused.
Imagine I install Firefox, I have a folder in Documents, and I have a folder in my Home directory. I want these 3 things on the workspaces, but differently arranged. What should I include on the list?
Thank you!
PS: Can I make a feature request for this to be implemented in XFCE in the bugzilla, or will you do it?
Offline
I have looked for this for a long time. How come this isn't implemented in the XFCE by default?
This is a real outside use case - not many people look for this functionality. Hence a workaround script like this one.
Anyway, I have MX Linux, and I would like to just confirm that Misko's version 2.1 is the newest and best one.
Yes, I guess it would be. It's the latest one posted here.
I also don't understand the part with Workspace icons folders. Are those folders that contain the .desktop files?
You could, but in the examples in the script they are just regular folders. When used, it will display the contents of those folders on the workspace.
Is this supposed to put the Documents, Pictures, etc. folders on the desktop?
Kind of. It puts the contents of those folders on the desktop.
If I have a folder on the desktop, and that folder is in the Documents folder, then I should include the documents folder in the list? Aren't all the .desktop files and icons hidden deep somewhere where no one can find them? How come this folder is not on the list? I'm so confused.
This is confusing. We need to understand your use case. What exactly do you want to do?
Imagine I install Firefox, I have a folder in Documents, and I have a folder in my Home directory. I want these 3 things on the workspaces, but differently arranged. What should I include on the list?
Okay, this is your use case. To make this happen, you would add the folder in Documents as your first entry, and the folder in your Home directory as your second entry (the contents of these folders will be displayed on the dekstop). In both of these folders, you should copy or link the firefox.desktop file from /usr/share/applications so it is also displayed on the desktop.
PS: Can I make a feature request for this to be implemented in XFCE in the bugzilla, or will you do it?
You are always welcome to create an enancement request. However, it is a very outside use case and may not be accepted.
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
Ooh, I think I understand. So to get normal functionality, I should just link the Desktop folder, and everything will work just fine. Right?
Why would I want the whole contents of random folders like Pictures on my workspace. Haha.
Unless... is each entry supposed to represent one workspace or something? Would I need 2 Desktop folders in that case? Is each folder in the initial array (Downloads, Pictures, Documents... etc) supposed to be one workspace per folder? Would I have to have Desktop and Desktop1 folders for my workspaces 1 and 2 ? If I dragged and dropped a file on workspace 2, does it automatically get added in Desktop1 folder?
Thanks!
PS: I think this is a grerat and revolutionary feature which might get used by a lot of people if they knew about it. It is basically an extended and customizable workspace. Much better than the default anyway.
EDIT:
I just tried it all again on my MX VM, and I messed up a couple of times. I used Miskos 2.1 script from 1.1.2019. Finally, it all worked, and after switching a few times, the output was:
demo@mx1:~/Desktop
$ chmod +x aaa.sh
demo@mx1:~/Desktop
$ ./aaa.sh
xfdeskiconsDEBUG: Locking succeeded
cat: /home/demo/.cache/.xfdeskicons: No such file or directory
cp: cannot stat '/home/demo/.config/xfce4/desktop/icon.layout.0': No such file or directory
3642
cp: cannot stat '/home/demo/.config/xfce4/desktop/icon.layout.1': No such file or directory
4192
4276
4303
4361
4376
4440
4877
The terminal seems to get a new number on each switching of the workspace. When I close the terminal, the script stops. I got some kill suggestion or something at one point also.
I also tried your code from 2019-01-06 13:08:23 , and at first it didn't work, and I had gotten weird errors, but second time, it seemed to be working even better than the other one. Only thing I mentioned is that the weird number is being reported every second.
And here I wanted to paste the output, and something got messed up, and now nothing works.
Ehh.. This is why I prefer legit programs with gui. Shells are so volatile, and I have no idea what I'm doing... xD
The log went 1,2,3,4,5,6 at first, but now it goes 1-9 (error) xD
Managed to kill the process with pgrep and kill. Now the lot of numbers don't appear, and it says "Locking succeeded".
The log output is:
1. start
2. lock enabled
3. retrieved icon file
4. retrieved old workspace
4.1 OLD=-3
6. got old workspace
with OLD getting lower and lower each time I try to run the script in the terminal (I shut off the terminal, so the script should be also turned off, no?). Anyway, now it's at -4. So I suspect that something went south, and I openeed too many of them. I also managed to open Misko's script abunch of times at one point, and I thought to myself how it would be nice to have a check whether the script is already running and prevent it from being ran simultaneously more than once. But I saw some check in your script, so maybe this is that. I dunno.
Anyway,
1. can you give me some advice on what to do, which script to use, how to use it?
2. what happens if I have 3 workspaces, and only 2 folders in the WSPACE_ICONS_FOLDERS array?
3. do the numbers each second and the log file require a lot of processing power? Can you give me a super good lean mean 2b version that will be the final and best version, with all the good stuff, which could be used even by people like me who have no idea what they are doing?
Tnx! Any advice or suggestion is welcome!
Last edited by anlity60 (2019-10-02 08:26:37)
Offline
1. can you give me some advice on what to do, which script to use, how to use it?
The last script provided above still works. Lets use the following use case as an example.
A person wants to have 3 workspaces each with its own set of icons:
for browsing and office applications
for music and media
for playing games
You could create 3 directories and copy over the appropriate .desktop and regular files to these directories (the ones you want displayed on the desktop) so that the layout looks something like this:
- Desktop-Main
----- firefox.desktop
----- libreoffice-writer.desktop
----- Resume.odt
- Desktop-Media
----- audacious.desktop
----- headbanger.mp3
- Desktop-Games
----- halflife3.desktop
----- chess.desktop
Then, in the system, you would ensure that you have 3 workspaces set and in the script you would edit the WSPACE_ICON_FOLDERS array to look like this:
WSPACE_ICONS_FOLDERS=( "/home/toz/Desktop-Main"
"/home/toz/Desktop-Media"
"/home/toz/Desktop-Games" )
Then when you run the script and change workspaces, the icons as listed above would appear on the desktop.
2. what happens if I have 3 workspaces, and only 2 folders in the WSPACE_ICONS_FOLDERS array?
Good question. My guess is that it won't change the desktop because there is no value to set it to.
3. do the numbers each second and the log file require a lot of processing power? Can you give me a super good lean mean 2b version that will be the final and best version, with all the good stuff, which could be used even by people like me who have no idea what they are doing?
The whole script runs every .1 seconds, so yes, it will use processing power. You can change the ".1" to "1" if you can live with the extra delay. To get rid of the numbers, replace every "pgrep xfdesktop" in the script with"
pgrep xfdesktop > /dev/null 2>&1
An important thing to note is that this script is a hack - and a bit of an ugly hack. It force kills xfdesktop to get it re-read the configuration settings so that it displays the correct desktop. Not really an optimal approach, but the best given the options that exist. Also, on slower systems, there will be a noticeable delay in the redraw of the desktop.
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
Good evening all,
I hope you are all well. ToZ: I want to say thank you again for the help you provided me over a year ago. I bookmarked this thread just in case I ever needed to get back to it, and I'm glad I did because I have an issue. I thought this was a new problem, but it seems as though it maybe isn't. My daughter has had the problem described below for months and has said nothing to me about it because she doesn't really care how the icons line up, just so long as they are all present on each different workspace. I like my icons grouped in some sort of logical way, so that I know where to find them.
For starters, I have attached the three scripts I use to switch desktops and switch panels. This way you can see what few modifications I have made to your scripts and hopefully help me see what my problem may be. It just dawned on my that at least part of my problem may be that I have two different scripts running independently of each other all the time and they may be getting in each others way. In any case, my issue...
My desktop icons seem to stay where I place them only about half of the time. Switching back and forth between work spaces, I have to reset the icon layout three or four times a day, which has gotten a little old. Best I can tell, when I switch from say, workspace 1 to workspace 3, the icon layout is saved in the appropriately named file. When I switch back to workspace 1 about half the time, all of my icons are recalled to their proper place and the other half of the time, they are lined up in the default configuration, down the left hand side of the screen. Immediately after switching back to workspace 1 (in instances where my icons are defaulted), before I touch anything, I go and view the desktop layout file created the last time I left workspace 1, which should have been loaded when I re-entered workspace 1. The desktop file shows the proper icon placement, which seems weird because it doesn't get reflected on the actual desktop. I then backup the good layout file and leave the workspace again.
Upon leaving, my good layout file is scrapped and the default layout is saved in its place. I then delete the bad layout file and restore my backup file. Upon re-entering the workspace, my desktop icons are recalled to their proper places. I tried write protecting the layout file. This stops the file from being overwritten, but doesn't seem to resolve my issue in its entirety. If I write protect the layout file, sometimes the icons are recalled to their proper places, sometimes they are defaulted down the left had side of the screen, and sometimes the icons end up in random places on the desktop. Usually after I switch out and switch back in three or four times, the icons are recalled to their proper places.
Any idea what i can do to solve my problem?
The desktop folder switching script:
#!/bin/bash
#Name: xfdeskicons
#Description: Displays a different set of icons on each workspace's desktop (corresponding to separate folders)
#Requires: wmctrl, xdg-user-dirs
#Debug mode: bash -xv /path/to/xfdeskicons 2>&1 | tee xfdeskicons.log
declare -a WSPACE_ICONS_FOLDERS
### Set these values to the folders containing the icons for each workspace
WSPACE_ICONS_FOLDERS=( "/home/$USER/.ws1"
"/home/$USER/.ws2"
"/home/$USER/.ws3"
"/home/$USER/.ws4"
"/home/$USER/.ws5"
"/home/$USER/.ws6"
"/home/$USER/.ws7"
"/home/$USER/.ws8"
"/home/$USER/.ws9"
"/home/$USER/.ws10"
"/home/$USER/.ws11"
"/home/$USER/.ws12"
"/home/$USER/.ws13"
"/home/$USER/.ws14"
"/home/$USER/.ws15"
"/home/$USER/.ws16"
"/home/$USER/.ws17"
"/home/$USER/.ws18"
"/home/$USER/.ws19"
"/home/$USER/.ws20" )
### Do not change anything below here
# make sure that only one instance of this script is running per user
lockfile=/tmp/.xfdeskicons.$USER.lockfile
if ( set -o noclobber; echo "locked" > "$lockfile") 2> /dev/null; then
trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
echo "xfdeskiconsDEBUG: Locking succeeded" >&2
# on startup, get the latest real xfdesktop icon file
ICON_FILE=$(ls -t ~/.config/xfce4/desktop | grep screen | head -1)
# on startup, set the CURRENT_WORKSPACE value & display correct icons
CURRENT_WORKSPACE=$(($(wmctrl -d | grep \* | cut -d' ' -f1)+1))
xdg-user-dirs-update --set DESKTOP "${WSPACE_ICONS_FOLDERS[$(($CURRENT_WORKSPACE-1))]}"
cp ~/.config/xfce4/desktop/icon.layout.$(($CURRENT_WORKSPACE-1)) ~/.config/xfce4/desktop/$ICON_FILE
pgrep xfdesktop || xfdesktop &
# every second, query the active workspace number and if different from the previous one, send a notification
while true
do
sleep 1
NEW_WORKSPACE=$(($(wmctrl -d | grep \* | cut -d' ' -f1)+1))
if [ $CURRENT_WORKSPACE -ne $NEW_WORKSPACE ]; then
# save current icon layout
cp ~/.config/xfce4/desktop/$ICON_FILE ~/.config/xfce4/desktop/icon.layout.$(($CURRENT_WORKSPACE-1))
# using xdg-user-dirs-update, point $XDG_DESKTOP to the proper icon folder
xdg-user-dirs-update --set DESKTOP "${WSPACE_ICONS_FOLDERS[$(($NEW_WORKSPACE-1))]}"
# restore new icon layout
cp ~/.config/xfce4/desktop/icon.layout.$(($NEW_WORKSPACE-1)) ~/.config/xfce4/desktop/$ICON_FILE
# reload xfdesktop to re-read values and display correct icon set
kill -HUP $(pidof xfdesktop)
ICON_FILE=$(ls -t ~/.config/xfce4/desktop | grep screen | head -1)
cp ~/.config/xfce4/desktop/icon.layout.$(($NEW_WORKSPACE-1)) ~/.config/xfce4/desktop/$ICON_FILE
kill -HUP $(pidof xfdesktop)
# Save the new current workspace
CURRENT_WORKSPACE=$NEW_WORKSPACE
fi
# restart xfdesktop if it dies
pgrep xfdesktop || xfdesktop &
done
# can't create lockfile - notify user and quit
else
echo "xfdeskiconsDEBUG: Lock failed, check for existing process and/or lock file and delete - exiting." >&2
exit 1
fi
exit 0
The panel switching script:
#!/bin/bash
# The Poor Man's Panel Switcher solution
# Requires: wmctrl
# Make sure you edit the PANEL configuration parameters to suit.
# debug mode = bash -xv /path/to/psw 2>&1 | tee wspm.log
# make sure that only one instance of this script is running
lockfile=/tmp/.psw.lockfile
if ( set -o noclobber; echo "locked" > "$lockfile") 2> /dev/null; then
trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
echo "pswDEBUG: Locking succeeded" >&2
######### PANEL CONFIGURATION: EDIT THESE VALUES ######################################################
###
### WORKSPACE[x]=Panel Number
###
WORKSPACE[1]=2
WORKSPACE[2]=3
WORKSPACE[3]=4
WORKSPACE[4]=5
WORKSPACE[5]=6
WORKSPACE[6]=7
WORKSPACE[7]=8
WORKSPACE[8]=9
WORKSPACE[9]=10
WORKSPACE[10]=11
WORKSPACE[11]=12
WORKSPACE[12]=13
WORKSPACE[13]=14
WORKSPACE[14]=15
WORKSPACE[15]=16
WORKSPACE[16]=17
WORKSPACE[17]=18
WORKSPACE[18]=19
WORKSPACE[19]=20
WORKSPACE[20]=21
####################################################################################################
######### DO NOT EDIT BELOW #############################################################################
CURRENT_WORKSPACE=$(($(wmctrl -d | grep \* | cut -d' ' -f1)+1))
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/autohide-behavior --create --type int --set 0
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/disable-struts --create --type bool --set false
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/length --create --type int --set 94
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/length-adjust --create --type bool --set false
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/nrows --create --type int --set 1
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/position --create --type string --set "p=3;x=1347;y=392"
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/position-locked --create --type bool --set true
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/size --create --type int --set 28
while true
do
NEW_WORKSPACE=$(($(wmctrl -d | grep \* | cut -d' ' -f1)+1))
if [ $CURRENT_WORKSPACE -ne $NEW_WORKSPACE ]; then
wmctrl -s $((($NEW_WORKSPACE)-1))
# autohide the current workspace panel
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/autohide-behavior --create --type int --set 2
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/disable-struts --create --type bool --set true
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/length --create --type int --set 1
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/length-adjust --create --type bool --set false
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/mode --create --type int --set 1
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/nrows --create --type int --set 1
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/position --create --type string --set "p=4;x=1359;y=754"
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/position-locked --create --type bool --set true
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$CURRENT_WORKSPACE]}/size --create --type int --set 16
# unhide the new workspace panel
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$NEW_WORKSPACE]}/autohide-behavior --create --type int --set 0
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$NEW_WORKSPACE]}/disable-struts --create --type bool --set false
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$NEW_WORKSPACE]}/length --create --type int --set 94
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$NEW_WORKSPACE]}/length-adjust --create --type bool --set false
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$NEW_WORKSPACE]}/nrows --create --type int --set 1
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$NEW_WORKSPACE]}/position --create --type string --set "p=3;x=1347;y=392"
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$NEW_WORKSPACE]}/position-locked --create --type bool --set true
xfconf-query --channel xfce4-panel --property /panels/panel-${WORKSPACE[$NEW_WORKSPACE]}/size --create --type int --set 28
CURRENT_WORKSPACE=$NEW_WORKSPACE
fi
sleep 1
done
rm -f "$lockfile"
else
echo "pswDEBUG: Lock failed - exit" >&2
exit 1
fi
Cheers,
Jason
Offline
Okay. I may have answered my own question here. I think most of the problem stemmed from the fact that the two scripts were not in sync with each other. If the panels get updated before the desktop layout is restored, everything is okay. However, if the inverse happens or if one panel is hidden, then the desktop reloads before the next panel reappears, it seems like you have problems. The only thing I can think of is the momentary shift in screen geometry, due to the hiding of one panel and the unhiding of another panel, causes problems, even though both panels are configured to be the exact same size and configured to be put in the exact same place.
Combining the two scripts ensures that every time you switch workspaces everything is done in the exact same order and, therefore, stays in sync. My only issue now is that if I change workspaces too quickly, I still have the problem of losing my icon layout. For instance (and what seems to happen to me most often) is I drag a window to the side of the screen to have the window auto-sized and accidentally hold it for too long, resulting in a move to another workspace. This causes problems, probably because the script gets interrupted before it has a chance to finish completely. Just speculation though.
I can only think of two fixes for this: 1) Disable the window dragging feature. If I can figure out how to do this, it will work fine for me; or, 2) somehow force a delay of say 2-3 seconds between workspace changes, giving the script enough time to fully execute. Are either one of these fixes programmatically feasible?
Update: Upon further investigation, it also seems as though there is an issue with icon placement any time you move to a workspace where certain windows (or maybe all windows?) are visible (not minimized). Any ideas here?
Jason
Last edited by hebrews2124 (2019-11-15 05:08:37)
Offline
I think you've nailed the issue on the head. The geometry of the workspace determines the icon layout - and auto-hiding panels change the available geometry.
There is no way to delay the workspace change, but you can disable the window dragging to another workspace via Settings Manager > Window Manager > Advanced Tab > Wrap workspaces when reaching the screen edge (with a dragged window)
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
[ Generated in 0.012 seconds, 7 queries executed - Memory usage: 662.78 KiB (Peak: 695.63 KiB) ]