Xfce Forum

Sub domains
 

You are not logged in.

#1 2017-04-10 22:28:57

gwhitney
Member
Registered: 2017-04-10
Posts: 2

xfdashboard can (almost) emulate macOS ⌘-Tab

Background: I recently got a new laptop running openSUSE (Tumbleweed), with a hidpi screen. I prefer to turn the hidpi scaling off and then adjust various system font sizes, etc., to make them readable. However when I did this on the default Gnome desktop, I found that some programs had huge text on their titlebars and others had just the size text I wanted, and I could not predict which would be which nor could I find a solution to the problem. So I decided to jettison the complexity of the Gnome desktop and try xfce. Since then I have been setting up xfce to be comfortable to use, which has been a reasonably positive experience. One feature I like from my prior macOS experiences is the way Command-Tab allows you to easily switch between applications (the built-in graphical window cycler in xfce is perfectly nice but as far as I can tell it always shows each individual window and when I happen to have a dozen terminals or emacs windows open, I don't want to have a dozen items to scroll past.) So:

Method: Install xfdashboard and set it to run as a daemon on startup. Use Keyboard settings to bind your favorite key as an application shortcut for

xfdashboard -t

I used Ctrl-` (aka Ctrl-grave); you will see why in a moment. In xfdashboard settings, under General > Switch to view when resumed, select "Do Nothing." Copy the default xfdashboard bindings file (likely found in /usr/share/xfdashboard/bindings.xml) and add lines like these:

  <key code="<Ctrl>-Tab" source="XfdashboardFocusable" when="released">selection-move-down</key>
  <key code="<Ctrl>-1" source="XfdashboardQuicklaunch" when="released">selection-move-up</key>
  <key code="Control_L" source="XfdashboardQuicklaunch" when="released">selection-activate</key>

into the <bindings> section. Make sure you restart xfdashboard. Open the dashboard in the usual way one time and set its focus to the quicklaunch bar, then leave xfdashboard via the Escape key.

Outcome: Now when you press control, and then press and release the ` (grave) key, leaving the control key pressed, the dashboard will come up and (presuming that quicklaunch was previously selected) quicklaunch will have focus. Keeping one finger on the control key, you can use Tab and 1 with another finger to move down and up the column of application icons. When you're on the one you want, just release all keys and you will switch to it. Repeat the process next time you want to switch applications. Sweet.

One nit: (and a workaround) It's annoying that this doesn't Just Work(tm) the first time right after log in, becaue xfdashboard focuses the search bar by default. I have worked around this by installing xdotool and adding the following command as a startup application:

sh -c 'xdotool search --sync --name xfdashboard && xfdashboard -t && sleep 0.5 && xdotool key Page_Up && xdotool key Escape' 

combined with the additional binding

 <key code="Page_Up" source="XfdashboardFocusable" target="XfdashboardFocusManager" when="released">focus-move-previous</key>

(replacing the existing Page_Up binding, which I never used). Briefly, the command tells a shell to run the following sequence of commands, waiting to run each one until the previous has succeeded: call xdotool to wait until it finds an xfdashboard window, switch to the dashboard, wait a half second for it to come up, simulate the Page_Up key (to move the focus to the element previous to the search bar, which is the quicklaunch), and finally simulate the escape key to exit the dashboard.  Now it is primed for use as a command-tab replacement. Note that even if you pop up the dashboard in another way (say, hot corners) and use the workspace switcher with mouse only to change workspaces, that does not disturb the dashboard's keyboard focus, so it will continue to work for quick application switching. Note I have posted a feature request at https://github.com/gmc-holle/xfdashboard/issues to make the initial/resume focus of xfdashboard configurable so that this little problem can simply be avoided.

More nits: (that I would love your help/suggestions on fixing)

  1. It would be nice to use the same key to navigate the list of application icons as was originally used to invoke xfdashboard. But using the application shortcut mechanism means that key is grabbed even while xfdashboard is active, so keeping control down and re-pressing ` (in my case) just toggles the dashboard back off. A possible workaround would be a command-line option for xfdashboard which means "resume xfdashboard if it is suspended, but if it is running, execute a specified action." That shouldn't be too hard to add, so I might do that at some point, presuming it gets the author's blessing, but if anyone has a cleaner/simpler suggested way to accomplish this, I would love to hear.

  2. It would be nice to be able to use the "Windows" key for the activator instead of "Ctrl." The only reason I didn't is that I could not get xfdashboard keybindings with that modifier key to work in xfdashboard at all. I tried both <Super>-1 and <Mod4>-1 as key specifiers, for example, and neither worked, even though Emacs for example reports Windows-1 as "Super-1" and xev shows the keystroke Windows-1 as delivering a keypress of 1 with state 0x40 which should correspond to Mod4. Any thoughts/ideas on this?

  3. Some running programs, like xfce4-settings-manager, just don't show up in the quicklaunch area. Anyone know why and/or how to get the quicklaunch to be more inclusive?

  4. Of course, Command-Tab on macOS reorders the application list so that on the next invocation, the previous app is the first one one you switch to on the list. That's a good feature; any thoughts on doing something similar in this setup? I think that the following might work: if there were a favourite-reorder-first action, and I could always invoke that action before selection-activate, it might do the trick. Any other suggestions/thoughts?

  5. It would be nice for the quick launch bar to be horizontal. I wasn't ready to launch into a wholesale rewrite of the theme layout to accomplish that, but if anyone has a horizontal theme for xfdashboard I would love to hear.

Hope this was of interest, glad to hear any feedback.

Offline

#2 2017-05-04 23:06:07

gwhitney
Member
Registered: 2017-04-10
Posts: 2

Re: xfdashboard can (almost) emulate macOS ⌘-Tab

Update to some of the points above:
The first nit (under the heading "One nit:") has been eliminated altogether in the latest git head version of xfdashboard. You can just change the line

<focus ref="quicklaunch" />

to

<focus ref="quicklaunch" selected="true" />

in the layout .xml file of the theme you are using and the quicklaunch will be focused on startup, no need to mess with xdotool, etc.

As for the "More nits:"

1) By binding command-tab to the following tiny script:
#!/bin/sh
xfdashboard
xdotool key Down

I can now use the same key to invoke xfdashboard and move the selected app forward, since if xfdashboard is already active, calling it again has no effect, and then I simulate the Down key to move the selected app forward. It still works a little bit unreliably, maybe there's a race condition between the xfdashboard activating and the simulated keystroke, so it would still be better to have a command-line option to xfdashboard to execute an action.

2) I got the "Windows" key working as well. The correct modifier was indeed <Mod4>, and the other issue is that sometimes putting actions on when="released" does not work, so if you put a binding that does not seem to take, make sure to try when="pressed" as well.

Points 3, 4, and 5 remain.

Offline

Board footer

Powered by FluxBB