mirror of
https://github.com/theupriser/steamify-cachyos.git
synced 2026-10-14 15:44:47 +02:00
GNOME: terminal for the Steamify shortcut and notifier, notifier runs on GNOME
This commit is contained in:
1 parent
62a30e6095
commit
039f2691d8
2 files changed
+36
-9
No files matched your search
+20
-4
@@ -22,6 +22,18 @@ WIZARD_TERMINAL_ENTRY="$WIZARD_APPS/steamify-terminal.desktop"
|
|||||||
# Before 2.0.1 the shortcut opened the terminal menu under this name.
|
# Before 2.0.1 the shortcut opened the terminal menu under this name.
|
||||||
WIZARD_OLD_NAME="cachyos-gamescope-boot-wizard.desktop"
|
WIZARD_OLD_NAME="cachyos-gamescope-boot-wizard.desktop"
|
||||||
|
|
||||||
|
wizard_terminal() {
|
||||||
|
# The command prefix that runs a program in a terminal window: Konsole on
|
||||||
|
# Plasma, on GNOME whichever of Ptyxis, Console or GNOME Terminal is there.
|
||||||
|
if [[ "$(desktop_kind)" == gnome ]]; then
|
||||||
|
if command -v ptyxis >/dev/null; then echo "ptyxis --"
|
||||||
|
elif command -v kgx >/dev/null; then echo "kgx -e"
|
||||||
|
else echo "gnome-terminal --"; fi
|
||||||
|
else
|
||||||
|
echo "konsole -e"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
wizard_desktop_dir() {
|
wizard_desktop_dir() {
|
||||||
xdg-user-dir DESKTOP 2>/dev/null || echo "$HOME/Desktop"
|
xdg-user-dir DESKTOP 2>/dev/null || echo "$HOME/Desktop"
|
||||||
}
|
}
|
||||||
@@ -47,6 +59,8 @@ launcher_status() {
|
|||||||
launcher_repair() { [[ -f "$WIZARD_APPS/$WIZARD_OLD_NAME" ]] && ! launcher_status; }
|
launcher_repair() { [[ -f "$WIZARD_APPS/$WIZARD_OLD_NAME" ]] && ! launcher_status; }
|
||||||
|
|
||||||
launcher_enable() {
|
launcher_enable() {
|
||||||
|
local terminal
|
||||||
|
terminal="$(wizard_terminal)"
|
||||||
info "Adding the Steamify shortcut (the app on the desktop and in the launcher, Steamify Terminal in the launcher)..."
|
info "Adding the Steamify shortcut (the app on the desktop and in the launcher, Steamify Terminal in the launcher)..."
|
||||||
install_executable "$WIZARD_LAUNCHER" 755 << EOF
|
install_executable "$WIZARD_LAUNCHER" 755 << EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
@@ -70,18 +84,18 @@ echo
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# The app, without a terminal. Only the first time, when PySide6 still
|
# The app, without a terminal. Only the first time, when PySide6 still
|
||||||
# has to be installed, it runs in Konsole: sudo asks for the password there.
|
# has to be installed, it runs in a terminal: sudo asks for the password there.
|
||||||
install_executable "$WIZARD_APP_LAUNCHER" 755 << EOF
|
install_executable "$WIZARD_APP_LAUNCHER" 755 << EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Installed by Steamify CachyOS: start the newest release of its app.
|
# Installed by Steamify CachyOS: start the newest release of its app.
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
if [[ "\${1:-}" != --in-terminal ]] && ! python3 -c 'import PySide6.QtQml' 2>/dev/null; then
|
if [[ "\${1:-}" != --in-terminal ]] && ! python3 -c 'import PySide6.QtQml' 2>/dev/null; then
|
||||||
exec konsole -e "\$0" --in-terminal
|
exec $terminal "\$0" --in-terminal
|
||||||
fi
|
fi
|
||||||
if ! curl -fsSL --max-time 30 "$WIZARD_APP_URL" | bash; then
|
if ! curl -fsSL --max-time 30 "$WIZARD_APP_URL" | bash; then
|
||||||
msg="Couldn't download or start Steamify. Are you connected to the internet?"
|
msg="Couldn't download or start Steamify. Are you connected to the internet?"
|
||||||
if [[ "\${1:-}" == --in-terminal ]]; then echo; echo "\$msg"; read -rp "Press Enter to close this window... " _
|
if [[ "\${1:-}" == --in-terminal ]]; then echo; echo "\$msg"; read -rp "Press Enter to close this window... " _
|
||||||
else kdialog --title Steamify --sorry "\$msg" 2>/dev/null; fi
|
else kdialog --title Steamify --sorry "\$msg" 2>/dev/null || zenity --error --title Steamify --text "\$msg" 2>/dev/null; fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
@@ -110,11 +124,13 @@ Categories=Game;System;Settings;
|
|||||||
X-Steamify-Shortcut=true"
|
X-Steamify-Shortcut=true"
|
||||||
printf '%s\n' "$entry" | install_executable "$WIZARD_APP_ENTRY" 644
|
printf '%s\n' "$entry" | install_executable "$WIZARD_APP_ENTRY" 644
|
||||||
printf '%s\n' "$entry" | install_executable "$(wizard_desktop_dir)/$WIZARD_DESKTOP_NAME" 755
|
printf '%s\n' "$entry" | install_executable "$(wizard_desktop_dir)/$WIZARD_DESKTOP_NAME" 755
|
||||||
|
# GNOME only starts desktop launchers it trusts.
|
||||||
|
gio set "$(wizard_desktop_dir)/$WIZARD_DESKTOP_NAME" metadata::trusted true 2>/dev/null || true
|
||||||
printf '%s\n' "[Desktop Entry]
|
printf '%s\n' "[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=Steamify Terminal
|
Name=Steamify Terminal
|
||||||
Comment=Steamify CachyOS's menu in a terminal
|
Comment=Steamify CachyOS's menu in a terminal
|
||||||
Exec=konsole -e $WIZARD_LAUNCHER
|
Exec=$terminal $WIZARD_LAUNCHER
|
||||||
Icon=$icon
|
Icon=$icon
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Categories=Game;System;Settings;" | install_executable "$WIZARD_TERMINAL_ENTRY" 644
|
Categories=Game;System;Settings;" | install_executable "$WIZARD_TERMINAL_ENTRY" 644
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import configparser
|
import configparser
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
@@ -56,10 +57,20 @@ def pending(new):
|
|||||||
|
|
||||||
|
|
||||||
def desktop():
|
def desktop():
|
||||||
# Only on the Plasma desktop: gamescope doesn't show notifications or a
|
# Only on the Plasma or GNOME desktop: gamescope doesn't show notifications
|
||||||
# tray, so an update found in gaming mode waits for the next desktop login.
|
# or a tray, so an update found in gaming mode waits for the next desktop login.
|
||||||
return subprocess.run(["pgrep", "-u", str(os.getuid()), "-x", "plasmashell"],
|
return any(subprocess.run(["pgrep", "-u", str(os.getuid()), "-x", shell],
|
||||||
stdout=subprocess.DEVNULL).returncode == 0
|
stdout=subprocess.DEVNULL).returncode == 0
|
||||||
|
for shell in ("plasmashell", "gnome-shell"))
|
||||||
|
|
||||||
|
|
||||||
|
def terminal():
|
||||||
|
# The command prefix that runs a program in a terminal window.
|
||||||
|
for program, prefix in (("konsole", ["konsole", "-e"]), ("ptyxis", ["ptyxis", "--"]),
|
||||||
|
("kgx", ["kgx", "-e"]), ("gnome-terminal", ["gnome-terminal", "--"])):
|
||||||
|
if shutil.which(program):
|
||||||
|
return prefix
|
||||||
|
return ["xterm", "-e"]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -91,8 +102,8 @@ def main():
|
|||||||
# ends the reminder. In its own unit: this one's processes are
|
# ends the reminder. In its own unit: this one's processes are
|
||||||
# stopped when the check exits.
|
# stopped when the check exits.
|
||||||
if state("frontend") == "terminal":
|
if state("frontend") == "terminal":
|
||||||
cmd = ["konsole", "-e", RUN_TERMINAL] if os.access(RUN_TERMINAL, os.X_OK) else \
|
cmd = [*terminal(), RUN_TERMINAL] if os.access(RUN_TERMINAL, os.X_OK) else \
|
||||||
["konsole", "-e", "bash", "-c",
|
[*terminal(), "bash", "-c",
|
||||||
f"set -o pipefail; curl -fsSL --max-time 30 {RELEASE}/steamify.sh | bash; read -rp 'Press Enter to close. ' _"]
|
f"set -o pipefail; curl -fsSL --max-time 30 {RELEASE}/steamify.sh | bash; read -rp 'Press Enter to close. ' _"]
|
||||||
else:
|
else:
|
||||||
cmd = [RUN_APP] if os.access(RUN_APP, os.X_OK) else \
|
cmd = [RUN_APP] if os.access(RUN_APP, os.X_OK) else \
|
||||||
|
|||||||
Reference in new issue
Block a user