From 70ad256365e9981d38ca1607b1847a0f205af7d8 Mon Sep 17 00:00:00 2001 From: natemaia Date: Thu, 6 Jan 2022 18:58:27 -0800 Subject: [PATCH] Clean up sway --- sway-home/.config/nwg-panel/archlabs.json | 201 ------------------ sway-home/.config/nwg-panel/config | 201 ------------------ sway-home/.local/bin/sway-check-updates | 89 ++++++++ sway-home/.local/bin/sway-update | 6 + .../.local/share/nwg-shell-config/settings | 18 -- 5 files changed, 95 insertions(+), 420 deletions(-) delete mode 100644 sway-home/.config/nwg-panel/archlabs.json delete mode 100644 sway-home/.config/nwg-panel/config create mode 100755 sway-home/.local/bin/sway-check-updates create mode 100755 sway-home/.local/bin/sway-update delete mode 100644 sway-home/.local/share/nwg-shell-config/settings diff --git a/sway-home/.config/nwg-panel/archlabs.json b/sway-home/.config/nwg-panel/archlabs.json deleted file mode 100644 index 21f053f5..00000000 --- a/sway-home/.config/nwg-panel/archlabs.json +++ /dev/null @@ -1,201 +0,0 @@ -[ - { - "name": "top", - "output": "", - "layer": "bottom", - "position": "top", - "width": "auto", - "height": 30, - "homogeneous": true, - "margin-top": 0, - "margin-bottom": 0, - "padding-horizontal": 0, - "padding-vertical": 0, - "spacing": 2, - "items-padding": 0, - "css-name": "panel-top", - "icons": "light", - "menu-start": "off", - "modules-left": [ - "sway-workspaces" - ], - "modules-center": [ - "clock" - ], - "modules-right": [ - "executor-updates", - "executor-cpuav", - "executor-cpubar", - "executor-temp", - "executor-memory" - ], - "controls": "right", - "controls-settings": { - "alignment": "right", - "components": [ - "brightness", - "battery", - "volume", - "bluetooth", - "net" - ], - "commands": { - "battery": "", - "net": "nm-connection-editor", - "bluetooth": "blueman-manager" - }, - "custom-items": [ - { - "name": "Wallpapers", - "icon": "azote", - "cmd": "azote" - }, - { - "name": "Look & Feel", - "icon": "preferences-desktop-theme", - "cmd": "lxappearance" - }, - { - "name": "Outputs", - "icon": "wdisplays", - "cmd": "wdisplays && sway-save-outputs" - }, - { - "name": "Panel settings", - "icon": "nwg-panel", - "cmd": "nwg-panel-config" - } - ], - "menu": { - "name": "Exit", - "icon": "system-shutdown-symbolic", - "items": [ - { - "name": "Lock", - "cmd": "swaylock -f -c 000000" - }, - { - "name": "Logout", - "cmd": "swaymsg exit" - }, - { - "name": "Restart", - "cmd": "systemctl reboot" - }, - { - "name": "Shutdown", - "cmd": "systemctl -i poweroff" - } - ] - }, - "show-values": false, - "interval": 1, - "icon-size": 18, - "hover-opens": false, - "leave-closes": true, - "css-name": "panel-top", - "net-interface": "wlan0", - "Exit": "Exittt", - "system-shutdown-symbolic": "system-shutdown", - "output-switcher": true, - "window-width": 320, - "window-margin": 0, - "root-css-name": "controls-overview" - }, - "sway-workspaces": { - "show-layout": false, - "show-icon": true, - "name-length": 20, - "mark-autotiling": false, - "mark-content": true, - "numbers": [ - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8" - ] - }, - "clock": { - "format": "%H:%M:%S", - "interval": 1, - "on-right-click": "", - "tooltip-text": "", - "on-left-click": "gsimplecal", - "on-middle-click": "", - "on-scroll-up": "", - "on-scroll-down": "", - "css-name": "clock", - "root-css-name": "root-clock" - }, - "executor-updates": { - "script": "baph -c", - "interval": 900, - "icon-size": 16, - "on-left-click": "foot bash -c 'baph -unN ; read -p \"Press Enter to finish\"'", - "tooltip-text": "AUR & Official Updates", - "on-middle-click": "", - "on-right-click": "", - "on-scroll-up": "", - "on-scroll-down": "", - "css-name": "", - "root-css-name": "", - "icon-placement": "left" - }, - "executor-cpubar": { - "script": "gopsuinfo -c g", - "interval": 2, - "tooltip-text": "", - "on-left-click": "", - "on-middle-click": "", - "on-right-click": "", - "on-scroll-up": "", - "on-scroll-down": "", - "css-name": "", - "icon-size": 16, - "icon-placement": "left" - }, - "executor-cpuav": { - "script": "gopsuinfo -i a", - "interval": 2, - "tooltip-text": "CPU average load", - "on-left-click": "foot htop", - "on-middle-click": "", - "on-right-click": "", - "on-scroll-up": "", - "on-scroll-down": "", - "css-name": "", - "icon-size": 16, - "icon-placement": "right" - }, - "executor-temp": { - "script": "gopsuinfo -i t", - "interval": 5, - "tooltip-text": "", - "on-left-click": "", - "on-middle-click": "", - "on-right-click": "", - "on-scroll-up": "", - "on-scroll-down": "", - "css-name": "", - "icon-size": 16, - "icon-placement": "left" - }, - "executor-memory": { - "script": "gopsuinfo -i m", - "interval": 5, - "tooltip-text": "", - "on-left-click": "", - "on-middle-click": "", - "on-right-click": "", - "on-scroll-up": "", - "on-scroll-down": "", - "css-name": "", - "icon-size": 16, - "icon-placement": "left" - } - } -] diff --git a/sway-home/.config/nwg-panel/config b/sway-home/.config/nwg-panel/config deleted file mode 100644 index 21f053f5..00000000 --- a/sway-home/.config/nwg-panel/config +++ /dev/null @@ -1,201 +0,0 @@ -[ - { - "name": "top", - "output": "", - "layer": "bottom", - "position": "top", - "width": "auto", - "height": 30, - "homogeneous": true, - "margin-top": 0, - "margin-bottom": 0, - "padding-horizontal": 0, - "padding-vertical": 0, - "spacing": 2, - "items-padding": 0, - "css-name": "panel-top", - "icons": "light", - "menu-start": "off", - "modules-left": [ - "sway-workspaces" - ], - "modules-center": [ - "clock" - ], - "modules-right": [ - "executor-updates", - "executor-cpuav", - "executor-cpubar", - "executor-temp", - "executor-memory" - ], - "controls": "right", - "controls-settings": { - "alignment": "right", - "components": [ - "brightness", - "battery", - "volume", - "bluetooth", - "net" - ], - "commands": { - "battery": "", - "net": "nm-connection-editor", - "bluetooth": "blueman-manager" - }, - "custom-items": [ - { - "name": "Wallpapers", - "icon": "azote", - "cmd": "azote" - }, - { - "name": "Look & Feel", - "icon": "preferences-desktop-theme", - "cmd": "lxappearance" - }, - { - "name": "Outputs", - "icon": "wdisplays", - "cmd": "wdisplays && sway-save-outputs" - }, - { - "name": "Panel settings", - "icon": "nwg-panel", - "cmd": "nwg-panel-config" - } - ], - "menu": { - "name": "Exit", - "icon": "system-shutdown-symbolic", - "items": [ - { - "name": "Lock", - "cmd": "swaylock -f -c 000000" - }, - { - "name": "Logout", - "cmd": "swaymsg exit" - }, - { - "name": "Restart", - "cmd": "systemctl reboot" - }, - { - "name": "Shutdown", - "cmd": "systemctl -i poweroff" - } - ] - }, - "show-values": false, - "interval": 1, - "icon-size": 18, - "hover-opens": false, - "leave-closes": true, - "css-name": "panel-top", - "net-interface": "wlan0", - "Exit": "Exittt", - "system-shutdown-symbolic": "system-shutdown", - "output-switcher": true, - "window-width": 320, - "window-margin": 0, - "root-css-name": "controls-overview" - }, - "sway-workspaces": { - "show-layout": false, - "show-icon": true, - "name-length": 20, - "mark-autotiling": false, - "mark-content": true, - "numbers": [ - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8" - ] - }, - "clock": { - "format": "%H:%M:%S", - "interval": 1, - "on-right-click": "", - "tooltip-text": "", - "on-left-click": "gsimplecal", - "on-middle-click": "", - "on-scroll-up": "", - "on-scroll-down": "", - "css-name": "clock", - "root-css-name": "root-clock" - }, - "executor-updates": { - "script": "baph -c", - "interval": 900, - "icon-size": 16, - "on-left-click": "foot bash -c 'baph -unN ; read -p \"Press Enter to finish\"'", - "tooltip-text": "AUR & Official Updates", - "on-middle-click": "", - "on-right-click": "", - "on-scroll-up": "", - "on-scroll-down": "", - "css-name": "", - "root-css-name": "", - "icon-placement": "left" - }, - "executor-cpubar": { - "script": "gopsuinfo -c g", - "interval": 2, - "tooltip-text": "", - "on-left-click": "", - "on-middle-click": "", - "on-right-click": "", - "on-scroll-up": "", - "on-scroll-down": "", - "css-name": "", - "icon-size": 16, - "icon-placement": "left" - }, - "executor-cpuav": { - "script": "gopsuinfo -i a", - "interval": 2, - "tooltip-text": "CPU average load", - "on-left-click": "foot htop", - "on-middle-click": "", - "on-right-click": "", - "on-scroll-up": "", - "on-scroll-down": "", - "css-name": "", - "icon-size": 16, - "icon-placement": "right" - }, - "executor-temp": { - "script": "gopsuinfo -i t", - "interval": 5, - "tooltip-text": "", - "on-left-click": "", - "on-middle-click": "", - "on-right-click": "", - "on-scroll-up": "", - "on-scroll-down": "", - "css-name": "", - "icon-size": 16, - "icon-placement": "left" - }, - "executor-memory": { - "script": "gopsuinfo -i m", - "interval": 5, - "tooltip-text": "", - "on-left-click": "", - "on-middle-click": "", - "on-right-click": "", - "on-scroll-up": "", - "on-scroll-down": "", - "css-name": "", - "icon-size": 16, - "icon-placement": "left" - } - } -] diff --git a/sway-home/.local/bin/sway-check-updates b/sway-home/.local/bin/sway-check-updates new file mode 100755 index 00000000..68e26f8c --- /dev/null +++ b/sway-home/.local/bin/sway-check-updates @@ -0,0 +1,89 @@ +#!/usr/bin/python + +import os +import time +import subprocess +import argparse + + +# You may either use the full icon(s) path here, like e.g.: +# "/home/piotr/.config/nwg-panel/icons_light/arch-linux.svg" +# or just give the icon name, like below. + +# The icon must either exist in your icon theme, or you may place `icon_name.svg` +# custom files in '~/.config/nwg-panel/icons_light/' and '~/.config/nwg-panel/icons_dark/'. + +def check(interval): + # Avoid checking on each panel restart: check if the time given as `interval` passed first. + # Make sure if the path below matches your temp directory. + file = "/tmp/archlabs-updates" + + if os.path.isfile(file): + if int(time.time() - os.stat(file).st_mtime) > interval: + arch, aur = check_updates() + save_string("{},{}".format(arch, aur), file) + else: + try: + vals = load_string(file).split(",") + arch, aur = int(vals[0]), int(vals[1]) + except: + arch, aur = 0, 0 + else: + arch, aur = check_updates() + save_string("{},{}".format(arch, aur), file) + + if arch > 0 and aur > 0: + print("software-update-available") + print("{}/{}".format(arch, aur)) + elif arch > 0: + print("software-update-available") + print("{}".format(arch)) + elif aur > 0: + print("software-update-available") + print("{}".format(aur)) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("-i", + "--interval", + type=int, + default=900, + help="check Interval in seconds") + args = parser.parse_args() + + check(args.interval) + + +def save_string(string, file): + try: + file = open(file, "wt") + file.write(string) + file.close() + except: + print("Error writing file '{}'".format(file)) + + +def load_string(path): + try: + with open(path, 'r') as file: + data = file.read() + return data + except: + return "" + + +def check_updates(): + arch, aur = 0, 0 + try: + output = subprocess.check_output(["baph", "-c"]).decode("utf-8").split() + aur = int(output[0]) + arch = int(output[1]) + except Exception as e: + print(e) + + return arch, aur + + +if __name__ == "__main__": + main() diff --git a/sway-home/.local/bin/sway-update b/sway-home/.local/bin/sway-update new file mode 100755 index 00000000..482112c5 --- /dev/null +++ b/sway-home/.local/bin/sway-update @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +baph -u && +rm /tmp/archlabs-updates; +echo Press enter to exit...; read; +swaymsg reload diff --git a/sway-home/.local/share/nwg-shell-config/settings b/sway-home/.local/share/nwg-shell-config/settings deleted file mode 100644 index 0b543b6a..00000000 --- a/sway-home/.local/share/nwg-shell-config/settings +++ /dev/null @@ -1,18 +0,0 @@ -{ - "keyboard-layout": "", - "autotiling-workspaces": "1 2 3 4 5 6 7 8", - "autotiling-on": true, - "night-lat": -1, - "night-long": -1, - "night-temp-low": 4500, - "night-temp-high": 6500, - "night-gamma": 1.0, - "night-on": true, - "terminal": "foot", - "file-manager": "thunar", - "editor": "mousepad", - "browser": "chromium --disable-gpu-memory-buffer-video-frames --enable-features=UseOzonePlatform --ozone-platform=wayland", - "panel-preset": "custom", - "panel-custom": "archlabs.json", - "show-on-startup": true -}