12

I had asked another question which is related. I know that I can invoke lg (looking glass) via the gnome-shell "run application" window (by pressing Alt+F2). What I'd like to know is how to do this from a command line?

For example, if I wanted to pop up the looking glass from a shell script, how would I do it?

(my other question)

TheGeeko61
  • 761
  • 1
  • 10
  • 27
  • Is this the same Looking Glass that [java](http://en.wikipedia.org/wiki/Project_Looking_Glass) did? – Alvar May 30 '12 at 10:49
  • @Alvar No, this one is referring to the [gnome-shell's looking glass](https://live.gnome.org/GnomeShell/LookingGlass). – jokerdino May 31 '12 at 05:46

3 Answers3

9

You can use the following command to launch looking glass from a terminal or keyboard shortcut:

gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'Main.lookingGlass.toggle();'

When you get in DE, you can't use keyboard shortcut to run "looking glass", you have to use ALT+F2 to run it at first time.

Flyk
  • 1,480
  • 3
  • 18
  • 24
darkxst
  • 101
  • 1
  • 3
  • This does nothing for me except return `(false, 'TypeError: Main.lookingGlass is null')` Is that expected? – Cerin Apr 07 '21 at 23:42
  • On dbus version 1.12.20 and GNOME Shell 40.4 I can eval with this command: `dbus-send --session --dest=org.gnome.Shell --print-reply --type=method_call /org/gnome/Shell org.gnome.Shell.Eval string:'Main.lookingGlass.toggle();'` – fzbd Sep 06 '21 at 13:17
  • As of gnome-shell 42.0, neither the `gdbus call` nor `dbus-send` approaches seem to be working. Both respond with `(false, "")` to all lookingglass commands. – cha Apr 10 '22 at 18:59
  • 1
    This appears to be due to new restrictions on `Eval`, which require running in a special "unsafe mode". – cha Apr 10 '22 at 19:23
2

Looking glass is built into gnome-shell and the command for looking glass is lg

Currently it can be run from gome shell by typing Alt+F2 and then typing lg in the dialog box.

I will see of I can find a better solution.

Panther
  • 100,877
  • 19
  • 193
  • 283
  • By command line, Op is talking about the terminal, not keyboard shortcuts in the Gnome UI. I'm also interested in this question because in some environments, you can't press the alt key, like in VNC, without triggering the same behavior in the host's Gnome desktop. – Cerin Apr 07 '21 at 23:44
1

I don't have enough rep to comment; cha's comment explains that the dbus methods don't work out of the box anymore; dbus calls to gnome shell don't work under Ubuntu 22.04 has a non-ideal solution that works without restarting anything or loading plugins.

tabbie
  • 21
  • 2
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/1245575) – Pilot6 Aug 26 '22 at 06:32