Skip to content

Commit

Permalink
chore(default-flatpaks): Improve detection of username & UID for root…
Browse files Browse the repository at this point in the history
…ful `notify-send`
  • Loading branch information
fiftydinar authored Oct 18, 2024
1 parent 8ed832d commit 17c6be7
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions modules/default-flatpaks/v1/system-flatpak-setup
Original file line number Diff line number Diff line change
Expand Up @@ -154,32 +154,32 @@ COMBINED_INSTALL_LIST=$(cat <(echo "$MAINTAINER_INSTALL_LIST") "$USER_INSTALL_LI
COMBINED_REMOVE_LIST=$(cat <(echo "$MAINTAINER_REMOVE_LIST") "$USER_REMOVE_LIST_FILE" | grep -v -E '^#|^$' | awk '!seen[$0]++')

function notify-send-pre-install {
user_name=$(loginctl list-sessions --output=json | jq -r '.[].user')
uid=$(loginctl list-sessions --output=json | jq -r '.[].uid')
user_name=$(loginctl list-users --output=json | jq -r '.[] | select(.state == "active") | .user')
uid=$(loginctl list-users --output=json | jq -r '.[] | select(.state == "active") | .uid')
xdg_runtime_path="/run/user/$uid"
display_var=$(printenv DISPLAY)
sudo -u "$user_name" DBUS_SESSION_BUS_ADDRESS=unix:path="$xdg_runtime_path"/bus DISPLAY="$display_var" notify-send "Flatpak Installer" "Started install of system flatpaks" --app-name="Flatpak Installer" -u NORMAL
}

function notify-send-install {
user_name=$(loginctl list-sessions --output=json | jq -r '.[].user')
uid=$(loginctl list-sessions --output=json | jq -r '.[].uid')
user_name=$(loginctl list-users --output=json | jq -r '.[] | select(.state == "active") | .user')
uid=$(loginctl list-users --output=json | jq -r '.[] | select(.state == "active") | .uid')
xdg_runtime_path="/run/user/$uid"
display_var=$(printenv DISPLAY)
sudo -u "$user_name" DBUS_SESSION_BUS_ADDRESS=unix:path="$xdg_runtime_path"/bus DISPLAY="$display_var" notify-send "Flatpak Installer" "Finished install of system flatpaks:\n$INSTALL_LIST" --app-name="Flatpak Installer" -u NORMAL
}

function notify-send-pre-uninstall {
user_name=$(loginctl list-sessions --output=json | jq -r '.[].user')
uid=$(loginctl list-sessions --output=json | jq -r '.[].uid')
xdg_runtime_path="/run/user/$uid"
display_var=$(printenv DISPLAY)
sudo -u "$user_name" DBUS_SESSION_BUS_ADDRESS=unix:path="$xdg_runtime_path"/bus DISPLAY="$display_var" notify-send "Flatpak Installer" "Started uninstall of some system flatpaks" --app-name="Flatpak Installer" -u NORMAL
user_name=$(loginctl list-users --output=json | jq -r '.[] | select(.state == "active") | .user')
uid=$(loginctl list-users --output=json | jq -r '.[] | select(.state == "active") | .uid')
xdg_runtime_path="/run/user/$uid"
display_var=$(printenv DISPLAY)
sudo -u "$user_name" DBUS_SESSION_BUS_ADDRESS=unix:path="$xdg_runtime_path"/bus DISPLAY="$display_var" notify-send "Flatpak Installer" "Started uninstall of some system flatpaks" --app-name="Flatpak Installer" -u NORMAL
}

function notify-send-uninstall {
user_name=$(loginctl list-sessions --output=json | jq -r '.[].user')
uid=$(loginctl list-sessions --output=json | jq -r '.[].uid')
user_name=$(loginctl list-users --output=json | jq -r '.[] | select(.state == "active") | .user')
uid=$(loginctl list-users --output=json | jq -r '.[] | select(.state == "active") | .uid')
xdg_runtime_path="/run/user/$uid"
display_var=$(printenv DISPLAY)
sudo -u "$user_name" DBUS_SESSION_BUS_ADDRESS=unix:path="$xdg_runtime_path"/bus DISPLAY="$display_var" notify-send "Flatpak Installer" "Finished uninstall of system flatpaks:\n$REMOVE_LIST" --app-name="Flatpak Installer" -u NORMAL
Expand Down

0 comments on commit 17c6be7

Please sign in to comment.