Xfce Forum

Sub domains
 

You are not logged in.

#51 2019-01-07 07:50:14

Misko_2083
Member
Registered: 2015-10-13
Posts: 118
Website

Re: How to display icons from existing directory on a Desktop/Workspace

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

Offline

#52 2019-01-07 22:27:13

acme
Member
From: London, England
Registered: 2018-12-30
Posts: 15

Re: How to display icons from existing directory on a Desktop/Workspace

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

#53 2019-01-07 23:34:36

Misko_2083
Member
Registered: 2015-10-13
Posts: 118
Website

Re: How to display icons from existing directory on a Desktop/Workspace

acme wrote:

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.

Offline

#54 2019-01-08 16:37:20

acme
Member
From: London, England
Registered: 2018-12-30
Posts: 15

Re: How to display icons from existing directory on a Desktop/Workspace

Misko:

That works well and is more succinct.

Thanks you,

Alan

Offline

#55 2019-10-01 07:13:57

anlity60
Member
Registered: 2018-11-14
Posts: 6

Re: How to display icons from existing directory on a Desktop/Workspace

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

#56 2019-10-02 02:03:21

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 5,877

Re: How to display icons from existing directory on a Desktop/Workspace

anlity60 wrote:

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.

Offline

#57 2019-10-02 06:39:41

anlity60
Member
Registered: 2018-11-14
Posts: 6

Re: How to display icons from existing directory on a Desktop/Workspace

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

#58 2019-10-02 20:18:29

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 5,877

Re: How to display icons from existing directory on a Desktop/Workspace

anlity60 wrote:

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:

  1. for browsing and office applications

  2. for music and media

  3. 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.

Offline

Board footer

Powered by FluxBB