mirror of
https://github.com/theupriser/steamify-cachyos.git
synced 2026-10-03 17:41:58 +02:00
feat: Update notifications: a notification and tray icon when there's a new Steamify
This commit is contained in:
1 parent
febdab5b53
commit
cf73229756
10 files changed
+264
-6
No files matched your search
+3
-2
@@ -5,7 +5,7 @@
|
||||
|
||||
# Menu order. Components are turned on in this order and off in reverse;
|
||||
# gaming must come first (single user builds on it).
|
||||
COMPONENTS=(gaming boot theme glyphs single launcher vram cec machine poweroff kpin hdmi bios)
|
||||
COMPONENTS=(gaming boot theme glyphs single launcher notify vram cec machine poweroff kpin hdmi bios)
|
||||
# One-off actions rather than on/off components: never preselected, never
|
||||
# re-applied, not listed as on or off.
|
||||
ACTIONS=(bios)
|
||||
@@ -26,7 +26,7 @@ NO_PRESELECT=(boot cec kpin hdmi)
|
||||
FEATURE_BASELINE=2.1.0
|
||||
declare -A FEATURE_VERSION=(
|
||||
[gaming]=2.1.0 [boot]=2.1.0 [theme]=2.1.0 [glyphs]=2.1.0 [single]=2.1.0
|
||||
[launcher]=2.1.0 [cec]=2.1.0 [machine]=2.2.0 [poweroff]=2.2.0 [vram]=2.3.0
|
||||
[launcher]=2.1.0 [cec]=2.1.0 [machine]=2.2.0 [poweroff]=2.2.0 [vram]=2.3.0 [notify]=2.5.0
|
||||
[kpin]=2.1.0 [hdmi]=2.1.0
|
||||
)
|
||||
|
||||
@@ -37,6 +37,7 @@ declare -A LABEL=(
|
||||
[glyphs]="Install Steam Deck/Machine icons: Deck button icons in gaming mode"
|
||||
[single]="Single user mode: no password, lock screen or log out (SDDM)"
|
||||
[launcher]="Steamify shortcut: the app on the desktop, Steamify Terminal in the launcher"
|
||||
[notify]="Update notifications: a notification when there's a new Steamify, never updates by itself"
|
||||
[vram]="VRAM booster: the game in front keeps its VRAM, background apps make room"
|
||||
[cec]="HDMI-CEC: use Steam with the TV remote, TV on/off with the PC (experimental)"
|
||||
[machine]="Steam Machine support: LED bar driver, hardware settings in Steam"
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
# "Update notifications" menu item (notify), ticked by default: a systemd
|
||||
# user timer checks GitHub's newest release once a day and at each Plasma
|
||||
# login. When it's newer than the last Steamify that ran here, it shows a
|
||||
# notification (Open Steamify / Skip this version) and a tray icon until
|
||||
# then; it never updates anything itself (patches/steamify-notifier.py).
|
||||
# Sourced by steamify.sh; not meant to be run on its own.
|
||||
|
||||
NOTIFY_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/cachyos-gamescope-boot"
|
||||
NOTIFY_SCRIPT="$NOTIFY_DIR/steamify-notifier"
|
||||
NOTIFY_UNITS="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"
|
||||
NOTIFY_NAME=steamify-update-check
|
||||
|
||||
notify_status() {
|
||||
[[ -f "$NOTIFY_SCRIPT" ]] &&
|
||||
systemctl --user is-enabled -q "$NOTIFY_NAME.timer" 2>/dev/null &&
|
||||
systemctl --user is-enabled -q "$NOTIFY_NAME.service" 2>/dev/null
|
||||
}
|
||||
|
||||
notify_seen() {
|
||||
# Every run records its version: the notifier compares the newest
|
||||
# release with it, so opening Steamify ends a reminder.
|
||||
notify_status && state_set notify seen "$VERSION"
|
||||
}
|
||||
|
||||
notify_enable() {
|
||||
local p missing=()
|
||||
info "Adding update notifications..."
|
||||
# PySide6 for the tray icon, notify-send for the notification's buttons.
|
||||
python3 -c 'import PySide6.QtWidgets' 2>/dev/null || missing+=(pyside6)
|
||||
command -v notify-send >/dev/null || missing+=(libnotify)
|
||||
if ((${#missing[@]})); then
|
||||
sudo pacman -S --needed --noconfirm "${missing[@]}" ||
|
||||
{ err "Installing ${missing[*]} failed."; return 1; }
|
||||
fi
|
||||
patch_file steamify-notifier.py | install_executable "$NOTIFY_SCRIPT" 755 ||
|
||||
{ err "Couldn't write $NOTIFY_SCRIPT."; return 1; }
|
||||
mkdir -p "$NOTIFY_UNITS"
|
||||
# PartOf the graphical session: the tray icon goes with a logout. The
|
||||
# short wait at login lets the tray come up first (in the script: an
|
||||
# ExecStartPre sleep runs into the start timeout).
|
||||
cat > "$NOTIFY_UNITS/$NOTIFY_NAME.service" << EOF
|
||||
[Unit]
|
||||
Description=Steamify: check for a new release
|
||||
After=plasma-workspace.target
|
||||
PartOf=graphical-session.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=$NOTIFY_SCRIPT --delay 60
|
||||
|
||||
[Install]
|
||||
WantedBy=plasma-workspace.target
|
||||
EOF
|
||||
cat > "$NOTIFY_UNITS/$NOTIFY_NAME.timer" << EOF
|
||||
[Unit]
|
||||
Description=Steamify: check for a new release daily
|
||||
|
||||
[Timer]
|
||||
OnCalendar=daily
|
||||
RandomizedDelaySec=1h
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOF
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable "$NOTIFY_NAME.service" >/dev/null 2>&1 &&
|
||||
systemctl --user enable --now "$NOTIFY_NAME.timer" >/dev/null 2>&1 ||
|
||||
{ err "Enabling the update check failed."; return 1; }
|
||||
state_set notify seen "$VERSION"
|
||||
ok "Update notifications on: you'll get a notification when there's a new Steamify."
|
||||
}
|
||||
|
||||
notify_disable() {
|
||||
systemctl --user disable --now "$NOTIFY_NAME.timer" "$NOTIFY_NAME.service" >/dev/null 2>&1
|
||||
rm -f "$NOTIFY_UNITS/$NOTIFY_NAME.service" "$NOTIFY_UNITS/$NOTIFY_NAME.timer" "$NOTIFY_SCRIPT"
|
||||
rmdir "$NOTIFY_DIR" 2>/dev/null || true
|
||||
systemctl --user daemon-reload
|
||||
state_clear notify
|
||||
ok "Update notifications off."
|
||||
}
|
||||
Reference in new issue
Block a user