diff --git a/modules/Modules.qml b/modules/Modules.qml index b7645f6..c8c6d1d 100644 --- a/modules/Modules.qml +++ b/modules/Modules.qml @@ -27,6 +27,8 @@ QtObject { property bool battery: true property bool wlogout: true + property var weatherArgs: ["--nerd"] + property FileView _file: FileView { path: (Quickshell.env("XDG_CONFIG_HOME") || (Quickshell.env("HOME") + "/.config")) + "/nova-shell/modules.json" watchChanges: true @@ -45,5 +47,7 @@ QtObject { if (k in root && typeof root[k] === "boolean") root[k] = data[k]; } + if (Array.isArray(data.weatherArgs)) + root.weatherArgs = data.weatherArgs; } } diff --git a/modules/ScreenCorners.qml b/modules/ScreenCorners.qml index a762917..1164743 100644 --- a/modules/ScreenCorners.qml +++ b/modules/ScreenCorners.qml @@ -3,10 +3,8 @@ import Quickshell import Quickshell.Wayland import "." as M -// Empty region = no input area — clicks pass through to windows below - // Draws rounded black corners at the edges of each screen. -// Disabled when screenRadius is 0 (the default). +// Disabled when screenRadius is 0. Item { id: root @@ -14,74 +12,66 @@ Item { readonly property int _r: M.Theme.screenRadius - Repeater { - model: root._r > 0 ? [ - { top: true, left: true, right: false, bottom: false, corner: 0 }, - { top: true, left: false, right: true, bottom: false, corner: 1 }, - { top: false, left: true, right: false, bottom: true, corner: 2 }, - { top: false, left: false, right: true, bottom: true, corner: 3 } - ] : [] + component Corner: PanelWindow { + id: win - delegate: PanelWindow { - id: cornerWindow + property int corner: 0 - required property var modelData + screen: root.screen + visible: root._r > 0 + color: "transparent" - screen: root.screen - color: "transparent" + WlrLayershell.layer: WlrLayer.Overlay + WlrLayershell.exclusiveZone: 0 + WlrLayershell.namespace: "nova-corners" + mask: Region {} - WlrLayershell.layer: WlrLayer.Overlay - WlrLayershell.exclusiveZone: 0 - WlrLayershell.namespace: "nova-corners" - mask: Region {} + implicitWidth: root._r + implicitHeight: root._r - anchors.top: cornerWindow.modelData.top - anchors.left: cornerWindow.modelData.left - anchors.right: cornerWindow.modelData.right - anchors.bottom: cornerWindow.modelData.bottom + Canvas { + anchors.fill: parent + onPaint: { + const r = root._r; + const ctx = getContext("2d"); + ctx.clearRect(0, 0, r, r); + ctx.fillStyle = "black"; + ctx.beginPath(); - implicitWidth: root._r - implicitHeight: root._r - - Canvas { - anchors.fill: parent - onPaint: { - const r = root._r; - const ctx = getContext("2d"); - ctx.clearRect(0, 0, r, r); - ctx.fillStyle = "black"; - ctx.beginPath(); - - switch (cornerWindow.modelData.corner) { - case 0: // top-left - ctx.moveTo(0, 0); - ctx.lineTo(r, 0); - ctx.arc(r, r, r, -Math.PI / 2, Math.PI, true); - ctx.closePath(); - break; - case 1: // top-right - ctx.moveTo(r, 0); - ctx.lineTo(0, 0); - ctx.arc(0, r, r, -Math.PI / 2, 0, false); - ctx.closePath(); - break; - case 2: // bottom-left - ctx.moveTo(0, r); - ctx.lineTo(0, 0); - ctx.arc(r, 0, r, Math.PI, Math.PI / 2, true); - ctx.closePath(); - break; - case 3: // bottom-right - ctx.moveTo(r, r); - ctx.lineTo(r, 0); - ctx.arc(0, 0, r, 0, Math.PI / 2, false); - ctx.closePath(); - break; - } - - ctx.fill(); + switch (win.corner) { + case 0: // top-left + ctx.moveTo(0, 0); + ctx.lineTo(r, 0); + ctx.arc(r, r, r, -Math.PI / 2, Math.PI, true); + ctx.closePath(); + break; + case 1: // top-right + ctx.moveTo(r, 0); + ctx.lineTo(0, 0); + ctx.arc(0, r, r, -Math.PI / 2, 0, false); + ctx.closePath(); + break; + case 2: // bottom-left + ctx.moveTo(0, r); + ctx.lineTo(0, 0); + ctx.arc(r, 0, r, Math.PI, Math.PI / 2, true); + ctx.closePath(); + break; + case 3: // bottom-right + ctx.moveTo(r, r); + ctx.lineTo(r, 0); + ctx.arc(0, 0, r, 0, Math.PI / 2, false); + ctx.closePath(); + break; } + + ctx.fill(); } } } + + Corner { corner: 0; anchors.top: true; anchors.left: true } + Corner { corner: 1; anchors.top: true; anchors.right: true } + Corner { corner: 2; anchors.bottom: true; anchors.left: true } + Corner { corner: 3; anchors.bottom: true; anchors.right: true } } diff --git a/modules/Weather.qml b/modules/Weather.qml index b8d03d0..11b002c 100644 --- a/modules/Weather.qml +++ b/modules/Weather.qml @@ -12,7 +12,7 @@ M.BarSection { Process { id: proc running: true - command: ["wttrbar", "--nerd"] + command: ["wttrbar"].concat(M.Modules.weatherArgs) stdout: StdioCollector { onStreamFinished: { try { diff --git a/nix/hm-module.nix b/nix/hm-module.nix index eb27d33..0f00a76 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -86,6 +86,17 @@ in }; }; + weatherArgs = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ "--nerd" ]; + description = "Arguments passed to wttrbar."; + example = [ + "--nerd" + "--location" + "Berlin" + ]; + }; + theme = lib.mkOption { type = lib.types.attrsOf lib.types.anything; default = { }; @@ -120,7 +131,8 @@ in ++ lib.optional cfg.modules.weather pkgs.wttrbar; xdg.configFile."nova-shell/modules.json".source = - (pkgs.formats.json { }).generate "nova-shell-modules.json" cfg.modules; + (pkgs.formats.json { }).generate "nova-shell-modules.json" + (cfg.modules // { weatherArgs = cfg.weatherArgs; }); xdg.configFile."nova-shell/theme.json".source = let