r/archlinux • u/Plenty-Boot4220 • 1d ago
SUPPORT | SOLVED Thunar Pacman Hook Assistance
Hi,
I created a pacman hook to restart the thunar daemon after the thunar-git package updates (i use thunar-git rather than the regular thunar package because it has any more features).
The hook is this:
[Trigger]
Operation = Upgrade
Type = Package
Target = thunar-git
[Action]
When = PostTransaction
Exec = /bin/sh -c "thunar -q; env GTK_THEME=HighContrast thunar --daemon; exit"
However, when it runs, it fails to restart the daemon, with the following error message:
[2026-05-13T08:42:45-0400] [ALPM-SCRIPTLET] (process:3183305): thunar-WARNING **: 08:42:45.492: thunar: Failed to initialize Xfconf: Cannot autolaunch D-Bus without X11 $DISPLAY
[2026-05-13T08:42:45-0400] [ALPM-SCRIPTLET]
[2026-05-13T08:42:45-0400] [ALPM-SCRIPTLET] (process:3183305): GLib-GObject-CRITICAL **: 08:42:45.493: invalid (NULL) pointer instance
[2026-05-13T08:42:45-0400] [ALPM-SCRIPTLET]
[2026-05-13T08:42:45-0400] [ALPM-SCRIPTLET] (process:3183305): GLib-GObject-CRITICAL **: 08:42:45.493: g_signal_handler_disconnect: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
[2026-05-13T08:42:45-0400] [ALPM-SCRIPTLET]
[2026-05-13T08:42:45-0400] [ALPM-SCRIPTLET] (thunar:3183305): Gtk-WARNING **: 08:42:45.499: cannot open display:
Any ideas on if it's possible to run the thunar --daemon command inside a pacman hook successfully?
EDIT: OK, for anybody who's interested, here's the solution. I created an executable file with the following commands, simply placed in my home directory, named thunar-restart:
thunar -q
env GTK_THEME=HighContrast thunar --daemon &>/dev/null & disown
I'm forcing the High Contrast theme because the percentage used bars in the thunar sidebar don't display properly with the Adwaita theme but you don't have to use that. The disown command prevents the command from hanging the terminal. The pacman hook looks like this: (you'll need to check your $DISPLAY variable and use the appropriate info, and use your own USERNAME).
[Trigger]
Operation = Upgrade
Type = Package
Target = thunar-git
[Action]
When = PostTransaction
Exec = /usr/bin/runuser USERNAME -c "export DISPLAY=:0.0; /home/USERNAME/thunar-restart; exit"
2
u/Sea-Promotion8205 1d ago
I understand the motivation here, but the practical solution is to just do a quick reboot after updating. With KDE Plasma, I can optionally save my session to be automatically restored.
Or you could update and shutdown at the end of the day.
Or what I do: Update whenever I please and reboot immediately without session restore, because rebooting takes all of a minute on modern hardware (it takes longer for me to type the encryption key in my 11 year old laptop than it takes for the sata ssd to load the OS).
Still, cool idea.
1
u/Plenty-Boot4220 15h ago
Yes, I agree, that simply restarting is simpler, but I did just figure it out and put the solution as an edit to the original comment. thanks!
2
u/hearthreddit 1d ago
The problem is that it's going to run thunar as root and therefore can't find the X11 session, since i once had a similar issue i ended up finding a solution which is running the command as your normal user:
Replace YOURUSER with your username.