Re: [qubes-users] where/how does dom0 gets its icons? ANSWERED

2019-03-03 Thread Marek Marczykowski-Górecki
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On Sat, Mar 02, 2019 at 05:32:19PM -0600, Daniel Allcock wrote:
> Thank you to unman for giving me the thread to follow.
> The way the icons are chosen could be improved easily.
> I'd be happy to contribute a patch if I knew the procedure
> for doing so.  (It would not touch dom0.)

Happy to hear that!
See here:
https://www.qubes-os.org/doc/source-code/#how-to-send-patches

> To close out the thread, here is the answer to my question.
> The process of updating the Q menus is controlled by dom0's
> /usr/lib/python3.5/site-packages/qubesappmenus/receive.py.
> When updating the Q menus, dom0 first asks the vm for its
> desktop files.  The vm provides these using 
> /etc/qubes-rpc/qubes.GetAppmenus, which is a shell script
> that jumbles all the desktop files on the system
> together and sends to stdout.  dom0 sanitizes and parses this,
> and assembles the results into a bunch of desktop files in
> dom0's ~/.local/share/qubes-appmenus/VM.  As it is doing this
> it notes which icons specified in the desktop files have 
> relative paths (typically, all of them).  For each icon name,
> dom0 asks the vm to run /etc/qubes-rpc/qubes.GetImageRGBA 
> and deliver the resulting icon file to dom0.  For icons
> described by a relative path, the first thing
> this shell script does is resolve the icon name to a file name using 
> /usr/lib/qubes/xdg-icon, which is also a shell script, and is
> where the actual resolution takes place.

Yes, exactly.
The VM side of this is here:
https://github.com/QubesOS/qubes-core-agent-linux/tree/master/qubes-rpc

> This resolution is simplistic.  It uses a fixed list of
> icon theme names (on my system: Humanity, Adwaita, gnome, oxygen),
> followed by any additional icon themes in /usr/share/icons.  
> The first theme that has a suitably named icon is the theme
> whose icon file gets used.  I don't have Humanity installed, so
> I was getting Adwaita icons every time, and overwriting them
> was the only way I could change my icons.
> 
> A simple fix is to insert my desired icon theme at the beginning
> of the fixed list of themes.  This is not the right
> way to solve the problem in general.  To solve it properly would
> require deciding what the right behavior is: should the theme
> used in dom0 (meaning: one of the same name) get used?  Or should the
> theme preferred by that template's user account get used? Not
> sure what the most natural answer is.  But I'm satisfied for now.

I think the logical thing to do, would be to use template's preferred
theme. If desirable, there could could be a mechanism to synchronize it
with dom0 theme.

- -- 
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/THMrX1ywFAlx73fkACgkQ24/THMrX
1ywLBAf+JIaGwRS1JyzWSqc9BLZvKwt/bw8nmSJIjxJi8wohdiZYkTbTRNKF8s0N
6WV4Rud0+hpR9mLHP/zd+vPqoCxrpHJpj8OgzBlvwsJ5epDc5WPecBs/uXjH9u5j
j2kbidAlh/Ho3Xih07irFwKtVj2asTUZt+nZIFoOLez7n/hUhrKzHALOmEMkJ7mD
5dPUbTh0awr5pa+H+NQyvwABJ0ZKmX1lLtkn87DIZoHIx9ug4vuXXEaKr3v7IzVa
ongHCej32hNpfU8We7uOlQYdNnboeA9XISS06efIMabEE2BocKk9C8i3y2v+sJxp
vqZgmQPaLgUGa6YryFCQxeFJY4N2pg==
=xzJo
-END PGP SIGNATURE-

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/20190303140026.GI9610%40mail-itl.
For more options, visit https://groups.google.com/d/optout.


Re: [qubes-users] where/how does dom0 gets its icons? ANSWERED

2019-03-02 Thread Daniel Allcock
Thank you to unman for giving me the thread to follow.
The way the icons are chosen could be improved easily.
I'd be happy to contribute a patch if I knew the procedure
for doing so.  (It would not touch dom0.)

To close out the thread, here is the answer to my question.
The process of updating the Q menus is controlled by dom0's
/usr/lib/python3.5/site-packages/qubesappmenus/receive.py.
When updating the Q menus, dom0 first asks the vm for its
desktop files.  The vm provides these using 
/etc/qubes-rpc/qubes.GetAppmenus, which is a shell script
that jumbles all the desktop files on the system
together and sends to stdout.  dom0 sanitizes and parses this,
and assembles the results into a bunch of desktop files in
dom0's ~/.local/share/qubes-appmenus/VM.  As it is doing this
it notes which icons specified in the desktop files have 
relative paths (typically, all of them).  For each icon name,
dom0 asks the vm to run /etc/qubes-rpc/qubes.GetImageRGBA 
and deliver the resulting icon file to dom0.  For icons
described by a relative path, the first thing
this shell script does is resolve the icon name to a file name using 
/usr/lib/qubes/xdg-icon, which is also a shell script, and is
where the actual resolution takes place.

This resolution is simplistic.  It uses a fixed list of
icon theme names (on my system: Humanity, Adwaita, gnome, oxygen),
followed by any additional icon themes in /usr/share/icons.  
The first theme that has a suitably named icon is the theme
whose icon file gets used.  I don't have Humanity installed, so
I was getting Adwaita icons every time, and overwriting them
was the only way I could change my icons.

A simple fix is to insert my desired icon theme at the beginning
of the fixed list of themes.  This is not the right
way to solve the problem in general.  To solve it properly would
require deciding what the right behavior is: should the theme
used in dom0 (meaning: one of the same name) get used?  Or should the
theme preferred by that template's user account get used? Not
sure what the most natural answer is.  But I'm satisfied for now.

Thank you!
Daniel

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/20190302173219.78fddd83%40allcock.org.
For more options, visit https://groups.google.com/d/optout.


Re: [qubes-users] where/how does dom0 gets its icons?

2019-03-02 Thread unman
On Sat, Mar 02, 2019 at 09:32:38AM -0600, Daniel Allcock wrote:
> Thank you David. It seems, though, to be more complicated than that.
> 
> > On 3/1/19 8:54 PM, Daniel Allcock wrote:
> > > Hello,
> > > I would like to understand what to do to customize the icons
> > > that appear in the Q menu for template and app vms.
> > > The only way I have found that works is to overwrite icon
> > > files in /usr/share/icons/Adwaita/* in the template vm.
> > > chose that icon theme in xfce settings.  Everything just works.  
> > 
> > I don't know about Adwaita or anything, but Qubes OS adheres to the 
> > Freedesktop Standard [1] (I guess version 1.0 though).
> > 
> > So the entire menu incl. icons is managed by *.desktop and *.menu
> > files in dom0. Nothing is imported from within any VM.
> 
> the vm's do communicate their desktop files to dom0, and icons for
> them.  This is what populates the directories in dom0 that produce
> the Q menu.  Whenever you install software in a template vm using
> dnf, it says "notifying dom0 about newly installed applications..."
> Whenever you choose "refresh applications" in Qubes Manager, dom0
> fires up the underlying template and reimports the desktop and icon
> files.
> 
> The basic mechanism in the Freedesktop standard is that that each
> desktop file specifies an icon, eg "Icon=utilities-terminal".
> When it comes time to display an icon, the system looks in the user's
> selected icon theme for a file of that name (perhaps with a
> suffix like .svg or .png).  That icon theme may specify a fallback
> icon theme, where the system will look if it doesn't find an icon
> of that name.  The fallback can have fallbacks, etc, with "hicolor"
> being the icon theme of last resort. (This theme might not appear
> in menus, for example it doesn't appear in xfce's icon theme setting
> screen.  But it is present in /usr/share/icons.)
> 
> The point is that what icons are displayed has two inputs: the icon
> names in the desktop files, and the user's choice of icon theme, which
> maps those icon names to actual image files.  What I would like
> to understand is how qubes handles this.  It resolves the icon
> names to image files in some way, imports the icons to dom0,
> and colorizes them.  How does the resolution work?
> 
> I had two guesses, both
> seemingly reasonable but neither correct. (For each appvm, it might
> use the icon theme setting of the user account in that appvm.  Or,
> dom0 might use the theme in the appvm that has the same name
> as the theme chosen in dom0.)
> 
> At this point my hypothesis is that the
> communication-of-icons-to-dom0 process 
> (1) completely ignores appvms in favor of their underlying templates. 
> (2) completely ignores icon theme settings, just using Adwaita icons
> (from the template vm; it does not use, or perhaps uses at a lower
> priority, the Adwaita icons already present in dom0). 
> 
> Would appreciate any info, even just confirmation of this.
> 
> Thank you,
> Daniel
> 

Hi Daniel,

It's some time since I looked at this, but I had a quick look at the
code. Take any of this with a (large) pinch of salt, but it may help you
to get to the right place.

I think the magic happens in
/usr/lib/python3.5/site-packages/qubesappmenus/receive.py .
This is where the icon directory is created, and icons are picked up
from the templates.(Yes, as you  say, they come from the template).
appmenus in the template are parsed, and the contents written in to
appmenu templates in dom0.

The icon file is read from the desktop file referenced in the template,
and copied to dom0. This is done by a call to imgconverter.
You'll find there a function get_xdg_icon_from_vm which attempts to
copy and sanitise an icon image from the template.

For applications installed in qubes, have a look at:
https://www.qubes-os.org/doc/managing-appvm-shortcuts/

So I think  your hypothesis 1 is correct, and 2 is partly right.

hth

unman

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/20190302161740.bi4kcobu4a3lx37c%40thirdeyesecurity.org.
For more options, visit https://groups.google.com/d/optout.


Re: [qubes-users] where/how does dom0 gets its icons?

2019-03-02 Thread Daniel Allcock
Thank you David. It seems, though, to be more complicated than that.

> On 3/1/19 8:54 PM, Daniel Allcock wrote:
> > Hello,
> > I would like to understand what to do to customize the icons
> > that appear in the Q menu for template and app vms.
> > The only way I have found that works is to overwrite icon
> > files in /usr/share/icons/Adwaita/* in the template vm.
> > chose that icon theme in xfce settings.  Everything just works.  
> 
> I don't know about Adwaita or anything, but Qubes OS adheres to the 
> Freedesktop Standard [1] (I guess version 1.0 though).
> 
> So the entire menu incl. icons is managed by *.desktop and *.menu
> files in dom0. Nothing is imported from within any VM.

the vm's do communicate their desktop files to dom0, and icons for
them.  This is what populates the directories in dom0 that produce
the Q menu.  Whenever you install software in a template vm using
dnf, it says "notifying dom0 about newly installed applications..."
Whenever you choose "refresh applications" in Qubes Manager, dom0
fires up the underlying template and reimports the desktop and icon
files.

The basic mechanism in the Freedesktop standard is that that each
desktop file specifies an icon, eg "Icon=utilities-terminal".
When it comes time to display an icon, the system looks in the user's
selected icon theme for a file of that name (perhaps with a
suffix like .svg or .png).  That icon theme may specify a fallback
icon theme, where the system will look if it doesn't find an icon
of that name.  The fallback can have fallbacks, etc, with "hicolor"
being the icon theme of last resort. (This theme might not appear
in menus, for example it doesn't appear in xfce's icon theme setting
screen.  But it is present in /usr/share/icons.)

The point is that what icons are displayed has two inputs: the icon
names in the desktop files, and the user's choice of icon theme, which
maps those icon names to actual image files.  What I would like
to understand is how qubes handles this.  It resolves the icon
names to image files in some way, imports the icons to dom0,
and colorizes them.  How does the resolution work?

I had two guesses, both
seemingly reasonable but neither correct. (For each appvm, it might
use the icon theme setting of the user account in that appvm.  Or,
dom0 might use the theme in the appvm that has the same name
as the theme chosen in dom0.)

At this point my hypothesis is that the
communication-of-icons-to-dom0 process 
(1) completely ignores appvms in favor of their underlying templates. 
(2) completely ignores icon theme settings, just using Adwaita icons
(from the template vm; it does not use, or perhaps uses at a lower
priority, the Adwaita icons already present in dom0). 

Would appreciate any info, even just confirmation of this.

Thank you,
Daniel

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/20190302093238.1ade4554%40allcock.org.
For more options, visit https://groups.google.com/d/optout.


Re: [qubes-users] where/how does dom0 gets its icons?

2019-03-02 Thread David Hobach

On 3/1/19 8:54 PM, Daniel Allcock wrote:

Hello,
I would like to understand what to do to customize the icons
that appear in the Q menu for template and app vms.
The only way I have found that works is to overwrite icon
files in /usr/share/icons/Adwaita/* in the template vm.

In dom0 it is easy: I put an icon folder Qubes in ~/.icons,
with a custom svg icon for a terminal, named appropriately, and Adwaita
as backup icon theme, ran gtk-update-icon-theme, and then chose that
icon theme in xfce settings.  Everything just works.


I don't know about Adwaita or anything, but Qubes OS adheres to the 
Freedesktop Standard [1] (I guess version 1.0 though).


So the entire menu incl. icons is managed by *.desktop and *.menu files 
in dom0. Nothing is imported from within any VM.


If I recall correctly, the menu structure is managed at 
~/.config/menus/applications-merged/ and the name & icons of the entries 
at ~/.local/share/applications.


The sync you mentioned probably copies files from 
~/.local/share/qubes-appmenus/ to ~/.local/share/applications as you 
reconfigure your menu with e.g. the Qubes manager. I'm not 100% sure 
about that, but you can easily test it.


Hope that helps,
David

[1] https://standards.freedesktop.org/desktop-entry-spec/latest/

--
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/d5d38c19-2157-60d4-7906-9e8137304401%40hackingthe.net.
For more options, visit https://groups.google.com/d/optout.


smime.p7s
Description: S/MIME Cryptographic Signature


[qubes-users] where/how does dom0 gets its icons?

2019-03-01 Thread Daniel Allcock
Hello,
I would like to understand what to do to customize the icons
that appear in the Q menu for template and app vms.
The only way I have found that works is to overwrite icon
files in /usr/share/icons/Adwaita/* in the template vm.

In dom0 it is easy: I put an icon folder Qubes in ~/.icons, 
with a custom svg icon for a terminal, named appropriately, and Adwaita
as backup icon theme, ran gtk-update-icon-theme, and then chose that
icon theme in xfce settings.  Everything just works.

But nothing similar seems to work in a template vm.  I'm using
almost-stock Fedora 29, if that matters.  dom0's qvm-sync-appmenus
seems to be the program that imports the desktop files from vm's
to dom0, and their corresponding icons.  I tried to figure out
how it worked, but failed.  It does not seem to consult any 
sort of icon theme setting in appvm or templatevm. 
It also does not seem to use an icon theme
of the same name "Qubes" I chose in dom0, even if I install such a theme
in the template.  (This would be another 
reasonable behavior.)  Does it just
use Adwaita icons? Also, the man page suggests that qvm-sync-appmenus
looks only at template and standalone vm's. So if we
add a custom application to an appvm, we must add its desktop
file to the Q menu by hand?  (am not sure how to do this in a way
that won't get overwritten.)  When is a lock icon chosen?  What
program does the vm-dependent icon colorization?

I feel I could figure things out if I had a basic understanding of
how the Q menu items and their icons are assembled and imported.
Are there any pointers to explanations of this?

(If anyone is interested in making icons themselves, they are super-easy
to make in inkscape.  Just keep them simple, black/white, or greyscale
with lots of white, and with a clear background.  Lots of white makes
the icon-colorization process give attractive icons that look very
different from the same icons used in other-colored vm's.)

Thank you,
Daniel 

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/20190301135419.6de7dea5%40allcock.org.
For more options, visit https://groups.google.com/d/optout.