I use the following in systemd .conf file to run a graphical zenity dialog every time specific device with SMART capability is inserted to the USB port. This works fine in Xubuntu which uses X display server, but the display of zenity dialog fails in Wayland server.
USER=myName
DISPLAY=:0.0
WAYLAND_DISPLAY=wayland-0
XAUTHORITY=/home/myName/.Xauthority
HOME=/home/myName
SHELL=/bin/bash
I tried adding WAYLAND_DISPLAY=wayland-0 in the .conf file for Wayland server in Ubuntu 23.10 but still zenity dialogue fails to show up. What more do I need to do?
The list of files that my setup-01:
/bin/hdd_smart_dump_on_usb_trigger.sh
/etc/00_hdd_smart_dump_on_usb_trigger.conf
/etc/systemd/system/hdd_smart_dump_on_usb_trigger@.service
/etc/systemd/system/hdd_smart_dump_on_usb_trigger@.service.d/disable_manual_start.conf
/etc/systemd/system/hdd_smart_dump_on_usb_trigger@.target
/etc/udev/00_hdd_smart_dump_on_usb_trigger.udev.sh
/etc/udev/rules.d/99-hdd-smart-dump-on-usb-trigger.udev.rules
The contents of /etc/00_hdd_smart_dump_on_usb_trigger.conf :
USER=myName
DISPLAY=:0.0
WAYLAND_DISPLAY=wayland-0
XAUTHORITY=/home/ajthapa/.Xauthority
HOME=/home/myName
SHELL=/bin/bash
The contents of /etc/systemd/system/hdd_smart_dump_on_usb_trigger@.service :
[Unit]
Description=HDD SMART Dump on USB Trigger - service unit for %I
Documentation=man:systemd.unit(5) man:systemd.exec(5) man:systemd.special(7) man:systemd.target(5)
ConditionPathExistsGlob=/sys/class/block/sd*
# RefuseManualStart=true
# RefuseManualStop=true
[Service]
EnvironmentFile=/etc/00_hdd_smart_dump_on_usb_trigger.conf
ExecStart=-/bin/bash -c '/bin/hdd_smart_dump_on_usb_trigger.sh -d %i -t "start_of_session"'
The contents of /etc/systemd/system/hdd_smart_dump_on_usb_trigger@.service.d/disable_manual_start.conf :
[Unit]
## Allow only to be started/stopped by device events; if manual start is needed
## you should instead call the script which this service calls.
RefuseManualStart=true
RefuseManualStop=true
The contents of /etc/systemd/system/hdd_smart_dump_on_usb_trigger@.target :
[Unit]
Description=HDD SMART Dump on USB Trigger - target unit for %I
Documentation=man:systemd.unit(5) man:systemd.target(5) man:systemd.special(7)
StopWhenUnneeded=yes
Requires=hdd_smart_dump_on_usb_trigger@%i.service
Before=hdd_smart_dump_on_usb_trigger@%i.service
BindsTo=%i.device
RefuseManualStart=true
RefuseManualStop=true
The contents of /etc/udev/rules.d/99-hdd-smart-dump-on-usb-trigger.udev.rules :
SUBSYSTEM!="block", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
KERNEL!="sd*", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
ENV{DEVTYPE}!="disk", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
Rules to match specific devices; start:
ATTRS{idProduct}=="2312", ATTRS{idVendor}=="0bc2", GOTO="label__enlisted_devices"
ATTRS{idProduct}=="5590", ATTRS{idVendor}=="0781", GOTO="label__enlisted_devices"
ATTRS{idProduct}!="2312|5590", ATTRS{idVendor}!="0bc2|0781", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
Rules to match specific devices; end.
LABEL="label__enlisted_devices"
ACTION=="remove", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_for_action_remove"
ACTION!="add", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd", ENV{DEVTYPE}=="disk", ATTRS{idProduct}=="2312", ATTRS{idVendor}=="0bc2", TAG+="systemd", ENV{SYSTEMD_WANTS}+="hdd_smart_dump_on_usb_trigger@dev-%k.target", RUN+="/etc/udev/00_hdd_smart_dump_on_usb_trigger.udev.sh ==01== UDEV_ACTION==ADD ####  ENVIRONMENT::::[[ DEVNAME=$env{DEVNAME} | DEVPATH=$env{DEVPATH} | ID_MODEL=$env{ID_MODEL} | ID_SERIAL=$env{ID_SERIAL} | ID_SERIAL_SHORT=$env{ID_SERIAL_SHORT} | ID_VENDOR=$env{ID_VENDOR} | TAGS=$env{TAGS} | ID_ATA=$env{ID_ATA} | ID_ATA_FEATURE_SET_SMART=$env{ID_ATA_FEATURE_SET_SMART} | ID_ATA_FEATURE_SET_SMART_ENABLED=$env{ID_ATA_FEATURE_SET_SMART_ENABLED} | ID_ATA_SATA=$env{ID_ATA_SATA} | ID_ATA_WRITE_CACHE=$env{ID_ATA_WRITE_CACHE} | ID_ATA_WRITE_CACHE_ENABLED=$env{ID_ATA_WRITE_CACHE_ENABLED} | ID_VENDOR_ID=$env{ID_VENDOR_ID} | ID_MODEL_ID=$env{ID_MODEL_ID} | ]]  ####  ATTRIBUTE::::[[ size=$attr{size} | KERNEL=%k | idProduct=$attr{idProduct} | idVendor=$attr{idVendor} | manufacturer=$attr{manufacturer} | product=$attr{product} | removable=$attr{removable} | bMaxPower=$attr{bMaxPower} | ]]", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd", ENV{DEVTYPE}=="disk", ATTRS{idProduct}=="5590", ATTRS{idVendor}=="0781", TAG+="systemd", ENV{SYSTEMD_WANTS}+="hdd_smart_dump_on_usb_trigger@dev-%k.target", RUN+="/etc/udev/00_hdd_smart_dump_on_usb_trigger.udev.sh ==01== UDEV_ACTION==ADD ####  ENVIRONMENT::::[[ DEVNAME=$env{DEVNAME} | DEVPATH=$env{DEVPATH} | ID_MODEL=$env{ID_MODEL} | ID_SERIAL=$env{ID_SERIAL} | ID_SERIAL_SHORT=$env{ID_SERIAL_SHORT} | ID_VENDOR=$env{ID_VENDOR} | TAGS=$env{TAGS} | ID_ATA=$env{ID_ATA} | ID_ATA_FEATURE_SET_SMART=$env{ID_ATA_FEATURE_SET_SMART} | ID_ATA_FEATURE_SET_SMART_ENABLED=$env{ID_ATA_FEATURE_SET_SMART_ENABLED} | ID_ATA_SATA=$env{ID_ATA_SATA} | ID_ATA_WRITE_CACHE=$env{ID_ATA_WRITE_CACHE} | ID_ATA_WRITE_CACHE_ENABLED=$env{ID_ATA_WRITE_CACHE_ENABLED} | ID_VENDOR_ID=$env{ID_VENDOR_ID} | ID_MODEL_ID=$env{ID_MODEL_ID} | ]]  ####  ATTRIBUTE::::[[ size=$attr{size} | KERNEL=%k | idProduct=$attr{idProduct} | idVendor=$attr{idVendor} | manufacturer=$attr{manufacturer} | product=$attr{product} | removable=$attr{removable} | bMaxPower=$attr{bMaxPower} | ]]", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
LABEL="label__hdd_smart_dump_on_usb_trigger_rules_for_action_remove"
ACTION=="remove", SUBSYSTEM=="block", KERNEL=="sd*", ENV{DEVTYPE}=="disk", RUN+="/etc/udev/00_hdd_smart_dump_on_usb_trigger.udev.sh ==02== UDEV_ACTION==REMOVE ####  ENVIRONMENT::::[[ DEVNAME=$env{DEVNAME} | ID_MODEL=$env{ID_MODEL} | ID_SERIAL=$env{ID_SERIAL} | ID_SERIAL_SHORT=$env{ID_SERIAL_SHORT} | ID_VENDOR=$env{ID_VENDOR} | TAGS=$env{TAGS} | ID_ATA=$env{ID_ATA} | ID_ATA_FEATURE_SET_SMART=$env{ID_ATA_FEATURE_SET_SMART} | ID_ATA_FEATURE_SET_SMART_ENABLED=$env{ID_ATA_FEATURE_SET_SMART_ENABLED} | ID_ATA_SATA=$env{ID_ATA_SATA} | ID_ATA_WRITE_CACHE=$env{ID_ATA_WRITE_CACHE} | ID_ATA_WRITE_CACHE_ENABLED=$env{ID_ATA_WRITE_CACHE_ENABLED} | ID_VENDOR_ID=$env{ID_VENDOR_ID} | ID_MODEL_ID=$env{ID_MODEL_ID} ]]  ####  ATTRIBUTE::::[[ size=$attr{size} | KERNEL=$kernel | idProduct=$attr{idProduct} | idVendor=$attr{idVendor} | manufacturer=$attr{manufacturer} | product=$attr{product} | model=$attr{model} | removable=$attr{removable} ]]"
LABEL="label__hdd_smart_dump_on_usb_trigger_rules_end"
The /etc/udev/rules.d/99-hdd-smart-dump-on-usb-trigger.udev.rules contains rules to match specific set of devices, on which it executes /etc/udev/00_hdd_smart_dump_on_usb_trigger.udev.sh which in turn writes some attributes to a file in /var/run/ directory. The rules file also triggers systemd unit files, which then executes /bin/hdd_smart_dump_on_usb_trigger.sh . This script uses zenity to allow users to save the output of smartmontools to selected location.
UPDATE:
Setup-02:
List of files:
-rw-r--r-- 1 root root 3018 Feb 19 12:25 /etc/00_hdd_smart_dump_on_usb_trigger.conf
-rw-r--r-- 1 root root 2013 Feb 19 12:15 /etc/systemd/system/hdd_smart_dump_on_usb_trigger@.service
-rw-r--r-- 1 root root 196 Aug  8  2020 /etc/systemd/system/hdd_smart_dump_on_usb_trigger@.service.d/disable_manual_start.conf
-rw-r--r-- 1 root root 573 Feb 19 07:42 /etc/systemd/system/hdd_smart_dump_on_usb_trigger@.target
-rwxr-xr-x 1 root root 7562 Sep  5  2020 /etc/udev/00_hdd_smart_dump_on_usb_trigger.udev.sh
-rw-r--r-- 1 root root 7710 Feb 19 13:29 /etc/udev/rules.d/99-hdd-smart-dump-on-usb-trigger.udev.rules
-rwxr-xr-x 1 root root 5032 Feb 19 13:18 /opt/hdd_smart_dump_on_usb_trigger/bin/hdd_smart_dump_display_with_zenity.sh
-rwxr-xr-x 1 root root 34594 Feb 19 11:58 /opt/hdd_smart_dump_on_usb_trigger/bin/hdd_smart_dump_on_usb_trigger.sh
-rw-r--r-- 1 myName myName 502 Feb 19 13:30 /home/myName/.config/systemd/user/hdd_smart_dump_display_using_zenity@.service
With this setup, udev writes attributes which is then read by my systemd system-units, but my systemd user-units fail to launch and show the dump in zenity dialogue. I can use the same command in my /home/myName/.config/systemd/user/hdd_smart_dump_display_using_zenity@.service to launch zenity with the SMART dump. So, the problem could be in my udev .rules file and/or my systemd user-unit file and/or it's naming.
The contents of /home/myName/.config/systemd/user/hdd_smart_dump_display_using_zenity@.service :
[Unit]
Description=HDD SMART Dump Display Using Zenity Dialogue
Documentation=man:systemd.unit(5) man:systemd.exec(5) man:systemd.special(7) man:systemd.target(5)
Requires=hdd_smart_dump_on_usb_trigger@%i.service
After=hdd_smart_dump_on_usb_trigger@%i.service
ConditionPathExistsGlob=/sys/class/block/sd*
# RefuseManualStart=true
# RefuseManualStop=true
[Service]
Type=oneshot
ExecStart=-/bin/bash -c '/opt/hdd_smart_dump_on_usb_trigger/bin/hdd_smart_dump_display_with_zenity.sh --display-dialogue'
The contents of /etc/udev/rules.d/99-hdd-smart-dump-on-usb-trigger.udev.rules :
SUBSYSTEM!="block", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
KERNEL!="sd*", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
ENV{DEVTYPE}!="disk", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
ATTRS{idProduct}=="2312", ATTRS{idVendor}=="0bc2", GOTO="label__enlisted_devices"
ATTRS{idProduct}=="5590", ATTRS{idVendor}=="0781", GOTO="label__enlisted_devices"
ATTRS{idProduct}!="2312|5590", ATTRS{idVendor}!="0bc2|0781", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
LABEL="label__enlisted_devices"
ACTION=="remove", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_for_action_remove"
ACTION!="add", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd*", ENV{DEVTYPE}=="disk", ATTRS{idProduct}=="2312", ATTRS{idVendor}=="0bc2", TAG+="systemd", ENV{SYSTEMD_WANTS}+="hdd_smart_dump_on_usb_trigger@dev-%k.target", ENV{SYSTEMD_USER_WANTS}+="hdd_smart_dump_display_using_zenity@dev-%k.system", RUN+="/etc/udev/00_hdd_smart_dump_on_usb_trigger.udev.sh ==01== UDEV_ACTION==ADD ####  ENVIRONMENT::::[[ DEVNAME=$env{DEVNAME} | DEVPATH=$env{DEVPATH} | ID_MODEL=$env{ID_MODEL} | ID_SERIAL=$env{ID_SERIAL} | ID_SERIAL_SHORT=$env{ID_SERIAL_SHORT} | ID_VENDOR=$env{ID_VENDOR} | TAGS=$env{TAGS} | ID_ATA=$env{ID_ATA} | ID_ATA_FEATURE_SET_SMART=$env{ID_ATA_FEATURE_SET_SMART} | ID_ATA_FEATURE_SET_SMART_ENABLED=$env{ID_ATA_FEATURE_SET_SMART_ENABLED} | ID_ATA_SATA=$env{ID_ATA_SATA} | ID_ATA_WRITE_CACHE=$env{ID_ATA_WRITE_CACHE} | ID_ATA_WRITE_CACHE_ENABLED=$env{ID_ATA_WRITE_CACHE_ENABLED} | ID_VENDOR_ID=$env{ID_VENDOR_ID} | ID_MODEL_ID=$env{ID_MODEL_ID} | ]]  ####  ATTRIBUTE::::[[ size=$attr{size} | KERNEL=%k | idProduct=$attr{idProduct} | idVendor=$attr{idVendor} | manufacturer=$attr{manufacturer} | product=$attr{product} | removable=$attr{removable} | bMaxPower=$attr{bMaxPower} | ]]", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd*", ENV{DEVTYPE}=="disk", ATTRS{idProduct}=="5590", ATTRS{idVendor}=="0781", TAG+="systemd", ENV{SYSTEMD_WANTS}+="hdd_smart_dump_on_usb_trigger@dev-%k.target", ENV{SYSTEMD_USER_WANTS}+="hdd_smart_dump_display_using_zenity@dev-%k.system", RUN+="/etc/udev/00_hdd_smart_dump_on_usb_trigger.udev.sh ==01== UDEV_ACTION==ADD ####  ENVIRONMENT::::[[ DEVNAME=$env{DEVNAME} | DEVPATH=$env{DEVPATH} | ID_MODEL=$env{ID_MODEL} | ID_SERIAL=$env{ID_SERIAL} | ID_SERIAL_SHORT=$env{ID_SERIAL_SHORT} | ID_VENDOR=$env{ID_VENDOR} | TAGS=$env{TAGS} | ID_ATA=$env{ID_ATA} | ID_ATA_FEATURE_SET_SMART=$env{ID_ATA_FEATURE_SET_SMART} | ID_ATA_FEATURE_SET_SMART_ENABLED=$env{ID_ATA_FEATURE_SET_SMART_ENABLED} | ID_ATA_SATA=$env{ID_ATA_SATA} | ID_ATA_WRITE_CACHE=$env{ID_ATA_WRITE_CACHE} | ID_ATA_WRITE_CACHE_ENABLED=$env{ID_ATA_WRITE_CACHE_ENABLED} | ID_VENDOR_ID=$env{ID_VENDOR_ID} | ID_MODEL_ID=$env{ID_MODEL_ID} | ]]  ####  ATTRIBUTE::::[[ size=$attr{size} | KERNEL=%k | idProduct=$attr{idProduct} | idVendor=$attr{idVendor} | manufacturer=$attr{manufacturer} | product=$attr{product} | removable=$attr{removable} | bMaxPower=$attr{bMaxPower} | ]]", GOTO="label__hdd_smart_dump_on_usb_trigger_rules_end"
LABEL="label__hdd_smart_dump_on_usb_trigger_rules_for_action_remove"
ACTION=="remove", SUBSYSTEM=="block", KERNEL=="sd*", ENV{DEVTYPE}=="disk", RUN+="/etc/udev/00_hdd_smart_dump_on_usb_trigger.udev.sh ==02== UDEV_ACTION==REMOVE ####  ENVIRONMENT::::[[ DEVNAME=$env{DEVNAME} | ID_MODEL=$env{ID_MODEL} | ID_SERIAL=$env{ID_SERIAL} | ID_SERIAL_SHORT=$env{ID_SERIAL_SHORT} | ID_VENDOR=$env{ID_VENDOR} | TAGS=$env{TAGS} | ID_ATA=$env{ID_ATA} | ID_ATA_FEATURE_SET_SMART=$env{ID_ATA_FEATURE_SET_SMART} | ID_ATA_FEATURE_SET_SMART_ENABLED=$env{ID_ATA_FEATURE_SET_SMART_ENABLED} | ID_ATA_SATA=$env{ID_ATA_SATA} | ID_ATA_WRITE_CACHE=$env{ID_ATA_WRITE_CACHE} | ID_ATA_WRITE_CACHE_ENABLED=$env{ID_ATA_WRITE_CACHE_ENABLED} | ID_VENDOR_ID=$env{ID_VENDOR_ID} | ID_MODEL_ID=$env{ID_MODEL_ID} ]]  ####  ATTRIBUTE::::[[ size=$attr{size} | KERNEL=$kernel | idProduct=$attr{idProduct} | idVendor=$attr{idVendor} | manufacturer=$attr{manufacturer} | product=$attr{product} | model=$attr{model} | removable=$attr{removable} ]]"
LABEL="label__hdd_smart_dump_on_usb_trigger_rules_end"
Output of sudo systemctl --no-pager -l status 'hdd_smart_dump_on_usb_trigger*' with USB device inserted:
● hdd_smart_dump_on_usb_trigger@dev-sdb.target - HDD SMART Dump on USB Trigger - target unit for dev/sdb
     Loaded: loaded (/etc/systemd/system/hdd_smart_dump_on_usb_trigger@.target; static)
     Active: active since Mon 2024-02-19 14:17:50 +0545; 2min 24s ago
       Docs: man:systemd.unit(5)
             man:systemd.target(5)
             man:systemd.special(7)
Feb 19 14:17:50 ajthapa-vcomputer systemd[1]: Reached target hdd_smart_dump_on_usb_trigger@dev-sdb.target - HDD SMART Dump on USB Trigger - target unit for dev/sdb.
There is no output for systemctl --user --no-pager -l status 'hdd_*' .
Setup-03:
The files:
/etc/00_hdd_smart_dump_on_usb_trigger.conf
/etc/systemd/system/hdd_smart_dump_on_usb_trigger@.service
/etc/systemd/system/hdd_smart_dump_on_usb_trigger@.service.d/disable_manual_start.conf
/etc/systemd/system/hdd_smart_dump_on_usb_trigger@.target
/etc/udev/00_hdd_smart_dump_on_usb_trigger.udev.sh
/etc/udev/rules.d/99-hdd-smart-dump-on-usb-trigger.udev.rules
/opt/hdd_smart_dump_on_usb_trigger/bin/hdd_smart_dump_display_with_zenity.sh
/opt/hdd_smart_dump_on_usb_trigger/bin/hdd_smart_dump_on_usb_trigger.sh
/home/ajthapa/.config/systemd/user/hdd_smart_dump_display_using_zenity.service
The contents of /home/ajthapa/.config/systemd/user/hdd_smart_dump_display_using_zenity.service :
[Unit]
Description=HDD SMART Dump Display Using Zenity Dialogue
Documentation=man:systemd.unit(5) man:systemd.exec(5) man:systemd.special(7) man:systemd.target(5)
StopWhenUnneeded=yes
After=hdd_smart_dump_on_usb_trigger@%i.service
#BindsTo=%i.device
RefuseManualStart=true
RefuseManualStop=true
[Service]
Type=oneshot
ExecStart=-/bin/bash -c '/opt/hdd_smart_dump_on_usb_trigger/bin/hdd_smart_dump_display_with_zenity.sh --display-dialogue'
[Install]
WantedBy=hdd_smart_dump_on_usb_trigger@%i.service
The output of command systemctl --user enable hdd_smart_dump_display_using_zenity.service :
Created symlink /home/ajthapa/.config/systemd/user/hdd_smart_dump_on_usb_trigger@.service.wants/hdd_smart_dump_display_using_zenity.service → /home/ajthapa/.config/systemd/user/hdd_smart_dump_display_using_zenity.service.
Unit /home/ajthapa/.config/systemd/user/hdd_smart_dump_display_using_zenity.service is added as a dependency to a non-existent unit hdd_smart_dump_on_usb_trigger@.service.
The '... dependency added to non-existent unit ...' prevents the starting of the encoded script in the user-unit.
In setup-03, the udev .rules file triggers only the system-unit of systemd files.
SETUP-04:
The list of files:
/etc/00_hdd_smart_dump_on_usb_trigger.conf
/etc/systemd/system/hdd_smart_dump_on_usb_trigger@.service
/etc/systemd/system/hdd_smart_dump_on_usb_trigger@.service.d/disable_manual_start.conf
/etc/systemd/system/hdd_smart_dump_on_usb_trigger@.target
/etc/udev/00_hdd_smart_dump_on_usb_trigger.udev.sh
/etc/udev/rules.d/99-hdd-smart-dump-on-usb-trigger.udev.rules
/opt/hdd_smart_dump_on_usb_trigger/bin/hdd_smart_dump_display_with_zenity.sh
/opt/hdd_smart_dump_on_usb_trigger/bin/hdd_smart_dump_on_usb_trigger.sh
/home/ajthapa/.config/systemd/user/hdd_smart_dump_display_using_zenity@.service
/home/ajthapa/.config/systemd/user/hdd_smart_dump_display_using_zenity@.target
The contents of /home/ajthapa/.config/systemd/user/hdd_smart_dump_display_using_zenity@.service :
[Unit]
Description=HDD SMART Dump Display Using Zenity Dialogue
Documentation=man:systemd.unit(5) man:systemd.exec(5) man:systemd.special(7) man:systemd.target(5)
ConditionPathExistsGlob=/sys/class/block/sd*
RefuseManualStart=true
RefuseManualStop=true
[Service]
Type=oneshot
ExecStart=-/bin/bash -c '/opt/hdd_smart_dump_on_usb_trigger/bin/hdd_smart_dump_display_with_zenity.sh --display-dialogue'
The contents of /home/ajthapa/.config/systemd/user/hdd_smart_dump_display_using_zenity@.target :
[Unit]
Description=HDD SMART Dump Display Using Zenity Dialogue - target unit for %I
Documentation=man:systemd.unit(5) man:systemd.exec(5) man:systemd.special(7) man:systemd.target(5)
StopWhenUnneeded=yes
Requires=hdd_smart_dump_display_using_zenity@%i.service
Before=hdd_smart_dump_display_using_zenity@%i.service
RefuseManualStart=true
RefuseManualStop=true
The system-unit .target and user-unit .target are triggered by udev rules. With this configuration of systemd system, and user units, and udev rule, these user-units seem to be executing before the system-units. E.g. when a USB device connected for the first time, the zenity displays blank. When the device is ejected, and connected again the user-unit executes first and reads the previous values written by scripts run by system-unit and hence displays stale value (of previously inserted device).
Update: In setup-04, in user-unit .service file I added a delay of about 3-5 seconds, and the setup work as expected, but this is not how I want it to be, I want this to be done via Systemd settings in the unit files.
I used ExecStart=-/bin/bash -c 'sleep 3s; /opt/hdd_smart_dump_on_usb_trigger/bin/hdd_smart_dump_display_with_zenity.sh --display-dialogue' in the .service user-unit file.
Any idea what I'm doing wrong in these setup?
 
    