diff mbox series

[bug#54434,v2,7/7] gnu: xfce4-session: Load user panel plugins.

Message ID 20220318073844.14290-8-mail@brendan.scot
State New
Headers show
Series XFCE Updates | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Brendan Tildesley March 18, 2022, 7:38 a.m. UTC
From: Brendan Tildesley <mail@brendan.scot>

 gnu/packages/xfce.scm (xfce4-session): [patches]: Add a patch to make
 use of X_XFCE4_LIB_DIRS and load user installed panel plugins. This is
 needed, because xfce is launched from /run/current-system/.... It will
 not otherwise load panel plugin .so's from the users home guix profile.

 gnu/packages/patches/xfce4-session-startxfce-load-user-plugins.patch:
 New file.
 gnu/local.mk: Reference patch file.
---
 gnu/local.mk                                  |  1 +
 ...-session-startxfce-load-user-plugins.patch | 20 +++++++++++++++++++
 gnu/packages/xfce.scm                         |  3 ++-
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/xfce4-session-startxfce-load-user-plugins.patch

Comments

Ludovic Courtès April 3, 2022, 10:33 a.m. UTC | #1
'Brendan Tildesley <mail@brendan.scot> writes:

> From: Brendan Tildesley <mail@brendan.scot>
>
>  gnu/packages/xfce.scm (xfce4-session): [patches]: Add a patch to make
>  use of X_XFCE4_LIB_DIRS and load user installed panel plugins. This is
>  needed, because xfce is launched from /run/current-system/.... It will
>  not otherwise load panel plugin .so's from the users home guix profile.
>
>  gnu/packages/patches/xfce4-session-startxfce-load-user-plugins.patch:
>  New file.
>  gnu/local.mk: Reference patch file.

Looks like leading stars disappeared from the commit log.  :-)

> +++ b/gnu/packages/patches/xfce4-session-startxfce-load-user-plugins.patch
> @@ -0,0 +1,20 @@
> +From a1c94934d211d69f9a2cdf03d64327bcd7cccb41 Mon Sep 17 00:00:00 2001
> +From: Brendan Tildesley <mail@brendan.scot>
> +Date: Thu, 17 Mar 2022 19:49:12 +1100
> +Subject: [PATCH] startxfce4: load plugins from user profile

A single line stating what the patch does would be enough.

> ++++ b/scripts/startxfce4.in
> +@@ -101,6 +101,8 @@ else
> +   prog=/bin/sh
> + fi
> +
> ++    export X_XFCE4_LIB_DIRS="${GUIX_PROFILE:-$HOME/.guix-profile}/lib/xfce4/${X_XFCE4_LIB_DIRS:+:}$X_XFCE4_LIB_DIRS"

There’s extra space at the beginning of the line.

One problem is that this won’t work for those using Guix Home, where the
default profile is ~/.guix-home/profile.

Can this extra variable be avoided?  Or could it be handled by a search
path specification?

I’ve applied the other patches in the meantime.

Thanks!

Ludo’.
Brendan Tildesley April 4, 2022, 2:42 a.m. UTC | #2
On 3/4/22 8:33 pm, Ludovic Courtès wrote:
> [...]
> One problem is that this won’t work for those using Guix Home, where the
> default profile is ~/.guix-home/profile.
>
> Can this extra variable be avoided?  Or could it be handled by a search
> path specification?
It's xfce4-panel that needs the search path to load .so files for panel 
plugins.
xfce4-panel already has the search-path set to load them, but since its 
installed
to the system profile,it does not load the user installed plugins. If 
xfce4-panel
was a user installed package it may work but userswould have to manually 
install it.
So I'm not sure how else to solve it.
> I’ve applied the other patches in the meantime.
>
> Thanks!
>
> Ludo’.
Feng Shu April 4, 2022, 2:56 a.m. UTC | #3
Brendan Tildesley <mail@brendan.scot> writes:

> On 3/4/22 8:33 pm, Ludovic Courtès wrote:
>> [...]
>> One problem is that this won’t work for those using Guix Home, where the
>> default profile is ~/.guix-home/profile.
>>
>> Can this extra variable be avoided?  Or could it be handled by a search
>> path specification?
> It's xfce4-panel that needs the search path to load .so files for
> panel plugins.
> xfce4-panel already has the search-path set to load them, but since
> its installed
> to the system profile,it does not load the user installed plugins. If
> xfce4-panel
> was a user installed package it may work but userswould have to
> manually install it.
> So I'm not sure how else to solve it.

What happen when version of xfce4-panel installed in system profile is
different from installed in home profile?


>> I’ve applied the other patches in the meantime.
>>
>> Thanks!
>>
>> Ludo’.
>
>

--
Brendan Tildesley April 4, 2022, 3:53 a.m. UTC | #4
On 4/4/22 12:56 pm, Feng Shu wrote:
> Brendan Tildesley <mail@brendan.scot> writes:
>
>> On 3/4/22 8:33 pm, Ludovic Courtès wrote:
>>> [...]
>>> One problem is that this won’t work for those using Guix Home, where the
>>> default profile is ~/.guix-home/profile.
>>>
>>> Can this extra variable be avoided?  Or could it be handled by a search
>>> path specification?
>> It's xfce4-panel that needs the search path to load .so files for
>> panel plugins.
>> xfce4-panel already has the search-path set to load them, but since
>> its installed
>> to the system profile,it does not load the user installed plugins. If
>> xfce4-panel
>> was a user installed package it may work but userswould have to
>> manually install it.
>> So I'm not sure how else to solve it.
> What happen when version of xfce4-panel installed in system profile is
> different from installed in home profile?
I think xfce4-panel will be run from $PATH so the system version will
be picked first and the user installed one will be ignored. The search
path will be set but will not work until the user logs out and back in
again, which is not ideal. I'd like a user to be able to install a plugin
and have it appear in the settings menu immediately.
Feng Shu April 4, 2022, 4:59 a.m. UTC | #5
Brendan Tildesley <mail@brendan.scot> writes:

> On 4/4/22 12:56 pm, Feng Shu wrote:
>> Brendan Tildesley <mail@brendan.scot> writes:
>>
>>> On 3/4/22 8:33 pm, Ludovic Courtès wrote:
>>>> [...]
>>>> One problem is that this won’t work for those using Guix Home, where the
>>>> default profile is ~/.guix-home/profile.
>>>>
>>>> Can this extra variable be avoided?  Or could it be handled by a search
>>>> path specification?
>>> It's xfce4-panel that needs the search path to load .so files for
>>> panel plugins.
>>> xfce4-panel already has the search-path set to load them, but since
>>> its installed
>>> to the system profile,it does not load the user installed plugins. If
>>> xfce4-panel
>>> was a user installed package it may work but userswould have to
>>> manually install it.
>>> So I'm not sure how else to solve it.
>> What happen when version of xfce4-panel installed in system profile is
>> different from installed in home profile?
> I think xfce4-panel will be run from $PATH so the system version will
> be picked first and the user installed one will be ignored. The search
> path will be set but will not work until the user logs out and back in
> again, which is not ideal. I'd like a user to be able to install a plugin
> and have it appear in the settings menu immediately.
>

Maybe it will first find xfce.desktop in <user-profile>/share/xsessions,
then in <system-profile>/share/xsessions.


(define* (xinitrc #:key fallback-session)
  "Return a system-wide xinitrc script that starts the specified X session,
which should be passed to this script as the first argument.  If not, the
@var{fallback-session} will be used or, if @var{fallback-session} is false, a
desktop session from the system or user profile will be used."
  (define builder
    #~(begin
        (use-modules (ice-9 match)
                     (ice-9 regex)
                     (ice-9 ftw)
                     (ice-9 rdelim)
                     (srfi srfi-1)
                     (srfi srfi-26))

        (define (close-all-fdes)
          ;; Close all the open file descriptors except 0 to 2.
          (let loop ((fd 3))
            (when (< fd 4096)               ;FIXME: use sysconf + _SC_OPEN_MAX
              (false-if-exception (close-fdes fd))
              (loop (+ 1 fd)))))

        (define (exec-from-login-shell command . args)
          ;; Run COMMAND from a login shell so that it gets to see the same
          ;; environment variables that one gets when logging in on a tty, for
          ;; instance.
          (let* ((pw    (getpw (getuid)))
                 (shell (passwd:shell pw)))
            ;; Close any open file descriptors.  This is all the more
            ;; important that SLiM itself exec's us directly without closing
            ;; its own file descriptors!
            (close-all-fdes)

            ;; The '--login' option is supported at least by Bash and zsh.
            (execl shell shell "--login" "-c"
                   (string-join (cons command args)))))

        (define system-profile
          "/run/current-system/profile")

        (define user-profile
          (and=> (getpw (getuid))
                 (lambda (pw)
                   (string-append (passwd:dir pw) "/.guix-profile"))))

        (define (xsession-command desktop-file)
          ;; Read from DESKTOP-FILE its X session command and return it as a
          ;; list.
          (define exec-regexp
            (make-regexp "^[[:blank:]]*Exec=(.*)$"))

          (call-with-input-file desktop-file
            (lambda (port)
              (let loop ()
                (match (read-line port)
                  ((? eof-object?) #f)
                  ((= (cut regexp-exec exec-regexp <>) result)
                   (if result
                       (string-tokenize (match:substring result 1))
                       (loop))))))))

        (define (find-session profile)
          ;; Return an X session command from PROFILE or #f if none was found.
          (let ((directory (string-append profile "/share/xsessions")))
            (match (scandir directory
                            (cut string-suffix? ".desktop" <>))
              ((or () #f)
               #f)
              ((sessions ...)
               (any xsession-command
                    (map (cut string-append directory "/" <>)
                         sessions))))))

        (let* ((home          (getenv "HOME"))
               (xsession-file (string-append home "/.xsession"))
               (session       (match (command-line)
                                ((_)
                                 #$(if fallback-session
                                       #~(list #$fallback-session)
                                       #f))
                                ((_ x ..1)
                                 x))))
          (if (file-exists? xsession-file)
              ;; Run ~/.xsession when it exists.
              (apply exec-from-login-shell xsession-file
                     (or session '()))
              ;; Otherwise, start the specified session or a fallback.
              (apply exec-from-login-shell
                     (or session
                         (find-session user-profile)
                         (find-session system-profile)))))))

  (program-file "xinitrc" builder))



--
宋文武 Aug. 22, 2022, 1:16 a.m. UTC | #6
Brendan Tildesley <mail@brendan.scot> writes:

> On 4/4/22 12:56 pm, Feng Shu wrote:
>> Brendan Tildesley <mail@brendan.scot> writes:
>>
>>> On 3/4/22 8:33 pm, Ludovic Courtès wrote:
>>>> [...]
>>>> One problem is that this won’t work for those using Guix Home, where the
>>>> default profile is ~/.guix-home/profile.
>>>>
>>>> Can this extra variable be avoided?  Or could it be handled by a search
>>>> path specification?
>>> It's xfce4-panel that needs the search path to load .so files for
>>> panel plugins.
>>> xfce4-panel already has the search-path set to load them, but since
>>> its installed
>>> to the system profile,it does not load the user installed plugins. If
>>> xfce4-panel
>>> was a user installed package it may work but userswould have to
>>> manually install it.
>>> So I'm not sure how else to solve it.
>> What happen when version of xfce4-panel installed in system profile is
>> different from installed in home profile?
> I think xfce4-panel will be run from $PATH so the system version will
> be picked first and the user installed one will be ignored. The search
> path will be set but will not work until the user logs out and back in
> again, which is not ideal. I'd like a user to be able to install a plugin
> and have it appear in the settings menu immediately.

Hello, when the version of xfce4-panel and its plugins are different,
xfce4-panel may crash, unable to start.  I think it's best keep them in
one profile, and prefer user's profile.  Well, the polkit actions need
installed into the system profile though.
宋文武 Aug. 25, 2023, 9:57 a.m. UTC | #7
Ludovic Courtès <ludo@gnu.org> writes:

>> ++++ b/scripts/startxfce4.in
>> +@@ -101,6 +101,8 @@ else
>> +   prog=/bin/sh
>> + fi
>> +
>> ++ export
>> X_XFCE4_LIB_DIRS="${GUIX_PROFILE:-$HOME/.guix-profile}/lib/xfce4/${X_XFCE4_LIB_DIRS:+:}$X_XFCE4_LIB_DIRS"
>
> There’s extra space at the beginning of the line.
>
> One problem is that this won’t work for those using Guix Home, where the
> default profile is ~/.guix-home/profile.
>
> Can this extra variable be avoided?  Or could it be handled by a search
> path specification?
>
> I’ve applied the other patches in the meantime.
>
> Thanks!
>
> Ludo’.

We have X_XFCE4_LIB_DIRS as a search-path-specification now, closing.

Thanks.
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 2911541275..4d968162ff 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1956,6 +1956,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/xf86-video-tga-remove-mibstore.patch	\
   %D%/packages/patches/xf86-video-voodoo-pcitag.patch		\
   %D%/packages/patches/xfce4-panel-plugins.patch		\
+  %D%/packages/patches/xfce4-session-startxfce-load-user-plugins.patch	\
   %D%/packages/patches/xfce4-settings-defaults.patch		\
   %D%/packages/patches/xgboost-use-system-dmlc-core.patch       \
   %D%/packages/patches/xmonad-dynamic-linking.patch		\
diff --git a/gnu/packages/patches/xfce4-session-startxfce-load-user-plugins.patch b/gnu/packages/patches/xfce4-session-startxfce-load-user-plugins.patch
new file mode 100644
index 0000000000..f6f1bbc9b1
--- /dev/null
+++ b/gnu/packages/patches/xfce4-session-startxfce-load-user-plugins.patch
@@ -0,0 +1,20 @@ 
+From a1c94934d211d69f9a2cdf03d64327bcd7cccb41 Mon Sep 17 00:00:00 2001
+From: Brendan Tildesley <mail@brendan.scot>
+Date: Thu, 17 Mar 2022 19:49:12 +1100
+Subject: [PATCH] startxfce4: load plugins from user profile
+
+---
+diff --git a/scripts/startxfce4.in b/scripts/startxfce4.in
+--- a/scripts/startxfce4.in
++++ b/scripts/startxfce4.in
+@@ -101,6 +101,8 @@ else
+   prog=/bin/sh
+ fi
+
++    export X_XFCE4_LIB_DIRS="${GUIX_PROFILE:-$HOME/.guix-profile}/lib/xfce4/${X_XFCE4_LIB_DIRS:+:}$X_XFCE4_LIB_DIRS"
++
+ if [ -f "$HOME/.xserverrc" ]; then
+   SERVERRC="$HOME/.xserverrc $SERVERRC"
+ elif [ -f /etc/X11/xinit/xserverrc ]; then
+
+
diff --git a/gnu/packages/xfce.scm b/gnu/packages/xfce.scm
index c36749c6a4..781046a968 100644
--- a/gnu/packages/xfce.scm
+++ b/gnu/packages/xfce.scm
@@ -658,7 +658,8 @@  (define-public xfce4-session
                     (("/sbin/shutdown -r now")  "restart")
                     (("/usr/sbin/pm-suspend")   "pm-suspend")
                     (("/usr/sbin/pm-hibernate") "pm-hibernate"))
-                  #t))))
+                  #t))
+              (patches (search-patches "xfce4-session-startxfce-load-user-plugins.patch"))))
     (build-system gnu-build-system)
     (arguments
      '(#:configure-flags