13

Is there a way to invoke the Activities view of GNOME from the Linux command line? This is what the Super key invokes from GNOME. Once it is shown, I can interact with it as usual using the mouse.

I'm using Ubuntu 18.04 LTS.

The reason I'm asking: I'm viewing the desktop that I need to "send" the Super key into via a TeamViewer session. TeamViewer has a way to send CTRL-ALT-DELETE, but that of course is for Windows remotes, but this is pure Ubuntu-to-Ubuntu here. Even if TeamViewer was not involved, and I was using VNC, I would have the same problem.

0

3 Answers 3

19

A command that causes the shell to switch to the overview is:

dbus-send --session --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'Main.overview.show();'

Use Main.overview.hide(); to close the overview, or Main.overview.toggle(); to toggle between overview and normal view (with thanks to gatr and Marcelo Avila).

8
  • reverse action would be dbus-send --session --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'Main.overview.hide();'
    – gtatr
    Mar 28, 2019 at 14:13
  • toggle works as well, with: dbus-send --session --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'Main.overview.toggle();'
    – avila
    Nov 20, 2019 at 0:59
  • How about show applications ?
    – Fadly Dzil
    Dec 21, 2019 at 9:06
  • @FadlyDzil, this question is about the activities overview.
    – vanadium
    Dec 21, 2019 at 9:08
  • Is there a way to run this in a BASH script? When I try to do it now, I get an error. Apr 21, 2021 at 14:02
4

There might be a proper command line way to interact with various GNOME Shell components (using DBus, I suppose), but a quick and dirty way is to simulate the keypress:

xdotool key super
4
  • 1
    This one worked. The subsequent answer by vanadium has to be the correct answer because xdotool is not installed by default, and I suspect that dbus-send is installed by default. So I am forced into giving vanadium "the" answer mark. Thanks for your quick response though.
    – bgoodr
    Nov 25, 2018 at 18:13
  • That is also the "fundamental" solution, i.e. directly communicating with the proces through the command line. The xdotool trick would work well, but is a hack - simulating keystrokes. May, moreover, not work for users that use Wayland as their displayserver.
    – vanadium
    Nov 26, 2018 at 9:20
  • @vanadium that's why I called it the "proper" way, but like a lot of GNOME stuff, the proper way is rather obscure.
    – muru
    Nov 26, 2018 at 10:06
  • Underrated comment. It worked and it is also easier.
    – Allexj
    Sep 7, 2020 at 11:16
2

From GNOME 41 onwards you need an extension.

As of GNOME 41, the dbus method Eval() is now restricted with MetaContext:unsafe-mode property (see this commit). This extension provides unrestricted Eval() dbus method for running arbitrary code in the compositor.

(source)

So the solution is:

  1. Install the eval-gjs extension:

  2. Use --object-path /dev/ramottamado/EvalGjs and --method dev.ramottamado.EvalGjs.Eval, like:

     gdbus call \
       --session \
       --dest org.gnome.Shell \
       --object-path /dev/ramottamado/EvalGjs \
       --method dev.ramottamado.EvalGjs.Eval "Main.overview.show();" 
    
2
  • Not yet applicable on this site currently - as Gnome 41 is not yet in Ubuntu, but valuable addition for spring 2021: upvoting!
    – vanadium
    Nov 22, 2021 at 11:57
  • This seems to work with GNOME 42 as well, but you have to edit the metadata.json to change the version number. May 15 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.