diff mbox series

[bug#47870,1/2] gnu: polkit-gnome: Add autostart .desktop file.

Message ID 20210418131727.6104-1-mail@brendan.scot
State Accepted
Headers show
Series Autostart polkit-gnome in XFCE | expand

Commit Message

Brendan Tildesley April 18, 2021, 1:17 p.m. UTC
* gnu/packages/polkit.scm (polkit-gnome):
[inputs]: Source a translated .desktop file from Arch Linux.
[arguments]: Install the .desktop file into /etc/autostart and set
OnlyShowIn to XFCE so it will be autostarted only by XFCE.
[description]: Add a note clarifying that this package is currently only
used for XFCE, not GNOME.
---
 gnu/packages/polkit.scm | 39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

Comments

Leo Prikler April 18, 2021, 2:47 p.m. UTC | #1
Hi Brendan,

Am Sonntag, den 18.04.2021, 23:17 +1000 schrieb Brendan Tildesley:
> * gnu/packages/polkit.scm (polkit-gnome):
> [inputs]: Source a translated .desktop file from Arch Linux.
> [arguments]: Install the .desktop file into /etc/autostart and set
> OnlyShowIn to XFCE so it will be autostarted only by XFCE.
> [description]: Add a note clarifying that this package is currently
> only
> used for XFCE, not GNOME.
> ---
>  gnu/packages/polkit.scm | 39 +++++++++++++++++++++++++++++++++++----
>  1 file changed, 35 insertions(+), 4 deletions(-)
> 
> diff --git a/gnu/packages/polkit.scm b/gnu/packages/polkit.scm
> index d868aceec2..1c5173921c 100644
> --- a/gnu/packages/polkit.scm
> +++ b/gnu/packages/polkit.scm
> @@ -6,6 +6,7 @@
>  ;;; Copyright © 2017 Huang Ying <huang.ying.caritas@gmail.com>
>  ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
>  ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
> +;;; Copyright © 2021 Brendan Tildesley <mail@brendan.scot>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -183,12 +184,42 @@ easily with PolicyKit.")
>                  "0sckmcbxyj6sbrnfc5p5lnw27ccghsid6v6wxq09mgxqcd4lk10
> p"))))
>      (build-system gnu-build-system)
>      (inputs `(("gtk+" ,gtk+)
> -              ("polkit" ,polkit)))
> +              ("polkit" ,polkit)
> +              ("desktop-file"
> +               ,(origin
> +                  (method url-fetch)
> +                  (uri
> +                   (string-append
> +                    "
> https://raw.githubusercontent.com/archlinux/svntogit-community/"
> +                    "8963650797cfe0383ef510e9c0492b2cb22a2593/repos/
> community-x86_64/"
> +                    "polkit-gnome-authentication-agent-1.desktop"))
> +                  (sha256
> +                   (base32
> +                    "1rqy8jf01idaqnyrzjaapr7pzx8zg2x9kmw70n1p9cpalhi
> wfx2h"))))))
Instead of sourcing the desktop file from a really obscure location,
would it be possible to express this in terms of `make-desktop-entry-
file'?  This also has the added advantage, that it could be inlined
into the phase.
>      (native-inputs `(("intltool"   ,intltool)
>                       ("pkg-config" ,pkg-config)))
> +    (arguments
> +     `(#:phases
> +       (modify-phases %standard-phases
> +         (add-after 'install 'install-autostart-file
> +           (lambda* (#:key inputs outputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (autostart-dir (string-append out
> "/etc/xdg/autostart"))
> +                    (desktop (string-append
> +                              autostart-dir
> +                              "/polkit-gnome-authentication-agent-
> 1.desktop")))
> +               (mkdir-p autostart-dir)
> +               (copy-file (assoc-ref inputs "desktop-file") desktop)
> +               (substitute* desktop
> +                 (("^Exec=.*")
> +                  (string-append
> +                   "Exec=" out "/libexec/polkit-gnome-
> authentication-agent-1\n"))
> +                 ;; This will mean the agent will only be started in
> XFCE.
> +                 (("^OnlyShowIn=.*") "OnlyShowIn=XFCE;\n"))))))))
See above.
>      (synopsis "Legacy polkit authentication agent for GNOME")
> -    (description "PolicyKit-gnome provides a D-Bus session bus
> service
> -that is used to bring up authentication dialogs used for obtaining
> -privileges.")
> +    (description "PolicyKit-gnome provides a D-Bus session bus
> service that
> +is used to bring up authentication dialogs used for obtaining
> privileges.
> +PolicyKit-gnome is no longer used in GNOME but has become the
> default agent
> +for XFCE.")
Is that so?  Even if this holds for GNOME 40, it's not true for Guix'
GNOME until wip-gnome is merged, or does 3.34 already use something
else?
>      (home-page "https://www.freedesktop.org/wiki/Software/polkit/")
>      (license lgpl2.0+)))

Regards,
Leo
Brendan Tildesley April 18, 2021, 3:15 p.m. UTC | #2
> On 04/18/2021 4:47 PM Leo Prikler <leo.prikler@student.tugraz.at> wrote:
> 
>  
> Hi Brendan,
> 
[...]
> Instead of sourcing the desktop file from a really obscure location,
> would it be possible to express this in terms of `make-desktop-entry-
> file'?  This also has the added advantage, that it could be inlined
> into the phase.

I did this because the file has many translations, so it would be a lot
of lines: https://raw.githubusercontent.com/archlinux/svntogit-community/packages/polkit-gnome/trunk/polkit-gnome-authentication-agent-1.desktop
I was just trying to source it so translations weren't duplicated.

[...]
> > +PolicyKit-gnome is no longer used in GNOME but has become the
> > default agent
> > +for XFCE.")
> Is that so?  Even if this holds for GNOME 40, it's not true for Guix'
> GNOME until wip-gnome is merged, or does 3.34 already use something
> else?
It's much older than that. I think it was used for Gnome 2 and long since 
discarded. The release is years old and the repo untouched for 3 years.

On second thought perhaps another option is just to use the MATE polkit
agent instead? I tested it for changing network manager and it worked
just the same, only the GUI looks slightly different. I was searching
 What do you think?
Leo Prikler April 18, 2021, 3:52 p.m. UTC | #3
Hi,

Am Sonntag, den 18.04.2021, 17:15 +0200 schrieb Brendan Tildesley:
> > On 04/18/2021 4:47 PM Leo Prikler <leo.prikler@student.tugraz.at>
> > wrote:
> > 
> >  
> > Hi Brendan,
> > 
> [...]
> > Instead of sourcing the desktop file from a really obscure
> > location,
> > would it be possible to express this in terms of `make-desktop-
> > entry-
> > file'?  This also has the added advantage, that it could be inlined
> > into the phase.
> 
> I did this because the file has many translations, so it would be a
> lot
> of lines: 
> https://raw.githubusercontent.com/archlinux/svntogit-community/packages/polkit-gnome/trunk/polkit-gnome-authentication-agent-1.desktop
> I was just trying to source it so translations weren't duplicated.
> 
> [...]
I still think we'd prefer to keep our own copy.  If not as code, then
perhaps as aux-file?

> > > +PolicyKit-gnome is no longer used in GNOME but has become the
> > > default agent
> > > +for XFCE.")
> > Is that so?  Even if this holds for GNOME 40, it's not true for
> > Guix'
> > GNOME until wip-gnome is merged, or does 3.34 already use something
> > else?
> It's much older than that. I think it was used for Gnome 2 and long
> since 
> discarded. The release is years old and the repo untouched for 3
> years.
Ah, thanks for clearing that up.
> On second thought perhaps another option is just to use the MATE
> polkit
> agent instead? I tested it for changing network manager and it worked
> just the same, only the GUI looks slightly different. I was searching
>  What do you think?
If it works for XFCE, why not?  Given that polkit-gnome has no
dependents other than itself, should we perhaps also look into removing
it?

Regards,
Leo
diff mbox series

Patch

diff --git a/gnu/packages/polkit.scm b/gnu/packages/polkit.scm
index d868aceec2..1c5173921c 100644
--- a/gnu/packages/polkit.scm
+++ b/gnu/packages/polkit.scm
@@ -6,6 +6,7 @@ 
 ;;; Copyright © 2017 Huang Ying <huang.ying.caritas@gmail.com>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2021 Brendan Tildesley <mail@brendan.scot>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -183,12 +184,42 @@  easily with PolicyKit.")
                 "0sckmcbxyj6sbrnfc5p5lnw27ccghsid6v6wxq09mgxqcd4lk10p"))))
     (build-system gnu-build-system)
     (inputs `(("gtk+" ,gtk+)
-              ("polkit" ,polkit)))
+              ("polkit" ,polkit)
+              ("desktop-file"
+               ,(origin
+                  (method url-fetch)
+                  (uri
+                   (string-append
+                    "https://raw.githubusercontent.com/archlinux/svntogit-community/"
+                    "8963650797cfe0383ef510e9c0492b2cb22a2593/repos/community-x86_64/"
+                    "polkit-gnome-authentication-agent-1.desktop"))
+                  (sha256
+                   (base32
+                    "1rqy8jf01idaqnyrzjaapr7pzx8zg2x9kmw70n1p9cpalhiwfx2h"))))))
     (native-inputs `(("intltool"   ,intltool)
                      ("pkg-config" ,pkg-config)))
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'install-autostart-file
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (autostart-dir (string-append out "/etc/xdg/autostart"))
+                    (desktop (string-append
+                              autostart-dir
+                              "/polkit-gnome-authentication-agent-1.desktop")))
+               (mkdir-p autostart-dir)
+               (copy-file (assoc-ref inputs "desktop-file") desktop)
+               (substitute* desktop
+                 (("^Exec=.*")
+                  (string-append
+                   "Exec=" out "/libexec/polkit-gnome-authentication-agent-1\n"))
+                 ;; This will mean the agent will only be started in XFCE.
+                 (("^OnlyShowIn=.*") "OnlyShowIn=XFCE;\n"))))))))
     (synopsis "Legacy polkit authentication agent for GNOME")
-    (description "PolicyKit-gnome provides a D-Bus session bus service
-that is used to bring up authentication dialogs used for obtaining
-privileges.")
+    (description "PolicyKit-gnome provides a D-Bus session bus service that
+is used to bring up authentication dialogs used for obtaining privileges.
+PolicyKit-gnome is no longer used in GNOME but has become the default agent
+for XFCE.")
     (home-page "https://www.freedesktop.org/wiki/Software/polkit/")
     (license lgpl2.0+)))