Thanks!
Example input: XDG_CONFIG_DIRS="/etc/xdg/rosa-xfce-config:/etc/xdg"
Output before this patch: XDG_CONFIG_DIRS="/etc/xdg/rosa-xfce-config:/etc/xdg:/etc/xdg"
But there is no need to duplicate /etc/xdg
in the tail.
Output after this patch: XDG_CONFIG_DIRS="/etc/xdg/rosa-xfce-config:/etc/xdg"
The scripts that sets XDG_CONFIG_DIRS: https://abf.io/soft/rosa-xfce-config/blob/04b69c389d/profile.d/10-rosa-xfce-config-xdg.sh
Tests for that script: https://abf.io/soft/rosa-xfce-config/blob/04b69c389d/profile.d/test_10-rosa-xfce-config-xdg.sh
I do not see why that my script must not append "/etc/xdg", so fixing startxfce4.
This case-esac code is compatible with POSIX shell (https://stackoverflow.com/a/2830416), but tested it only with bash.
Diff is bellow, git am
-able patch is attached.
0001-Avoid-duplicating-directories-in-the-tail-of-XDG_-en.patch
diff --git a/scripts/startxfce4.in b/scripts/startxfce4.in
index bf3201b6..b20a9cf4 100644
--- a/scripts/startxfce4.in
+++ b/scripts/startxfce4.in
@@ -72,7 +72,11 @@ then
XDG_DATA_DIRS="@_datadir_@:/usr/local/share:/usr/share"
fi
else
- XDG_DATA_DIRS="$XDG_DATA_DIRS:@_datadir_@"
+ # avoid duplicating @_datadir_@ if $XDG_DATA_DIRS already contains it
+ case "$XDG_DATA_DIRS" in
+ *:@_datadir_@ | @_datadir_@ ) : ;;
+ * ) XDG_DATA_DIRS="$XDG_DATA_DIRS:@_datadir_@" ;;
+ esac
fi
export XDG_DATA_DIRS
@@ -84,7 +88,11 @@ then
XDG_CONFIG_DIRS="/etc/xdg:@_sysconfdir_@/xdg"
fi
else
- XDG_CONFIG_DIRS="$XDG_CONFIG_DIRS:@_sysconfdir_@/xdg"
+ # avoid duplicating @_sysconfdir_@/xdg if $XDG_CONFIG_DIRS already contains it
+ case "$XDG_CONFIG_DIRS" in
+ *:@_sysconfdir_@/xdg | @_sysconfdir_@/xdg ) : ;;
+ * ) XDG_CONFIG_DIRS="$XDG_CONFIG_DIRS:@_sysconfdir_@/xdg" ;;
+ esac
fi
export XDG_CONFIG_DIRS
Sorry, fixed
Done. I've added a comment explaining what it does.
I have written quite a lot of shell scripts in the last few years, but do not know what this construction means, most other people probably also do not know this. Of course I can ask Google/Yandex/man, but we probably should not overcomplicate code with brain-fuck alike constructions...
Current code is simple, so I think it is worth it. If there were a much more complex code for solving this, than it would be argueable, I agree
@Tamaranch Yeah, I'm still here, let's merge it eventually :)
I would better avoid ${XDG_DATA_DIRS##*:}
because it is not evident how it works and at the same time will not give performance improvements.
Thanks!
Here the idea is to read the defaults once, yes, but it will make out of the box experience smooth for most users because most users do not change DM and even do not change settings of the Whisker menu.
A separate tool will be better of course, thanks for the idea. xflock4 is part of xfce4-session and is a simple shell script, so you suggest to make a similar script and make a merge request adding it into xfce4-session? Are there any other places in XFCE where it can be used from?
Old versions of xfce4-whiskermenu-plugin called gdmflexiserver, then it was changed to dm-tool.
But LightDM's dm-tool does not work under GDM:
$ dm-tool switch-to-greeter
Not running inside a display manager, XDG_SEAT_PATH not defined
Let's support both GDM and LightDM out of the box.
P.S. Maybe codestyle of my code is bad, feel free to suggest changes.
@lastonestanding I think it is better to append :/etc/xdg
to the end in this case as it is done by current code in this merge request and get XDG_CONFIG_DIRS=/etc/xdg:/etc/xdg/rosa-xfce-config:/etc/xdg
, because:
XDG_CONFIG_DIRS=/etc/xdg:/etc/xdg/foo
and current code will convert it to XDG_CONFIG_DIRS=/etc/xdg:/etc/xdg/foo:/etc/xdg
, it should be functionally equal to XDG_CONFIG_DIRS=/etc/xdg:/etc/xdg/foo
But appending a duplicate of /etc/xdg
to the tail is argueable...
If the desktop file just runs clipman in systray, why it is named as "autostart"? Why AUTOstart?
I did not notice problems caused by this duplication, but I did not study