Skip to content

Commit

Permalink
feat: implement notifications for system flatpak setup
Browse files Browse the repository at this point in the history
  • Loading branch information
xynydev committed Nov 10, 2024
1 parent 6510afa commit 7185ef5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 16 additions & 10 deletions modules/default-flatpaks/v2/post-boot/system-flatpak-setup
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,27 @@ def main [] {
flatpak remote-add --system --if-not-exists $config.repo.name $config.repo.url --title $config.repo.title

if ($config.notify) {
# TODO implement notification sending
# (notify-send
# --app-name "Automatic Flatpak Installation Service"
# $"Starting automated installation of ($config.install | length) Flatpak\(s) from ($config.repo.title)..."
# )
(notify-send-as-user
"--app-name" "Automatic Flatpak Installation Service"
$"Starting automated installation of ($config.install | length) system Flatpak\(s) from ($config.repo.title)..."
)
}

flatpak install --system $config.repo.name ...$config.install

if ($config.notify) {
# (notify-send
# --app-name "Automatic Flatpak Installation Service"
# $"Finished automated installation of ($config.install | length) Flatpak\(s) from ($config.repo.title)!"
# ($config.install | str join ', ')
# )
(notify-send-as-user
"--app-name" "Automatic Flatpak Installation Service"
$"Finished automated installation of ($config.install | length) system Flatpak\(s) from ($config.repo.title)!"
($config.install | str join ', ')
)
}
}
}

def notify-send-as-user [...args] {
let user_name = (loginctl list-sessions --json=short | from json | get user | get 0)
let uid = (loginctl list-sessions --json=short | from json | get uid | get 0)
let xdg_runtime_path = $"/run/user/($uid)"
sudo -u $user_name DBUS_SESSION_BUS_ADDRESS=unix:path=($xdg_runtime_path)/bus DISPLAY=($env.DISPLAY) notify-send ...$args
}
4 changes: 2 additions & 2 deletions modules/default-flatpaks/v2/post-boot/user-flatpak-setup
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def main [] {
if ($config.notify) {
(notify-send
--app-name "Automatic Flatpak Installation Service"
$"Starting automated installation of ($config.install | length) Flatpak\(s) from ($config.repo.title)..."
$"Starting automated installation of ($config.install | length) user Flatpak\(s) from ($config.repo.title)..."
)
}

Expand All @@ -30,7 +30,7 @@ def main [] {
if ($config.notify) {
(notify-send
--app-name "Automatic Flatpak Installation Service"
$"Finished automated installation of ($config.install | length) Flatpak\(s) from ($config.repo.title)!"
$"Finished automated installation of ($config.install | length) user Flatpak\(s) from ($config.repo.title)!"
($config.install | str join ', ')
)
}
Expand Down

0 comments on commit 7185ef5

Please sign in to comment.