Adding run dialog and terminal to domains trayapp

33 views
Skip to first unread message

Davíð Steinn Geirsson

unread,
Mar 25, 2018, 6:48:48 PM3/25/18
to qubes...@googlegroups.com
Hi,

One thing I would really like is a way to invoke a run dialog through the
domains tray. It would be especially useful for dispvms, which don't really
provide any way to run additional commands after startup beyond 'qvm-run'
in a dom0 shell.

I would like to implement this. I've already extended the dbus interface
in qubesdbus/models.py to expose the vm.run() method. Adding a menu
item for the tray application looks easy. But as far as I can see there
is no run dialog/application launcher I can count on being installed
in all templates.

Does anyone know if there is such a thing already installed on the current
templates? If not, would it be acceptable to add for example gmrun to the
template default packages? Suggestions for a better launcher also
appreciated, though ideally with minimal dependencies.


'Run terminal' would also be a very handy menu item. But it has the same
problem - we don't know the users installed terminal emulators, though
gnome-terminal seems to be included both on debian and fedora templates.
Would it be acceptable to hardcode a dependency on that?

Is there a better way to launch the users preferred terminal? On debian
I would use /etc/alternatives/x-terminal-emulator but it seems fedora
doesn't use alternatives for this.

I would very strongly prefer not to have to look for installed terminal
emulators as part of the launching process.

Best regards,
DavМП

Marek Marczykowski-Górecki

unread,
Mar 26, 2018, 1:17:46 PM3/26/18
to Davíð Steinn Geirsson, qubes...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Sun, Mar 25, 2018 at 10:48:44PM +0000, Davíð Steinn Geirsson wrote:
> Hi,
>
> One thing I would really like is a way to invoke a run dialog through the
> domains tray. It would be especially useful for dispvms, which don't really
> provide any way to run additional commands after startup beyond 'qvm-run'
> in a dom0 shell.
>
> I would like to implement this. I've already extended the dbus interface
> in qubesdbus/models.py to expose the vm.run() method.

vm.run() (and qvm-run with just a command) use qubes.VMShell service,
which should be used as a last resort (generally we plan to limit access
to this service as much as possible, because it gives full control over
the VM). For starting an application there is qubes.StartApp, with
argument being a name of .desktop file in /usr/share/applications
(without actual .desktop extension). Check menu entries for example
usage. Note that some applications have different .desktop filename than
actual executable - for example gnome-terminal has org.gnome.Terminal.

> Adding a menu
> item for the tray application looks easy. But as far as I can see there
> is no run dialog/application launcher I can count on being installed
> in all templates.
>
> Does anyone know if there is such a thing already installed on the current
> templates? If not, would it be acceptable to add for example gmrun to the
> template default packages? Suggestions for a better launcher also
> appreciated, though ideally with minimal dependencies.

The most universal thing to do, would be to ask for the command still in
dom0. But you wont get command completion and such features.

> 'Run terminal' would also be a very handy menu item. But it has the same
> problem - we don't know the users installed terminal emulators, though
> gnome-terminal seems to be included both on debian and fedora templates.
> Would it be acceptable to hardcode a dependency on that?

Very similar problem is solved here:
https://github.com/QubesOS/qubes-desktop-linux-i3/blob/master/i3-settings-qubes/qubes-i3-sensible-terminal

IMO putting gnome-terminal earlier in that list makes sense. Note that
minimal templates don't have it - AFAIR only xterm is available there.
But this is not the best possible solution...

Also, related:
https://github.com/QubesOS/qubes-issues/issues/2706

> Is there a better way to launch the users preferred terminal? On debian
> I would use /etc/alternatives/x-terminal-emulator but it seems fedora
> doesn't use alternatives for this.

I don't think Fedora have something like this.

Another option (in addition to the above guessing/hardcoded default?)
would be to use "features" introduced in Qubes 4.0. This is basically
arbitrary key-value store associated with a VM. You can use it to set
preferred terminal application per-VM. And there is a function to get a
value for a VM, and fallback to a value on its template (if not set for
the VM).

Usage:

- From command line: qvm-features tool.

[marmarek@dom0 ~]$ qvm-features personal
[marmarek@dom0 ~]$ qvm-features personal preferred-terminal
[marmarek@dom0 ~]$ qvm-features personal preferred-terminal gnome-terminal
[marmarek@dom0 ~]$ qvm-features personal preferred-terminal
gnome-terminal
[marmarek@dom0 ~]$ qvm-features personal
preferred-terminal gnome-terminal

- From python:
https://dev.qubes-os.org/projects/core-admin-client/en/latest/qubesadmin.html#module-qubesadmin.features

Usage:

>>> import qubesadmin
>>> q = qubesadmin.Qubes()
>>> personal = q.domains['personal']

Get feature:

>>> personal.features['preferred-terminal']
'gnome-terminal'

Unset:

>>> del personal.features['preferred-terminal']

Getting feature when not set will get you exception (as any dict in
python)...

>>> personal.features['preferred-terminal']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/site-packages/qubesadmin/features.py", line 55, in __getitem__
self.vm.name, 'admin.vm.feature.Get', item).decode('utf-8')
File "/usr/lib/python3.5/site-packages/qubesadmin/base.py", line 68, in qubesd_call
payload_stream)
File "/usr/lib/python3.5/site-packages/qubesadmin/app.py", line 483, in qubesd_call
return self._parse_qubesd_response(return_data)
File "/usr/lib/python3.5/site-packages/qubesadmin/base.py", line 102, in _parse_qubesd_response
raise exc_class(format_string, *args)
qubesadmin.exc.QubesFeatureNotFoundError: "'Feature not set for domain personal: preferred-terminal'"

...unless you use 'get' and provide default value:

>>> personal.features.get('preferred-terminal', 'xterm')
'xterm'

Getting value, with fallback to the one on template (not available from
command line):

>>> f_tpl = q.domains['fedora-26']
>>> f_tpl.features['preferred-terminal'] = 'gnome-terminal'
>>> personal.features.check_with_template('preferred-terminal', 'xterm')
'gnome-terminal'

- --
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEhrpukzGPukRmQqkK24/THMrX1ywFAlqvI8YACgkQ24/THMrX
1ywpQQgAhWIOQdtVLJQclHt7WDbFPzyDkKgRetDH/8O9jCmy8vyMK+IFAJRp7vpu
62biv4lVeiOH7DJ3KWossP3AknYGu5DCHd6/AJFTZ+Afk3qAyqYZvQSmw7rJ4bKY
b0uZsXjSkYYZvvJYxSl4iSrT42EoiwjY4zduWUkLKGjHaWt2i0wm2PS+ZJL4+Jz3
Mrm64pAYptjzfOlXlflj8pJw8XCVCf8N8PheKRpyc5hJHQSc3ml1QxYvxWHmotmT
LL9//4DRwGVKxVXAx6TLmtrjJGFrwnHnHmzN1E9/b0kpUrBGL4bG6DB9snUx+7sP
nAS/nQRaxqw9Sra8LGC3wy5gy3lSAw==
=y9XI
-----END PGP SIGNATURE-----

Davíð Steinn Geirsson

unread,
Mar 28, 2018, 9:49:12 AM3/28/18
to Marek Marczykowski-Górecki, qubes...@googlegroups.com
On Mon, Mar 26, 2018 at 07:17:36PM +0200, Marek Marczykowski-Górecki wrote:
> On Sun, Mar 25, 2018 at 10:48:44PM +0000, Davíð Steinn Geirsson wrote:
> > Hi,
> >
> > One thing I would really like is a way to invoke a run dialog through the
> > domains tray. It would be especially useful for dispvms, which don't really
> > provide any way to run additional commands after startup beyond 'qvm-run'
> > in a dom0 shell.
> >
> > I would like to implement this. I've already extended the dbus interface
> > in qubesdbus/models.py to expose the vm.run() method.
>
> vm.run() (and qvm-run with just a command) use qubes.VMShell service,
> which should be used as a last resort (generally we plan to limit access
> to this service as much as possible, because it gives full control over
> the VM). For starting an application there is qubes.StartApp, with
> argument being a name of .desktop file in /usr/share/applications
> (without actual .desktop extension). Check menu entries for example
> usage. Note that some applications have different .desktop filename than
> actual executable - for example gnome-terminal has org.gnome.Terminal.

Thanks, I changed my patches to expose RunService instead, and used
qubes.StartApp in the dialog.

>
> > Adding a menu
> > item for the tray application looks easy. But as far as I can see there
> > is no run dialog/application launcher I can count on being installed
> > in all templates.
> >
> > Does anyone know if there is such a thing already installed on the current
> > templates? If not, would it be acceptable to add for example gmrun to the
> > template default packages? Suggestions for a better launcher also
> > appreciated, though ideally with minimal dependencies.
>
> The most universal thing to do, would be to ask for the command still in
> dom0. But you wont get command completion and such features.

That was my thinking, command completion would be handy. However after
further thought I don't really have any use case for the run menuentry if
I have a "Run Terminal" one. So I just made do with that.

>
> > 'Run terminal' would also be a very handy menu item. But it has the same
> > problem - we don't know the users installed terminal emulators, though
> > gnome-terminal seems to be included both on debian and fedora templates.
> > Would it be acceptable to hardcode a dependency on that?
>
> Very similar problem is solved here:
> https://github.com/QubesOS/qubes-desktop-linux-i3/blob/master/i3-settings-qubes/qubes-i3-sensible-terminal
>
> IMO putting gnome-terminal earlier in that list makes sense. Note that
> minimal templates don't have it - AFAIR only xterm is available there.
> But this is not the best possible solution...

Pushed something similar here, to have it independent of the i3 tools:
https://github.com/QubesOS/qubes-core-agent-linux/pull/105

>
> Also, related:
> https://github.com/QubesOS/qubes-issues/issues/2706
>
> > Is there a better way to launch the users preferred terminal? On debian
> > I would use /etc/alternatives/x-terminal-emulator but it seems fedora
> > doesn't use alternatives for this.
>
> I don't think Fedora have something like this.
>
> Another option (in addition to the above guessing/hardcoded default?)
> would be to use "features" introduced in Qubes 4.0. This is basically
> arbitrary key-value store associated with a VM. You can use it to set
> preferred terminal application per-VM. And there is a function to get a
> value for a VM, and fallback to a value on its template (if not set for
> the VM).

Hm, that would work. Though since we can't have any sensible default for
this setting we'd still end up with a shellscript like above looking for
fallbacks if the feature isn't configured or the configured shell doesn't
exist.

As it is now it's easy for the user to specify a preferred shell by either
'update-alternatives --config x-terminal-emulator' (on debian) or just
symlinking their preferred terminal to /usr/local/bin/x-terminal-emulator.
I put that first in the search list.


Links to the pull requests:

https://github.com/QubesOS/qubes-core-agent-linux/pull/105
https://github.com/QubesOS/qubes-desktop-linux-manager/pull/22
https://github.com/QubesOS/qubes-dbus/pull/7


>
> Usage:
>
> From command line: qvm-features tool.
>
> [marmarek@dom0 ~]$ qvm-features personal
> [marmarek@dom0 ~]$ qvm-features personal preferred-terminal
> [marmarek@dom0 ~]$ qvm-features personal preferred-terminal gnome-terminal
> [marmarek@dom0 ~]$ qvm-features personal preferred-terminal
> gnome-terminal
> [marmarek@dom0 ~]$ qvm-features personal
> preferred-terminal gnome-terminal
>
signature.asc
Reply all
Reply to author
Forward
0 new messages