diff --git a/modules/common/Config.qml b/modules/common/Config.qml index 97f2c02f..0ee70489 100644 --- a/modules/common/Config.qml +++ b/modules/common/Config.qml @@ -210,8 +210,16 @@ Singleton { property string networkEthernet: "kcmshell6 kcm_networkmanagement" property string taskManager: "plasma-systemmonitor --page-name Processes" property string terminal: "kitty -1" // This is only for shell actions - property string update: "kitty -1 --hold=yes fish -i -c 'pkexec pacman -Syu'" - property string volumeMixer: `~/.config/hypr/hyprland/scripts/launch_first_available.sh "pavucontrol-qt" "pavucontrol"` + property string update: "kitty -1 --hold=yes bash -c " + "\n if [ \"${SystemInfo.distroId}\" = \"arch\" ] || [ \"${SystemInfo.distroId}\" = \"cachyos\" ] || [ \"${SystemInfo.distroId}\" = \"endeavouros\" ]; then + yay -Syu --combinedupgrade=false + elif command -v apt &>/dev/null && [ -f /etc/debian_version ]; then + sudo apt update && sudo apt upgrade -y + else + echo \"Unsupported distro\" && read -p \"Press Enter...\" + fi + " + property string volumeMixer: `~/.config/hypr/hyprland/scripts/launch_first_available.sh "pavucontrol-qt" "pavucontrol"`property string volumeMixer: `~/.config/hypr/hyprland/scripts/launch_first_available.sh "pavucontrol-qt" "pavucontrol"` } property JsonObject settings: JsonObject { diff --git a/modules/ii/bar/UpdatesCount.qml b/modules/ii/bar/UpdatesCount.qml index ae942bdd..a3717079 100644 --- a/modules/ii/bar/UpdatesCount.qml +++ b/modules/ii/bar/UpdatesCount.qml @@ -14,7 +14,7 @@ MouseArea { property bool isMaterial: Config.options.bar.cornerStyle === 3 property bool borderless: Config.options.bar.borderless - implicitWidth: vertical ? Appearance.sizes.verticalBarWidth : (contentLoader.item?.implicitWidth ?? 0) + implicitWidth: vertical ? Appearance.sizes.verticalBarWidth : (contentLoader.item?.implicitWidth ?? 0) implicitHeight: vertical ? (contentLoader.item?.implicitHeight ?? 0) : Appearance.sizes.barHeight cursorShape: Qt.PointingHandCursor @@ -29,7 +29,8 @@ MouseArea { onPressed: (mouse) => { if (mouse.button === Qt.RightButton) { Updates.refresh() - Quickshell.execDetached(["notify-send", + Quickshell.execDetached([ + "notify-send", Translation.tr("Updates"), Translation.tr("Checking for updates..."), "-a", "Shell" @@ -42,8 +43,17 @@ MouseArea { id: updateProc command: [ "kitty", "--hold", - "fish", "-i", "-l", "-c", - "yay -Syu --combinedupgrade=false" + "bash", "-c", + "\ + if [ \"${SystemInfo.distroId}\" = \"arch\" ] || [ \"${SystemInfo.distroId}\" = \"cachyos\" ] || [ \"${SystemInfo.distroId}\" = \"endeavouros\" ]; then + yay -Syu --combinedupgrade=false + elif command -v apt &>/dev/null && [ -f /etc/debian_version ]; then + sudo apt update && sudo apt upgrade -y + else + echo \"Unsupported distro for updates\" + read -p \"Press Enter to exit...\" + fi + " ] onExited: (exitCode, exitStatus) => { Updates.refresh() @@ -57,13 +67,15 @@ MouseArea { repeat: false onTriggered: { if (Updates.count === 0) { - Quickshell.execDetached(["notify-send", + Quickshell.execDetached([ + "notify-send", Translation.tr("Updates"), Translation.tr("System up to date"), "-a", "Shell" ]) } else { - Quickshell.execDetached(["notify-send", + Quickshell.execDetached([ + "notify-send", Translation.tr("Updates"), Translation.tr("Update cancelled — %1 updates still pending").arg(Updates.count), "-a", "Shell", "-u", "normal" @@ -186,4 +198,4 @@ MouseArea { } } } -} \ No newline at end of file +} diff --git a/modules/ii/settings/pages/About.qml b/modules/ii/settings/pages/About.qml index 1f99d4c2..f080e83c 100644 --- a/modules/ii/settings/pages/About.qml +++ b/modules/ii/settings/pages/About.qml @@ -17,8 +17,17 @@ ContentPage { function runSystemUpdate() { Quickshell.execDetached([ "kitty", "--hold", - "fish", "-i", "-l", "-c", - "yay -Syu --combinedupgrade=false" + "bash", "-c", + "\ + if [ \"${SystemInfo.distroId}\" = \"arch\" ] || [ \"${SystemInfo.distroId}\" = \"cachyos\" ] || [ \"${SystemInfo.distroId}\" = \"endeavouros\" ]; then + yay -Syu --combinedupgrade=false + elif command -v apt &>/dev/null && [ -f /etc/debian_version ]; then + sudo apt update && sudo apt upgrade -y + else + echo \"Unsupported distro for updates\" + read -p \"Press Enter to exit...\" + fi + " ]) Qt.callLater(() => GlobalStates.settingsOpen = false) } @@ -53,7 +62,7 @@ ContentPage { Rectangle { Layout.fillWidth: true - Layout.preferredHeight: 156 + Layout.preferredHeight: 156 Layout.topMargin: !isMinimal ? 35 : 4 Layout.leftMargin: !isMinimal ? 16 : 0 Layout.rightMargin: !isMinimal ? 16 : 0 @@ -161,7 +170,7 @@ ContentPage { Layout.topMargin: !isMinimal ? 0 : -8 spacing: 8 - RowLayout { //This is not in the grid because I was planning to do something else. + RowLayout { // This is not in the grid because I was planning to do something else. Layout.fillWidth: true spacing: 8 @@ -241,4 +250,4 @@ ContentPage { } } } -} \ No newline at end of file +} diff --git a/modules/ii/settings/pages/ServicesConfig.qml b/modules/ii/settings/pages/ServicesConfig.qml index a57b7d31..2c6cde06 100644 --- a/modules/ii/settings/pages/ServicesConfig.qml +++ b/modules/ii/settings/pages/ServicesConfig.qml @@ -302,7 +302,7 @@ ContentPage { ContentSection { icon: "deployed_code_update" - title: Translation.tr("System updates (Arch only)") + title: Translation.tr("System updates") GroupedList { ConfigSwitch { diff --git a/scripts/colors/switchwall.sh b/scripts/colors/switchwall.sh index f0f81cc0..225ea8ec 100755 --- a/scripts/colors/switchwall.sh +++ b/scripts/colors/switchwall.sh @@ -84,21 +84,30 @@ check_and_prompt_upscale() { if command -v upscayl &>/dev/null; then nohup upscayl > /dev/null 2>&1 & else + if [[ "$distro_id" == "arch" || "$distro_id" == "cachyos" || "$distro_id" == "endeavouros" ]]; then + install_cmd="yay -S upscayl-bin" + install_label="Install Upscayl (Arch)" + elif command -v apt &>/dev/null && [ -f /etc/debian_version ]; then + install_cmd="sudo apt install upscayl" + install_label="Install Upscayl (Debian/Kali)" + else + install_cmd="sudo apt install upscayl" + install_label="Install Upscayl" + fi action2=$(notify-send \ -a "Wallpaper switcher" \ -c "im.error" \ - -A "install_upscayl=Install Upscayl (Arch)" \ + -A "install_upscayl=$install_label" \ "Install Upscayl?" \ - "yay -S upscayl-bin") + "$install_cmd") if [[ "$action2" == "install_upscayl" ]]; then - kitty -1 yay -S upscayl-bin + kitty -1 $install_cmd if command -v upscayl &>/dev/null; then nohup upscayl > /dev/null 2>&1 & fi fi fi fi - fi fi } @@ -212,15 +221,25 @@ switch() { fi if [ ${#missing_deps[@]} -gt 0 ]; then echo "Missing deps: ${missing_deps[*]}" - echo "Arch: sudo pacman -S ${missing_deps[*]}" + if [[ "$distro_id" == "arch" || "$distro_id" == "cachyos" || "$distro_id" == "endeavouros" ]]; then + install_cmd="sudo pacman -S ${missing_deps[*]}" + install_label="Install (Arch)" + elif command -v apt &>/dev/null && [ -f /etc/debian_version ]; then + install_cmd="sudo apt install ${missing_deps[*]}" + install_label="Install (Debian/Kali)" + else + install_cmd="sudo apt install ${missing_deps[*]}" + install_label="Install" + fi + echo "Install: $install_cmd" action=$(notify-send \ -a "Wallpaper switcher" \ -c "im.error" \ - -A "install_arch=Install (Arch)" \ + -A "install_deps=$install_label" \ "Can't switch to video wallpaper" \ "Missing dependencies: ${missing_deps[*]}") - if [[ "$action" == "install_arch" ]]; then - kitty -1 sudo pacman -S "${missing_deps[*]}" + if [[ "$action" == "install_deps" ]]; then + kitty -1 $install_cmd if command -v mpvpaper &>/dev/null && command -v ffmpeg &>/dev/null; then notify-send 'Wallpaper switcher' 'Alright, try again!' -a "Wallpaper switcher" fi diff --git a/services/SystemInfo.qml b/services/SystemInfo.qml index 240fed8a..b732e76e 100644 --- a/services/SystemInfo.qml +++ b/services/SystemInfo.qml @@ -194,7 +194,24 @@ Singleton { Process { id: getPackages running: false - command: ["bash", "-c", "pacman_count=$(pacman -Q | wc -l); flatpak_count=$(flatpak list 2>/dev/null | wc -l || echo 0); if [ \"$flatpak_count\" -gt 0 ]; then echo \"$pacman_count pacman, $flatpak_count fp\"; else echo \"$pacman_count pacman\"; fi"] + command: ["bash", "-c", "\ + if [ \"${SystemInfo.distroId}\" = \"arch\" ] || [ \"${SystemInfo.distroId}\" = \"cachyos\" ] || [ \"${SystemInfo.distroId}\" = \"endeavouros\" ]; then + pkg_count=$(pacman -Q 2>/dev/null | wc -l) + pkg_tool=\"pacman\" + elif command -v dpkg &>/dev/null; then + pkg_count=$(dpkg -l 2>/dev/null | grep -c '^ii' || echo 0) + pkg_tool=\"dpkg\" + else + pkg_count=0 + pkg_tool=\"unknown\" + fi + flatpak_count=$(flatpak list 2>/dev/null | wc -l || echo 0) + if [ \"$flatpak_count\" -gt 0 ]; then + echo \"${pkg_count} ${pkg_tool}, ${flatpak_count} fp\" + else + echo \"${pkg_count} ${pkg_tool}\" + fi + "] stdout: SplitParser { onRead: data => root.packages = data.trim() } } diff --git a/services/Updates.qml b/services/Updates.qml index 8e605de4..a9d79cac 100644 --- a/services/Updates.qml +++ b/services/Updates.qml @@ -7,7 +7,8 @@ import Quickshell import Quickshell.Io /* - * System updates service. Currently only supports Arch. + * System updates service. + * Supports Arch (pacman/checkupdates/yay) and Debian-based (apt). */ Singleton { id: root @@ -15,7 +16,7 @@ Singleton { property bool available: false property alias checking: checkUpdatesProc.running property int count: 0 - + readonly property bool updateAdvised: available && count > Config.options.updates.adviseUpdateThreshold readonly property bool updateStronglyAdvised: available && count > Config.options.updates.stronglyAdviseUpdateThreshold @@ -36,19 +37,41 @@ Singleton { } } + // Distro-aware availability check Process { id: checkAvailabilityProc running: Config.ready && Config.options.updates.enableCheck - command: ["which", "checkupdates"] + command: ["bash", "-c", "\ + if [ \"${SystemInfo.distroId}\" = \"arch\" ] || [ \"${SystemInfo.distroId}\" = \"cachyos\" ] || [ \"${SystemInfo.distroId}\" = \"endeavouros\" ]; then + which checkupdates >/dev/null 2>&1 && echo \"arch\" + elif command -v apt &>/dev/null && [ -f /etc/debian_version ]; then + echo \"debian\" + else + echo \"unsupported\" + fi + "] onExited: (exitCode, exitStatus) => { - root.available = (exitCode === 0); - root.refresh(); + const out = (exitStatus?.toString() ?? "").trim() + root.available = (out === "arch" || out === "debian") + root.refresh() } } + // Distro-aware update count Process { id: checkUpdatesProc - command: ["bash", "-c", "pacman=$(checkupdates 2>/dev/null | wc -l); aur=$(yay -Qua 2>/dev/null | wc -l || paru -Qua 2>/dev/null | wc -l || echo 0); echo $((pacman + aur))"] + command: ["bash", "-c", "\ + if [ \"${SystemInfo.distroId}\" = \"arch\" ] || [ \"${SystemInfo.distroId}\" = \"cachyos\" ] || [ \"${SystemInfo.distroId}\" = \"endeavouros\" ]; then + pacman=$(checkupdates 2>/dev/null | wc -l) + aur=$(yay -Qua 2>/dev/null | wc -l || paru -Qua 2>/dev/null | wc -l || echo 0) + echo $((pacman + aur)) + elif command -v apt &>/dev/null && [ -f /etc/debian_version ]; then + apt update -qq 2>/dev/null + apt list --upgradable 2>/dev/null | tail -n +2 | wc -l + else + echo 0 + fi + "] stdout: StdioCollector { onStreamFinished: { root.count = parseInt(text.trim()) diff --git a/translations/en_US.json b/translations/en_US.json index dd3be71a..dabb78db 100644 --- a/translations/en_US.json +++ b/translations/en_US.json @@ -638,7 +638,7 @@ "Symbol": "Symbol", "System Age •": "System Age •", "System Icons": "System Icons", - "System updates (Arch only)": "System updates (Arch only)", + "System updates": "System updates", "There might be a download in progress. Check your Downloads folder.": "There might be a download in progress. Check your Downloads folder.", "Title font": "Title font", "Toggle anime results. Usage: %1anime SHOW/HIDE": "Toggle anime results. Usage: %1anime SHOW/HIDE",