Not sure if this is an appropriate question for this site, since it's not really specific to Ubuntu. Those who feel it isn't should probably respond to my crosspost on the Unix and Linux stackexchange site. Sorry for any confusion, I'm still negotiating the borderlines between these sites (and superuser.com, where I also crossposted). I guess we all are.
I make heavy use of workspaces, and have a lot of them (a 6x4 grid). I usually run openbox, but am currently using a machine that doesn't have openbox set up, so I'm using xfce because it's already mostly configured to my liking. I've gotten used to getting visual feedback when I switch workspaces, showing me which one I've just moved to, and am finding myself a bit disoriented in xfce. In openbox this is a big heads-up display, which is pretty much ideal. I'm aware that the workspace switcher panel applet will highlight the active workspace, but this only seems to work for workspaces which have some desktop space showing; since I generally have all my windows maximized, this isn't super helpful.
Is there a way to enable visual feedback showing the new workspace when switching workspaces in xfce?
I wrote a small code that shows a notification on workspace switch action. This code requires libnotify and libwnck
To compile it use the command:
If you found compiling errors with above command, try this one:
To test it from a terminal: ./wsnd
Include it as XFCE startup application: In XFCE you need to add it as startup applicaion on settings-manager->session and startup -> Application Autostart
The code:
I've modified Isaac Pessoa's answer for my own preferences. Instead of showing a notification on workspace changed, this briefly shows a hidden Xfce panel with the workspace switcher widget.
Here's what it looks like while switching workspaces:
Save this file as wschanged.c:
Now create a new Xfce panel anywhere on the edge of your screen and set it to auto-hide. Add the workspace switcher widget. Make a note of the panel number as displayed in the drop-down menu of the panel preferences window.
Make a .workspace-changed file in your home directory, replacing < P_NUMBER > with the panel number that you just created. Make sure this file is executable! (chmod +x .workspace-changed)
Now compile with:
Test it in your terminal (./wschanged) to make sure everything looks right. When satisfied, add the program as an Xfce startup application: Settings -> Session and Startup -> Application Autostart.
Most of the answers are 5 years old and as of xubuntu 18.04 don't work anymore. I've put together an updated version of zspotter's answer that runs on 18.04. For simplicity I'll assume that all files are located in the home directory, you can easily adapt the scripts to a different folder.
First create a file called wschanged.c with this contents:
Second, create a new Xfce panel anywhere on the edge of your screen and set it to auto-hide. Add the workspace switcher widget. Make a note of the panel number as displayed in the drop-down menu of the panel preferences window, in our example the panel number is 2, adjust accordingly.
Third, here things start to get different, create another script in the same folder called wschanged.sh with this contents (remember to set it as executable with rightclick -> properties-> set as executable, or
chmod +x .wschanged.sh
in a terminal):The panels no longer have an autohide property but an autohide-behavior property and thus the adjustments in the script.
Fourth, we have to compile the .c file, the commands in previous answers don't work anymore, as suggested here use:
If you get an error install libwnck-3-dev with
sudo apt install libwnck-3-dev
.You can now test the script with
./wschanged
(place yourself in the same directory as the executable). You can also now set to run the command at startup.The only thing I can think of is to use separate wallpapers (I believe this is possible, but I cannot confirm as I don't use xfce every day) for each desktop. If you don't mind using compiz, you can configure it work much like xfwm, and installing the workspace namer plugin, which allows you to have names for each workspace displayed when you switch.
You could install conky
save this to a file...
run it in Xfce. (terminal) -> with conky -c /path/to/file &
icon/launcher conky -c /path/to/file
Everytime you switch desktops, the number of the desktop will be on the screen.
the "alignment bm" value controls desktop placement. bm is bottom-middle.
See http://conky.sourceforge.net/docs.html for DOCs.
I have made a slight modification to the conky script above
It will allow for transparency for the numbers under XFCE and also you can modify the font size. It also uses the correct variable to display the workspace identity
This is exactly what I was looking for. Thank you, Isaac Pessoa and zspotter! I'm using Xfce on Arch, and in the spirit of keeping it minimal, I didn't want to resort to installing Compiz.
I'm not sure if this would or has happened to anyone else, but I noticed something pretty strange: The panel I set up to be the workspace indicator was configured to show 3 rows (I have 9 desktops). It was set to be about the same size as what you'd get in Ubuntu (about 3x6 inches). However, it would only show one row until I right-clicked the panel and selected properties (which, to be clear, was to display the properties window of the workspace-switcher). The fix was to remove the workspace-switcher that was on another panel.
Also, in order to change how long the workspace-indicator panel displays before it autohides again, you'll need to add this to your .gtkrc-2.0 file:
Found here
In my case, since I'm on Arch, the gtkrc-2.0 file doesn't exist. I had to add that to the gtkrc file in my ~/.themes/[theme name here] directory.
Change the popup-delay and popdown-delay to your liking. For some strange reason, I had to set the values at about half of what I wanted them to be. Probably has something to do with wschanged executing the script.
If you want to place a panel in the middle of your screen showing a grid of workspaces, (similar to Ubuntu) you'll need to set that panel's alpha (under the appearance tab in the panel preferences) all the way down. That way you won't see a small bar on top of all your windows. Setting the autohide-size value to 1 will make it almost impossible for that panel to show by accident.
One last thing: if the cursor happens to be on top of the panel when you're switching workspaces, it will randomly show a tool tip and I have to move the cursor off of the panel to get it to hide again. Not a big deal though.
EDIT: I used zspotter's fix for this.
EDIT: I just noticed that scrolling the mouse while focused on the desktop will switch workspaces (using zspotter's fix). Nice!
EDIT: This causes my notification popus (i.e. when using volume keys, etc.) to appear in the wrong place. Specifically, when using the options top-left or top-right, the notifications appear in middle-left or middle-right. I don't have osd-notify installed -- just xfce4-notifyd. Everything in settings appeared to be correct. When I removed the panel and took wschanged off the applications auto-start list, problem was corrected..
I have this little python3 code-blob that reacts to workspace switching.
It's not made to display a notification, but to work around a chromium redraw bug. Anything you want to happen on workspace switch, you can easily throw in to the "fire_the_kludge" function though.
https://github.com/aking1012/chromiumKludge/blob/master/kludge.py
Here's a reworked example that uses libnotify2 to tell you your workspace:
Perfect. Thank you, dsSTORM, and zspotter and Isaac Pessoa. The answer from dsSTORM functioned here on the first try on xfce over ubuntu 20.04. If you use Ctrl-Alt-Arrows to switch spaces, you may like to keep the switcher panel visible until you release the Alt key. That way you can take as much time as you like to navigate among the workspaces, with feedback, as desired by the op from this question, as long as you hold down the Alt.
Thanks to key.py from https://blog.robertelder.org/detect-keyup-event-linux-terminal we have this code which you can put in wait-until-alt-up.py
Then change your wschanged.sh to:
And do sudo visudo, then add these lines toward the bottom. This keyboard listener must run as root because it "listens" to the raw device.
Now using a huge 6x6 grid and it's beautiful. If you press ctrl-alt-arrow and release the alt very quickly, the script will not see the alt-up, and the grid will stay active. If that happens, just press and release the Alt key again to hide the panel. Thanks to all.
BTW, you can use Settings / Window Manager / Keyboard to setup Ctrl-Alt-Arrows to switch workspaces and Shift-Ctrl-Alt-Arrows to bring your active window with you, or you can run: