Huge Updates
This commit is contained in:
30 files changed
+1421
-1260
No files matched your search
Executable
+164
@@ -0,0 +1,164 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Word of caution: changing this can break update module, be vigilant
|
||||
|
||||
check_arch_updates() {
|
||||
official_updates=0
|
||||
aur_updates=0
|
||||
flatpak_updates=0
|
||||
tooltip="" # Initialize tooltip variable
|
||||
|
||||
# Get the number of official updates using 'checkupdates'
|
||||
official_updates=$(checkupdates 2>/dev/null | wc -l)
|
||||
|
||||
if command -v paru &>/dev/null; then
|
||||
aur_helper="paru"
|
||||
else
|
||||
aur_helper="yay"
|
||||
fi
|
||||
|
||||
# Get the number of AUR updates using 'yay'
|
||||
aur_updates=$($aur_helper -Qum 2>/dev/null | wc -l)
|
||||
|
||||
# Calculate total updates
|
||||
total_updates=$((official_updates + aur_updates + flatpak_updates))
|
||||
|
||||
# Build the tooltip for official updates
|
||||
tooltip=" Official $official_updates\n AUR $aur_updates"
|
||||
|
||||
# Check if flatpak is installed
|
||||
if command -v flatpak &>/dev/null; then
|
||||
# Get the number of Flatpak updates if flatpak is installed
|
||||
flatpak_updates=$(flatpak remote-ls --updates | wc -l)
|
||||
|
||||
# Append Flatpak updates to the tooltip
|
||||
tooltip="$tooltip\n Flatpak $flatpak_updates"
|
||||
|
||||
# Recalculate total updates
|
||||
total_updates=$((official_updates + aur_updates + flatpak_updates))
|
||||
fi
|
||||
|
||||
# Output the result as a JSON object
|
||||
echo "{\"total\":\"$total_updates\", \"tooltip\":\"$tooltip\"}"
|
||||
}
|
||||
|
||||
check_ubuntu_updates() {
|
||||
official_updates=0
|
||||
flatpak_updates=0
|
||||
|
||||
# Check if flatpak is installed and get Flatpak updates if it is
|
||||
if command -v flatpak &>/dev/null; then
|
||||
flatpak_updates=$(flatpak remote-ls --updates | wc -l)
|
||||
# Always show Flatpak updates in the tooltip, even if there are none
|
||||
tooltip=" Official $official_updates\n Flatpak $flatpak_updates"
|
||||
else
|
||||
# If flatpak is not installed, only show official updates
|
||||
tooltip=" Official $official_updates"
|
||||
fi
|
||||
|
||||
# Get the number of official updates using 'apt-get'
|
||||
official_updates=$(apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst)
|
||||
|
||||
# Calculate total updates
|
||||
total_updates=$((official_updates + flatpak_updates))
|
||||
|
||||
# Output the result as a JSON object
|
||||
echo "{\"total\":\"$total_updates\", \"tooltip\":\"$tooltip\"}"
|
||||
}
|
||||
|
||||
check_fedora_updates() {
|
||||
official_updates=0
|
||||
flatpak_updates=0
|
||||
|
||||
# Get the number of official updates using 'dnf'
|
||||
official_updates=$(dnf check-update -q | grep -v '^Loaded plugins' | grep -v '^No match for' | wc -l)
|
||||
|
||||
# Calculate total updates
|
||||
total_updates=$((official_updates + flatpak_updates))
|
||||
|
||||
# Check if flatpak is installed and get Flatpak updates if it is
|
||||
if command -v flatpak &>/dev/null; then
|
||||
flatpak_updates=$(flatpak remote-ls --updates | wc -l)
|
||||
# Always show Flatpak updates in the tooltip, even if there are none
|
||||
tooltip=" Official $official_updates\n Flatpak $flatpak_updates"
|
||||
else
|
||||
# If flatpak is not installed, only show official updates
|
||||
tooltip=" Official $official_updates"
|
||||
fi
|
||||
|
||||
# Output the result as a JSON object
|
||||
echo "{\"total\":\"$total_updates\", \"tooltip\":\"$tooltip\"}"
|
||||
}
|
||||
|
||||
check_opensuse_updates() {
|
||||
official_updates=0
|
||||
flatpak_updates=0
|
||||
|
||||
# Check if flatpak is installed and get Flatpak updates if it is
|
||||
if command -v flatpak &>/dev/null; then
|
||||
flatpak_updates=$(flatpak remote-ls --updates | wc -l)
|
||||
fi
|
||||
|
||||
# Get the number of official updates using 'dnf'
|
||||
official_updates=$(zypper lu | wc -l)
|
||||
|
||||
# Calculate total updates
|
||||
total_updates=$((official_updates + flatpak_updates))
|
||||
|
||||
# Check if flatpak is installed and get Flatpak updates if it is
|
||||
if command -v flatpak &>/dev/null; then
|
||||
flatpak_updates=$(flatpak remote-ls --updates | wc -l)
|
||||
# Always show Flatpak updates in the tooltip, even if there are none
|
||||
tooltip=" Official $official_updates\n Flatpak $flatpak_updates"
|
||||
else
|
||||
# If flatpak is not installed, only show official updates
|
||||
tooltip=" Official $official_updates"
|
||||
fi
|
||||
|
||||
# Output the result as a JSON object
|
||||
echo "{\"total\":\"$total_updates\", \"tooltip\":\"$tooltip\"}"
|
||||
}
|
||||
|
||||
update_arch() {
|
||||
command="
|
||||
fastfetch
|
||||
yay -Syu
|
||||
read -n 1 -p 'Press any key to continue...'
|
||||
"
|
||||
kitty --title systemupdate sh -c "${command}"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
-arch)
|
||||
if [ -z "$2" ]; then # If second argument is null (not provided)
|
||||
check_arch_updates
|
||||
else
|
||||
update_arch
|
||||
fi
|
||||
;;
|
||||
-ubuntu)
|
||||
if [ -z "$2" ]; then # If second argument is null (not provided)
|
||||
check_ubuntu_updates
|
||||
else
|
||||
update_ubuntu
|
||||
fi
|
||||
;;
|
||||
-fedora)
|
||||
if [ -z "$2" ]; then # If second argument is null (not provided)
|
||||
check_fedora_updates
|
||||
else
|
||||
update_fedora
|
||||
fi
|
||||
;;
|
||||
-suse)
|
||||
if [ -z "$2" ]; then # If second argument is null (not provided)
|
||||
check_opensuse_updates
|
||||
else
|
||||
update_arch
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [-arch|-ubuntu|-fedora|-suse] [up (optional)]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -1,83 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
from signal import SIGINT, SIGTERM, signal
|
||||
from threading import Event
|
||||
import setproctitle
|
||||
|
||||
from pywayland.client.display import Display # type: ignore
|
||||
from pywayland.protocol.idle_inhibit_unstable_v1.zwp_idle_inhibit_manager_v1 import ( # type: ignore
|
||||
ZwpIdleInhibitManagerV1,
|
||||
)
|
||||
from pywayland.protocol.wayland.wl_compositor import WlCompositor # type: ignore
|
||||
from pywayland.protocol.wayland.wl_registry import WlRegistryProxy # type: ignore
|
||||
from pywayland.protocol.wayland.wl_surface import WlSurface # type: ignore
|
||||
|
||||
|
||||
@dataclass
|
||||
class GlobalRegistry:
|
||||
surface: WlSurface | None = None
|
||||
inhibit_manager: ZwpIdleInhibitManagerV1 | None = None
|
||||
|
||||
|
||||
def handle_registry_global(
|
||||
wl_registry: WlRegistryProxy, id_num: int, iface_name: str, version: int
|
||||
) -> None:
|
||||
global_registry: GlobalRegistry = wl_registry.user_data or GlobalRegistry()
|
||||
|
||||
if iface_name == "wl_compositor":
|
||||
compositor = wl_registry.bind(id_num, WlCompositor, version)
|
||||
global_registry.surface = compositor.create_surface() # type: ignore
|
||||
elif iface_name == "zwp_idle_inhibit_manager_v1":
|
||||
global_registry.inhibit_manager = wl_registry.bind(
|
||||
id_num, ZwpIdleInhibitManagerV1, version
|
||||
)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
done = Event()
|
||||
signal(SIGINT, lambda _, __: done.set())
|
||||
signal(SIGTERM, lambda _, __: done.set())
|
||||
|
||||
global_registry = GlobalRegistry()
|
||||
|
||||
display = Display()
|
||||
display.connect()
|
||||
|
||||
registry = display.get_registry() # type: ignore
|
||||
registry.user_data = global_registry
|
||||
registry.dispatcher["global"] = handle_registry_global
|
||||
|
||||
def shutdown() -> None:
|
||||
display.dispatch()
|
||||
display.roundtrip()
|
||||
display.disconnect()
|
||||
|
||||
display.dispatch()
|
||||
display.roundtrip()
|
||||
|
||||
if global_registry.surface is None or global_registry.inhibit_manager is None:
|
||||
print("Wayland seems not to support idle_inhibit_unstable_v1 protocol.")
|
||||
shutdown()
|
||||
sys.exit(1)
|
||||
|
||||
inhibitor = global_registry.inhibit_manager.create_inhibitor( # type: ignore
|
||||
global_registry.surface
|
||||
)
|
||||
|
||||
display.dispatch()
|
||||
display.roundtrip()
|
||||
|
||||
print("Inhibiting idle...")
|
||||
done.wait()
|
||||
print("Shutting down...")
|
||||
|
||||
inhibitor.destroy()
|
||||
|
||||
shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
setproctitle.setproctitle("wayland-idle-inhibitor.py")
|
||||
main()
|
||||
Reference in new issue
Block a user