From db3042111fd954cd568eee12a34d80fca8eb5b91 Mon Sep 17 00:00:00 2001 From: Nydragon Date: Sat, 21 Sep 2024 02:05:00 +0200 Subject: [PATCH] feat: hacky network and notification widget and caffeine widget Network and notification widgets are just buttons to open nmtui and swaync respectively... what they are doing in my waybar right now anyways. Now I *should* not need waybar anymore. Caffeine widget does what there is to do, set an inhibitor. Restructured the project so that icons are in src/, screenshots are in the renamed screenshots folder --- .pre-commit-config.yaml | 20 ++++++++++++ README.md | 4 +-- flake.lock | 20 ++++++------ flake.nix | 4 +++ .../2024-08-28-audio-manager.png | Bin .../2024-08-28-main-bar.png | Bin src/AudioOutput.qml | 2 +- src/Bar.qml | 12 ++++++- {assets => src/assets}/audio-volume-high.svg | 0 {assets => src/assets}/audio-volume-muted.svg | 0 src/assets/eye-closed.svg | 4 +++ src/assets/eye-open.svg | 5 +++ {assets => src/assets}/folder-music.svg | 0 {assets => src/assets}/mute.png | Bin {assets => src/assets}/speaker.png | Bin {assets => src/assets}/volume-mute.png | Bin src/base/BRectangle.qml | 3 +- src/widgets/caffeine/Caffeine.qml | 30 ++++++++++++++++++ src/widgets/network/Network.qml | 30 ++++++++++++++++++ src/widgets/notifcenter/Notifcenter.qml | 30 ++++++++++++++++++ src/widgets/systray/SysTrayItem.qml | 19 +++-------- src/windows/audioman/AudioEntry.qml | 6 ++-- 22 files changed, 156 insertions(+), 33 deletions(-) create mode 100644 .pre-commit-config.yaml rename {assets => screenshots}/2024-08-28-audio-manager.png (100%) rename {assets => screenshots}/2024-08-28-main-bar.png (100%) rename {assets => src/assets}/audio-volume-high.svg (100%) rename {assets => src/assets}/audio-volume-muted.svg (100%) create mode 100644 src/assets/eye-closed.svg create mode 100644 src/assets/eye-open.svg rename {assets => src/assets}/folder-music.svg (100%) rename {assets => src/assets}/mute.png (100%) rename {assets => src/assets}/speaker.png (100%) rename {assets => src/assets}/volume-mute.png (100%) create mode 100644 src/widgets/caffeine/Caffeine.qml create mode 100644 src/widgets/network/Network.qml create mode 100644 src/widgets/notifcenter/Notifcenter.qml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..f5c3035 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +default_install_hook_types: + - pre-commit + - commit-msg + +repos: + - repo: https://github.com/gitleaks/gitleaks + rev: v8.18.2 + hooks: + - id: gitleaks + stages: [commit] + + - repo: local + hooks: + - id: typos + name: Check for typos + entry: typos + language: system + files: .* + exclude: .*\.(png|jpg|jpeg|age) + stages: [commit] diff --git a/README.md b/README.md index 72751f1..c5de4c4 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ Nysh is written in QML using [Quickshell]. ## Work in Progress Showcase -![Main Bar](./assets/2024-08-28-main-bar.png) +![Main Bar](./screenshots/2024-08-28-main-bar.png) -![Audio Manager](./assets/2024-08-28-audio-manager.png) +![Audio Manager](./screenshots/2024-08-28-audio-manager.png) ## Launching the shell diff --git a/flake.lock b/flake.lock index 9536f99..ca86d85 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1726243404, - "narHash": "sha256-sjiGsMh+1cWXb53Tecsm4skyFNag33GPbVgCdfj3n9I=", + "lastModified": 1726755586, + "narHash": "sha256-PmUr/2GQGvFTIJ6/Tvsins7Q43KTMvMFhvG6oaYK+Wk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "345c263f2f53a3710abe117f28a5cb86d0ba4059", + "rev": "c04d5652cfa9742b1d519688f65d1bbccea9eb7e", "type": "github" }, "original": { @@ -23,11 +23,11 @@ ] }, "locked": { - "lastModified": 1726441580, - "narHash": "sha256-/uiDpaZUZVwqI4d0rPjT2N4qp2+eQA4GZQwEr8e+0XM=", + "lastModified": 1726641881, + "narHash": "sha256-ee2YIeFbYhm/gGs26grUW37BxqqDoFNElW1Vy5PIuHA=", "ref": "refs/heads/master", - "rev": "c57ac4b1f283896bab7fb91e8fdc9249c18d3afe", - "revCount": 344, + "rev": "7f9762be5368ca33b84e7b2b3e23a626d432436d", + "revCount": 348, "type": "git", "url": "https://git.outfoxxed.me/outfoxxed/quickshell" }, @@ -63,11 +63,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 5a8e517..faec8ac 100644 --- a/flake.nix +++ b/flake.nix @@ -24,11 +24,15 @@ buildInputs = [ quickshell pkgs.kdePackages.qtdeclarative + pkgs.pre-commit + pkgs.typos + ]; shellHook = '' # Required for qmlls to find the correct type declarations # Sadly Quickshell doesn't export some types declaratively export QMLLS_BUILD_DIRS=${pkgs.kdePackages.qtdeclarative}/lib/qt-6/qml/:${quickshell}/lib/qt-6/qml/ + ${pkgs.pre-commit}/bin/pre-commit install -f ''; }; defaultPackage = import ./nix/package.nix { diff --git a/assets/2024-08-28-audio-manager.png b/screenshots/2024-08-28-audio-manager.png similarity index 100% rename from assets/2024-08-28-audio-manager.png rename to screenshots/2024-08-28-audio-manager.png diff --git a/assets/2024-08-28-main-bar.png b/screenshots/2024-08-28-main-bar.png similarity index 100% rename from assets/2024-08-28-main-bar.png rename to screenshots/2024-08-28-main-bar.png diff --git a/src/AudioOutput.qml b/src/AudioOutput.qml index b8c75ac..b4fe083 100644 --- a/src/AudioOutput.qml +++ b/src/AudioOutput.qml @@ -48,7 +48,7 @@ BRectangle { // TODO: Make icon depend on sink type and volume level Image { id: icon - source: "root:/../assets/speaker.png" + source: "root:/assets/speaker.png" width: parent.width * (2 / 3) anchors.horizontalCenter: parent.horizontalCenter diff --git a/src/Bar.qml b/src/Bar.qml index e630d98..fc88acf 100644 --- a/src/Bar.qml +++ b/src/Bar.qml @@ -5,6 +5,9 @@ import "widgets/systray" import "widgets/workspaces" import "widgets/privacy" import "widgets/battery" +import "widgets/network" +import "widgets/notifcenter" +import "widgets/caffeine" Scope { Variants { @@ -40,7 +43,14 @@ Scope { Workspaces {} Battery {} - Privacy {} + + //Privacy {} + + Network {} + + Notifcenter {} + + Caffeine {} Item { Layout.fillHeight: true diff --git a/assets/audio-volume-high.svg b/src/assets/audio-volume-high.svg similarity index 100% rename from assets/audio-volume-high.svg rename to src/assets/audio-volume-high.svg diff --git a/assets/audio-volume-muted.svg b/src/assets/audio-volume-muted.svg similarity index 100% rename from assets/audio-volume-muted.svg rename to src/assets/audio-volume-muted.svg diff --git a/src/assets/eye-closed.svg b/src/assets/eye-closed.svg new file mode 100644 index 0000000..ef75b06 --- /dev/null +++ b/src/assets/eye-closed.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/assets/eye-open.svg b/src/assets/eye-open.svg new file mode 100644 index 0000000..3fe5720 --- /dev/null +++ b/src/assets/eye-open.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/assets/folder-music.svg b/src/assets/folder-music.svg similarity index 100% rename from assets/folder-music.svg rename to src/assets/folder-music.svg diff --git a/assets/mute.png b/src/assets/mute.png similarity index 100% rename from assets/mute.png rename to src/assets/mute.png diff --git a/assets/speaker.png b/src/assets/speaker.png similarity index 100% rename from assets/speaker.png rename to src/assets/speaker.png diff --git a/assets/volume-mute.png b/src/assets/volume-mute.png similarity index 100% rename from assets/volume-mute.png rename to src/assets/volume-mute.png diff --git a/src/base/BRectangle.qml b/src/base/BRectangle.qml index b35ce5b..949fcea 100644 --- a/src/base/BRectangle.qml +++ b/src/base/BRectangle.qml @@ -2,8 +2,9 @@ import QtQuick Rectangle { width: parent.width - height: parent.height + height: width border.color: "black" border.width: 2 radius: 5 + color: "#BD93F9" } diff --git a/src/widgets/caffeine/Caffeine.qml b/src/widgets/caffeine/Caffeine.qml new file mode 100644 index 0000000..497c3ee --- /dev/null +++ b/src/widgets/caffeine/Caffeine.qml @@ -0,0 +1,30 @@ +import "root:base" +import QtQuick +import Quickshell.Io +import Quickshell.Widgets +import Quickshell + +BRectangle { + id: caffeine + property bool inhibiting: false + + MouseArea { + anchors.fill: parent + + IconImage { + anchors.fill: parent + anchors.margins: 4 + source: caffeine.inhibiting ? "root:assets/eye-open.svg" : "root:assets/eye-closed.svg" + } + + onClicked: () => { + caffeine.inhibiting = !caffeine.inhibiting; + } + + Process { + id: inhibitor + running: caffeine.inhibiting + command: ["systemd-inhibit", "sleep", "infinity"] + } + } +} diff --git a/src/widgets/network/Network.qml b/src/widgets/network/Network.qml new file mode 100644 index 0000000..1491ed4 --- /dev/null +++ b/src/widgets/network/Network.qml @@ -0,0 +1,30 @@ +import "root:base" +import QtQuick +import Quickshell.Io +import Quickshell.Widgets +import Quickshell + +BRectangle { + MouseArea { + anchors.fill: parent + + IconImage { + anchors.fill: parent + anchors.margins: 2 + source: Quickshell.iconPath("wifi-radar") + } + + onClicked: () => { + gui.running = true; + } + + Process { + id: gui + running: false + command: ["foot", "nmtui"] + stdout: SplitParser { + onRead: data => console.log(`line read: ${data}`) + } + } + } +} diff --git a/src/widgets/notifcenter/Notifcenter.qml b/src/widgets/notifcenter/Notifcenter.qml new file mode 100644 index 0000000..f50e671 --- /dev/null +++ b/src/widgets/notifcenter/Notifcenter.qml @@ -0,0 +1,30 @@ +import "root:base" +import Quickshell +import Quickshell.Widgets +import Quickshell.Io +import QtQuick + +BRectangle { + MouseArea { + anchors.fill: parent + + IconImage { + anchors.fill: parent + anchors.margins: 2 + source: Quickshell.iconPath("notification-active") + } + + onClicked: () => { + gui.running = true; + } + + Process { + id: gui + running: false + command: ["swaync-client", "-t"] + stdout: SplitParser { + onRead: data => console.log(`line read: ${data}`) + } + } + } +} diff --git a/src/widgets/systray/SysTrayItem.qml b/src/widgets/systray/SysTrayItem.qml index b1ecf5d..a09c039 100644 --- a/src/widgets/systray/SysTrayItem.qml +++ b/src/widgets/systray/SysTrayItem.qml @@ -2,6 +2,7 @@ import Quickshell.Services.SystemTray import QtQuick import QtQuick.Layouts import Quickshell +import Quickshell.Widgets MouseArea { id: root @@ -29,22 +30,10 @@ MouseArea { anchor.window: lbar } - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: parent.width - Layout.alignment: Qt.AlignHCenter + IconImage { + source: root.item.icon - color: "black" - radius: 3 - height: width width: parent.width - - Image { - source: root.item.icon - - width: parent.width - height: parent.height - fillMode: Image.Stretch - } + height: parent.height } } diff --git a/src/windows/audioman/AudioEntry.qml b/src/windows/audioman/AudioEntry.qml index 9cfee2d..40ab50c 100644 --- a/src/windows/audioman/AudioEntry.qml +++ b/src/windows/audioman/AudioEntry.qml @@ -14,7 +14,7 @@ RowLayout { Image { source: { - const getFallback = () => node.isStream ? "root:/../assets/folder-music.svg" : "root:/../assets/audio-volume-high.svg"; + const getFallback = () => node.isStream ? "root:/assets/folder-music.svg" : "root:/assets/audio-volume-high.svg"; root.node.properties["application.icon-name"] ? `image://icon/${root.node.properties["application.icon-name"]}` : getFallback(); } @@ -40,7 +40,7 @@ RowLayout { const app = root.node.isStream ? `[${root.node.properties["application.name"]}] ` : ""; return app + (root.node.properties["media.name"] ?? root.node.description); } - // Cede space to other elements -> don't have stupidly long names detroying the layout + // Cede space to other elements -> don't have stupidly long names destroying the layout Layout.maximumWidth: 0 } @@ -54,7 +54,7 @@ RowLayout { width: 10 checkable: true Image { - source: node.audio.muted ? "root:/../assets/audio-volume-muted.svg" : "root:/../assets/audio-volume-high.svg" + source: node.audio.muted ? "root:/assets/audio-volume-muted.svg" : "root:/assets/audio-volume-high.svg" height: parent.height * (2 / 3) anchors.centerIn: parent