From eac4c8a895a4400be3151d4cb218dda259dbf28e Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 10 Nov 2023 03:08:22 +0100 Subject: [PATCH] Update and fix ags --- flake.lock | 73 ++++++----------------- flake.nix | 16 ++--- modules/dwl/ags/config.js | 6 +- modules/dwl/ags/covercolors.py | 51 ++++++++-------- modules/dwl/ags/layouts/bar.js | 6 +- modules/dwl/ags/layouts/notifications.js | 2 +- modules/dwl/ags/layouts/osd.js | 4 +- modules/dwl/ags/layouts/powermenu.js | 5 +- modules/dwl/ags/layouts/quicksettings.js | 9 +-- modules/dwl/ags/misc.js | 6 +- modules/dwl/ags/modules/audio.js | 15 ++--- modules/dwl/ags/modules/battery.js | 4 +- modules/dwl/ags/modules/bluetooth.js | 8 +-- modules/dwl/ags/modules/brightness.js | 6 +- modules/dwl/ags/modules/clock.js | 2 +- modules/dwl/ags/modules/darkmode.js | 6 +- modules/dwl/ags/modules/dwl.js | 2 +- modules/dwl/ags/modules/materialcolors.js | 12 ++-- modules/dwl/ags/modules/mpris.js | 6 +- modules/dwl/ags/modules/network.js | 12 ++-- modules/dwl/ags/modules/nightmode.js | 7 +-- modules/dwl/ags/modules/notifications.js | 6 +- modules/dwl/ags/services/brightness.js | 7 ++- modules/dwl/ags/services/dwl.js | 2 +- modules/dwl/ags/services/osd.js | 26 ++++---- modules/dwl/ags/services/quicksettings.js | 48 ++++++--------- modules/dwl/config.h | 24 ++++---- overlays/default.nix | 1 - overlays/tuxedo-keyboard.nix | 40 ------------- 29 files changed, 162 insertions(+), 250 deletions(-) delete mode 100644 overlays/tuxedo-keyboard.nix diff --git a/flake.lock b/flake.lock index d690f1b..de23b07 100644 --- a/flake.lock +++ b/flake.lock @@ -7,15 +7,16 @@ ] }, "locked": { - "lastModified": 1699490483, - "narHash": "sha256-EdrdpemkBx8Zkjt/OWOt/X2X6VfuhL1P7PsJGF4ryQM=", + "lastModified": 1695234369, + "narHash": "sha256-1XX2K417v9ghnLI9uP6EIEAS1zmy92AenQ04P+v6Si4=", "owner": "Aylur", "repo": "ags", - "rev": "99e6ab7f364d4667fbb58ab801aaed7705a8e823", + "rev": "364fde91311ca6396c8a82796eb54bbca7e708ae", "type": "github" }, "original": { "owner": "Aylur", + "ref": "v1.3.0", "repo": "ags", "type": "github" } @@ -53,22 +54,6 @@ "type": "github" } }, - "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -212,11 +197,11 @@ }, "locked": { "dir": "contrib", - "lastModified": 1699486685, - "narHash": "sha256-pb4O9I8nkIPyvdWS33FPUgGIA4Y24pCLlxvqWmKxRik=", + "lastModified": 1699553831, + "narHash": "sha256-EFBYtKE0U14Y5hXc6iXGhUxTzOrYYbOTtwbYWyj53Wc=", "owner": "neovim", "repo": "neovim", - "rev": "04187d1cb58a46dff3b490115f38f9120e13d598", + "rev": "ae8ca79920a8d0e928ac1502a10d1d063a06cae5", "type": "github" }, "original": { @@ -235,11 +220,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1699488661, - "narHash": "sha256-rJZNJexm3CGs86m0xrQ1pr2LCJ5E2BALwD4n3ePycFU=", + "lastModified": 1699574693, + "narHash": "sha256-WjCaT/PtmhAQncXNhaOF5oYi/8A8S5qmYL3cZ7rUfE4=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "fa7175414af333bbb9ea4546cf8f7d037b504ded", + "rev": "0542d71d5decc351f752b864669f8bdc71898942", "type": "github" }, "original": { @@ -266,17 +251,17 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1696929687, - "narHash": "sha256-JcOb2HevAY+XtQu5AQDljV2xcrEfPkpI0E7/qzLHA68=", - "owner": "zoriya", + "lastModified": 1699099776, + "narHash": "sha256-X09iKJ27mGsGambGfkKzqvw5esP1L/Rf8H3u3fCqIiU=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "60223c238b887c5c3c0a9d7bb479d4d1df6f8f37", + "rev": "85f1ba3e51676fa8cc604a3d863d729026a6b8eb", "type": "github" }, "original": { - "owner": "zoriya", - "repo": "nixpkgs", - "type": "github" + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" } }, "root": { @@ -287,8 +272,7 @@ "home-manager": "home-manager", "impermanence": "impermanence", "neovim-nightly": "neovim-nightly", - "nixpkgs": "nixpkgs_2", - "tuxedo-nixos": "tuxedo-nixos" + "nixpkgs": "nixpkgs_2" } }, "systems": { @@ -305,27 +289,6 @@ "repo": "default", "type": "github" } - }, - "tuxedo-nixos": { - "inputs": { - "flake-compat": "flake-compat_2", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1696283326, - "narHash": "sha256-nMlx9L5SaaRRzKeixx2TtRtE8RrWdK7h1jXba1TZcNs=", - "owner": "zoriya", - "repo": "tuxedo-nixos", - "rev": "32ca70b7fc018a8d0dfc6e26dbfa2273f8c44c32", - "type": "github" - }, - "original": { - "owner": "zoriya", - "repo": "tuxedo-nixos", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 379eb9f..b1a7541 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "A very basic flake"; inputs = { - nixpkgs.url = "github:zoriya/nixpkgs"; #"nixpkgs/nixos-unstable"; + nixpkgs.url = "nixpkgs/nixos-unstable"; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; @@ -10,17 +10,13 @@ impermanence.url = "github:nix-community/impermanence"; neovim-nightly.url = "github:nix-community/neovim-nightly-overlay"; # nur.url = "github:nix-community/NUR"; - tuxedo-nixos = { - url = "github:zoriya/tuxedo-nixos"; #"github:blitz/tuxedo-nixos"; - inputs.nixpkgs.follows = "nixpkgs"; - }; dwl-source = { # Use dwl's master. url = "github:djpohly/dwl?ref=755fcae2afbed51f38c167bdc56a5437cda8137a"; flake = false; }; ags = { - url = "github:Aylur/ags"; + url = "github:Aylur/ags?ref=v1.3.0"; inputs.nixpkgs.follows = "nixpkgs"; }; flood = { @@ -36,7 +32,6 @@ # nur, ags, nixpkgs, - tuxedo-nixos, dwl-source, flood, ... @@ -93,10 +88,11 @@ in { nixosConfigurations = { fuhen = mkSystem "fuhen" "dwl" [ - tuxedo-nixos.nixosModules.default ({lib, ...}: { - hardware.tuxedo-keyboard.enable = true; - hardware.tuxedo-control-center.enable = true; + hardware.tuxedo-rs = { + enable = true; + tailor-gui.enable = true; + }; programs.gamescope.enable = true; }) diff --git a/modules/dwl/ags/config.js b/modules/dwl/ags/config.js index 0c612a1..f0bff31 100644 --- a/modules/dwl/ags/config.js +++ b/modules/dwl/ags/config.js @@ -4,8 +4,8 @@ import { OSD } from "./layouts/osd.js"; import { Powermenu } from "./layouts/powermenu.js"; import { Quicksettings } from "./layouts/quicksettings.js"; -const { App } = ags; -const { timeout } = ags.Utils; +import App from 'resource:///com/github/Aylur/ags/app.js' +import { timeout } from 'resource:///com/github/Aylur/ags/utils.js'; const { Display } = imports.gi.Gdk; const config = { @@ -13,7 +13,7 @@ const config = { quicksettings: 300, notifications: 300, }, - style: ags.App.configDir + "/style.css", + style: App.configDir + "/style.css", monitorFactory: (mon) => [Bar(mon, `${mon.geometry.x},${mon.geometry.y}`)], windows: [Quicksettings(), Notifications(), OSD(), Powermenu()], }; diff --git a/modules/dwl/ags/covercolors.py b/modules/dwl/ags/covercolors.py index 6273845..2c72db5 100644 --- a/modules/dwl/ags/covercolors.py +++ b/modules/dwl/ags/covercolors.py @@ -10,37 +10,38 @@ import hashlib CACHE_DIR = os.path.expanduser("~/.cache/ags/tempcolors") def cache_and_get_colors(file_path): - file_hash = hashlib.sha256(file_path.encode('utf-8')).hexdigest() - cache_path = os.path.join(CACHE_DIR, file_hash[:2], file_hash[2:]) + file_hash = hashlib.sha256(file_path.encode('utf-8')).hexdigest() + cache_path = os.path.join(CACHE_DIR, file_hash[:2], file_hash[2:]) - if not os.path.exists(cache_path): - os.makedirs(cache_path) + if not os.path.exists(cache_path): + os.makedirs(cache_path) - colors_path = os.path.join(cache_path, "colors.json") - if os.path.exists(colors_path): - with open(colors_path, "r") as f: - parsed_colors = json.load(f) - else: - img = Image.open(file_path) - basewidth = 8 - wpercent = (basewidth/float(img.size[0])) - hsize = int((float(img.size[1])*float(wpercent))) - img = img.resize((basewidth, hsize), Image.Resampling.LANCZOS) - theme = themeFromImage(img) + colors_path = os.path.join(cache_path, "colors.json") + if os.path.exists(colors_path): + with open(colors_path, "r") as f: + parsed_colors = json.load(f) + elif not os.path.exists(file_path): + return None + img = Image.open(file_path) + basewidth = 8 + wpercent = (basewidth/float(img.size[0])) + hsize = int((float(img.size[1])*float(wpercent))) + img = img.resize((basewidth, hsize), Image.Resampling.LANCZOS) + theme = themeFromImage(img) - scheme = theme.get("schemes") + scheme = theme.get("schemes") - parsed_colors = { - "primary": hexFromArgb(scheme.get("dark").primary), - "onPrimary": hexFromArgb(scheme.get("dark").onPrimary), - "background": hexFromArgb(scheme.get("dark").background), - "onBackground": hexFromArgb(scheme.get("dark").onBackground), - } + parsed_colors = { + "primary": hexFromArgb(scheme.get("dark").primary), + "onPrimary": hexFromArgb(scheme.get("dark").onPrimary), + "background": hexFromArgb(scheme.get("dark").background), + "onBackground": hexFromArgb(scheme.get("dark").onBackground), + } - with open(colors_path, "w") as f: - json.dump(parsed_colors, f) + with open(colors_path, "w") as f: + json.dump(parsed_colors, f) - return parsed_colors + return parsed_colors fn = sys.argv[1] diff --git a/modules/dwl/ags/layouts/bar.js b/modules/dwl/ags/layouts/bar.js index 36b08ec..f20dec2 100644 --- a/modules/dwl/ags/layouts/bar.js +++ b/modules/dwl/ags/layouts/bar.js @@ -6,15 +6,15 @@ import * as bluetooth from "../modules/bluetooth.js"; import * as battery from "../modules/battery.js"; import * as notifications from "../modules/notifications.js"; -const { App } = ags; -const { Window, CenterBox, Box, Button } = ags.Widget; +import App from 'resource:///com/github/Aylur/ags/app.js'; +import { Window, CenterBox, Box, Button } from 'resource:///com/github/Aylur/ags/widget.js'; export const Bar = (mon, monId) => Window({ name: `bar${monId}`, className: "transparent", exclusive: true, - anchor: "top left right", + anchor: ["top", "left", "right"], layer: "bottom", monitor: mon, child: CenterBox({ diff --git a/modules/dwl/ags/layouts/notifications.js b/modules/dwl/ags/layouts/notifications.js index 84cb62c..b14a9e3 100644 --- a/modules/dwl/ags/layouts/notifications.js +++ b/modules/dwl/ags/layouts/notifications.js @@ -1,7 +1,7 @@ import { PopupOverlay } from "../misc.js"; import * as notifications from "../modules/notifications.js"; -const { Window, Box } = ags.Widget; +import { Window, Box } from 'resource:///com/github/Aylur/ags/widget.js' export const Notifications = () => Window({ diff --git a/modules/dwl/ags/layouts/osd.js b/modules/dwl/ags/layouts/osd.js index 8caef0f..4a933d1 100644 --- a/modules/dwl/ags/layouts/osd.js +++ b/modules/dwl/ags/layouts/osd.js @@ -1,5 +1,5 @@ -const { lookUpIcon } = ags.Utils; -const { Window, Revealer, Stack, Box, Icon } = ags.Widget; +import { lookUpIcon } from 'resource:///com/github/Aylur/ags/utils.js'; +import { Window, Revealer, Stack, Box, Icon } from 'resource:///com/github/Aylur/ags/widget.js' import { FontIcon, Progress } from "../misc.js"; import { Indicator } from "../services/osd.js"; diff --git a/modules/dwl/ags/layouts/powermenu.js b/modules/dwl/ags/layouts/powermenu.js index 9e50482..a2fc066 100644 --- a/modules/dwl/ags/layouts/powermenu.js +++ b/modules/dwl/ags/layouts/powermenu.js @@ -1,6 +1,7 @@ import { PopupOverlay } from "../misc.js"; -const { Box, Button, Icon, Label, Window } = ags.Widget; +import { Box, Button, Icon, Label, Window } from 'resource:///com/github/Aylur/ags/widget.js'; +import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; const cmd = { Sleep: "systemctl suspend", @@ -11,7 +12,7 @@ const cmd = { const SysButton = (icon, action) => Button({ - onClicked: cmd[action], + onClicked: () => execAsync(cmd[action]), child: Box({ vertical: true, children: [Icon(icon), Label(action)], diff --git a/modules/dwl/ags/layouts/quicksettings.js b/modules/dwl/ags/layouts/quicksettings.js index 6f609f8..e0f872f 100644 --- a/modules/dwl/ags/layouts/quicksettings.js +++ b/modules/dwl/ags/layouts/quicksettings.js @@ -5,15 +5,16 @@ import * as bluetooth from "../modules/bluetooth.js"; import * as darkmode from "../modules/darkmode.js"; import * as nightmode from "../modules/nightmode.js"; import * as mpris from "../modules/mpris.js"; -import { QSMenu, Arrow } from "../services/quicksettings.js"; +import { opened, Arrow } from "../services/quicksettings.js"; import { FontIcon, PopupOverlay } from "../misc.js"; -const { Window, Revealer, Icon, Box, Button, Label } = ags.Widget; +import { Window, Revealer, Icon, Box, Button, Label } from 'resource:///com/github/Aylur/ags/widget.js' +import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js' const Submenu = ({ menuName, icon, title, contentType }) => Revealer({ transition: "slide_down", - connections: [[QSMenu, (r) => (r.reveal_child = menuName === QSMenu.opened)]], + connections: [[opened, (r) => (r.reveal_child = menuName === opened.value)]], child: Box({ className: "qs-submenu surface", vertical: true, @@ -33,7 +34,7 @@ const VolumeBox = () => children: [ Button({ child: audio.SpeakerIndicator(), - onClicked: "pactl set-sink-mute @DEFAULT_SINK@ toggle", + onClicked: () => execAsync("pactl set-sink-mute @DEFAULT_SINK@ toggle"), }), audio.SpeakerSlider({ hexpand: true }), audio.SpeakerPercentLabel(), diff --git a/modules/dwl/ags/misc.js b/modules/dwl/ags/misc.js index 43776e5..c46b2c2 100644 --- a/modules/dwl/ags/misc.js +++ b/modules/dwl/ags/misc.js @@ -1,6 +1,6 @@ -const { App } = ags; -const { Box, Label, Revealer, EventBox, Overlay, Icon } = ags.Widget; -const { timeout } = ags.Utils; +import App from 'resource:///com/github/Aylur/ags/app.js' +import { Box, Label, Revealer, EventBox, Overlay, Icon } from 'resource:///com/github/Aylur/ags/widget.js' +import { timeout } from 'resource:///com/github/Aylur/ags/utils.js'; export const addElipsis = (str, max = 20, position = "end") => { if (str.length <= max) return str; diff --git a/modules/dwl/ags/modules/audio.js b/modules/dwl/ags/modules/audio.js index 69a7899..158a1a5 100644 --- a/modules/dwl/ags/modules/audio.js +++ b/modules/dwl/ags/modules/audio.js @@ -1,10 +1,11 @@ import { Separator, FontIcon, addElipsis } from "../misc.js"; -import { ArrowToggle, QSMenu } from "../services/quicksettings.js"; +import { ArrowToggle, opened } from "../services/quicksettings.js"; -const { App } = ags; -const { Audio } = ags.Service; -const { Label, Box, Icon, Stack, Button, Slider } = ags.Widget; -const { execAsync } = ags.Utils; +import App from 'resource:///com/github/Aylur/ags/app.js' +import Service from 'resource:///com/github/Aylur/ags/service.js' +import Audio from 'resource:///com/github/Aylur/ags/service/audio.js' +import { Label, Box, Icon, Stack, Button, Slider } from 'resource:///com/github/Aylur/ags/widget.js'; +import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; const iconSubstitute = (item) => { const substitues = [ @@ -118,7 +119,7 @@ export const MuteToggle = (props) => Button({ ...props, className: "qs-button surface", - onClicked: "pactl set-source-mute @DEFAULT_SOURCE@ toggle", + onClicked: () => execAsync("pactl set-source-mute @DEFAULT_SOURCE@ toggle"), child: Box({ children: [ MicrophoneMuteIndicator({ className: "qs-icon" }), @@ -154,7 +155,7 @@ export const AppMixerToggle = (props) => icon: FontIcon({ icon: "", className: "qs-icon" }), label: Label("App Mixer"), name: "app-mixer", - toggle: () => QSMenu.toggle("app-mixer"), + toggle: () => opened.value = opened.value === "app-mixer" ? "" : "app-mixer", ...props, }); diff --git a/modules/dwl/ags/modules/battery.js b/modules/dwl/ags/modules/battery.js index 51b1224..46458e6 100644 --- a/modules/dwl/ags/modules/battery.js +++ b/modules/dwl/ags/modules/battery.js @@ -1,5 +1,5 @@ -const { Battery } = ags.Service; -const { Label, Icon, Stack, Box } = ags.Widget; +import Battery from 'resource:///com/github/Aylur/ags/service/battery.js' +import { Label, Icon, Stack, Box } from 'resource:///com/github/Aylur/ags/widget.js'; const icons = (charging) => Array.from({ length: 11 }, (_, i) => i * 10).map((i) => [ diff --git a/modules/dwl/ags/modules/bluetooth.js b/modules/dwl/ags/modules/bluetooth.js index 3a59a5f..6887cfb 100644 --- a/modules/dwl/ags/modules/bluetooth.js +++ b/modules/dwl/ags/modules/bluetooth.js @@ -1,10 +1,10 @@ import { Spinner, Separator } from "../misc.js"; import { ArrowToggle } from "../services/quicksettings.js"; -const { App } = ags; -const { Bluetooth } = ags.Service; -const { Icon, Label, Box, Button, Stack } = ags.Widget; -const { execAsync } = ags.Utils; +import App from 'resource:///com/github/Aylur/ags/app.js' +import Bluetooth from 'resource:///com/github/Aylur/ags/service/bluetooth.js' +import { Icon, Label, Box, Button, Stack } from 'resource:///com/github/Aylur/ags/widget.js'; +import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; export const Indicator = ({ enabled = Icon({ icon: "bluetooth-active-symbolic", className: "enabled" }), diff --git a/modules/dwl/ags/modules/brightness.js b/modules/dwl/ags/modules/brightness.js index eaa147b..ab04ccd 100644 --- a/modules/dwl/ags/modules/brightness.js +++ b/modules/dwl/ags/modules/brightness.js @@ -1,8 +1,8 @@ import { Brightness } from "../services/brightness.js"; -const { Service } = ags; -const { exec, execAsync } = ags.Utils; -const { Icon, Label, Slider } = ags.Widget; +import Service from 'resource:///com/github/Aylur/ags/service.js'; +import { exec, execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; +import { Icon, Label, Slider } from 'resource:///com/github/Aylur/ags/widget.js'; export const BrightnessSlider = (props) => Slider({ diff --git a/modules/dwl/ags/modules/clock.js b/modules/dwl/ags/modules/clock.js index 7dfbd5c..4c60da6 100644 --- a/modules/dwl/ags/modules/clock.js +++ b/modules/dwl/ags/modules/clock.js @@ -1,4 +1,4 @@ -const { Label } = ags.Widget; +import { Label } from 'resource:///com/github/Aylur/ags/widget.js'; const { DateTime } = imports.gi.GLib; export const Clock = ({ diff --git a/modules/dwl/ags/modules/darkmode.js b/modules/dwl/ags/modules/darkmode.js index f9a0d0b..aeb12e0 100644 --- a/modules/dwl/ags/modules/darkmode.js +++ b/modules/dwl/ags/modules/darkmode.js @@ -1,8 +1,8 @@ import GLib from 'gi://GLib'; -const { Service } = ags; -const { exec, execAsync } = ags.Utils; -const { Icon, Label, Button, Box, Stack } = ags.Widget; +import Service from 'resource:///com/github/Aylur/ags/service.js' +import { exec, execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; +import { Icon, Label, Button, Box, Stack } from 'resource:///com/github/Aylur/ags/widget.js'; class ThemeService extends Service { static { diff --git a/modules/dwl/ags/modules/dwl.js b/modules/dwl/ags/modules/dwl.js index ba6f084..267ac32 100644 --- a/modules/dwl/ags/modules/dwl.js +++ b/modules/dwl/ags/modules/dwl.js @@ -1,4 +1,4 @@ -const { Box, Button, Label } = ags.Widget; +import { Box, Button, Label } from 'resource:///com/github/Aylur/ags/widget.js'; import { Dwl } from "../services/dwl.js"; export const Tags = ({ mon, labels, ...props } = {}) => diff --git a/modules/dwl/ags/modules/materialcolors.js b/modules/dwl/ags/modules/materialcolors.js index c96ff22..ccfb1db 100644 --- a/modules/dwl/ags/modules/materialcolors.js +++ b/modules/dwl/ags/modules/materialcolors.js @@ -1,7 +1,7 @@ -const { Service } = ags; -const { Box, Stack, Button, Icon } = ags.Widget; -const { execAsync, timeout } = ags.Utils; -const { Mpris } = ags.Service; +import Service from 'resource:///com/github/Aylur/ags/service.js'; +import { Box, Stack, Button, Icon } from 'resource:///com/github/Aylur/ags/widget.js'; +import { execAsync, timeout } from 'resource:///com/github/Aylur/ags/utils.js'; +import Mpris from 'resource:///com/github/Aylur/ags/service/mpris.js'; class MaterialcolorsService extends Service { static { @@ -13,7 +13,9 @@ class MaterialcolorsService extends Service { timeout(100, () => { execAsync(["covercolors", url]) .then((colors) => { - this._colors = JSON.parse(colors); + const col = JSON.parse(colors); + if (!col) return; + this._colors = col; this.emit("changed"); }) .catch(print); diff --git a/modules/dwl/ags/modules/mpris.js b/modules/dwl/ags/modules/mpris.js index 2e9a586..c7dafce 100644 --- a/modules/dwl/ags/modules/mpris.js +++ b/modules/dwl/ags/modules/mpris.js @@ -1,9 +1,9 @@ import { BackgroundBox, CoverArt, PlayPause } from "./materialcolors.js"; import { addElipsis } from "../misc.js"; -const { Box, Button, Slider, Icon, CenterBox, Label } = ags.Widget; -const { Mpris } = ags.Service; -const { lookUpIcon } = ags.Utils; +import { Box, Button, Slider, Icon, CenterBox, Label } from 'resource:///com/github/Aylur/ags/widget.js'; +import Mpris from 'resource:///com/github/Aylur/ags/service/mpris.js' +import { lookUpIcon } from 'resource:///com/github/Aylur/ags/utils.js'; const PlayerIcon = ({ player, symbolic = false, ...props }) => Icon({ diff --git a/modules/dwl/ags/modules/network.js b/modules/dwl/ags/modules/network.js index 5282a60..8850bd3 100644 --- a/modules/dwl/ags/modules/network.js +++ b/modules/dwl/ags/modules/network.js @@ -1,10 +1,10 @@ import { ArrowToggle } from "../services/quicksettings.js"; import { Separator } from "../misc.js"; -const { App } = ags; -const { Network } = ags.Service; -const { Label, Icon, Box, Stack, Button } = ags.Widget; -const { execAsync } = ags.Utils; +import App from 'resource:///com/github/Aylur/ags/app.js' +import Network from 'resource:///com/github/Aylur/ags/service/network.js' +import { Label, Icon, Box, Stack, Button } from 'resource:///com/github/Aylur/ags/widget.js'; +import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; export const SSIDLabel = (props) => Label({ @@ -44,7 +44,7 @@ export const Indicator = () => Stack({ }]], })], ], - binds: [['shown', Network, 'primary', p => p || 'wifi']], + connections: [[Network, self => { self.shown = Network.primary || "wifi" }]], }); export const Toggle = (props) => @@ -87,7 +87,7 @@ export const Selection = (props) => box.children = Network.wifi?.accessPoints .map((ap) => Button({ - onClicked: `nmcli device wifi connect ${ap.bssid}`, + onClicked: () => execAsync(`nmcli device wifi connect ${ap.bssid}`), child: Box({ children: [ Icon(icons.find(({ value }) => value <= ap.strength).icon), diff --git a/modules/dwl/ags/modules/nightmode.js b/modules/dwl/ags/modules/nightmode.js index d234f2c..8307806 100644 --- a/modules/dwl/ags/modules/nightmode.js +++ b/modules/dwl/ags/modules/nightmode.js @@ -1,6 +1,4 @@ -const { Service } = ags; -const { exec, execAsync } = ags.Utils; -const { Icon, Label, Button, Box, Stack } = ags.Widget; +import { Icon, Label, Button, Box, Stack } from 'resource:///com/github/Aylur/ags/widget.js'; // class ThemeService extends Service { // static { @@ -30,10 +28,9 @@ const { Icon, Label, Button, Box, Stack } = ags.Widget; // static { // Service.export(this, "Theme"); // } -// static instance = new ThemeService(); // // static get dark() { -// return Theme.instance.dark; +// return Theme.dark; // } // static set dark(value) { // Theme.instance.dark = value; diff --git a/modules/dwl/ags/modules/notifications.js b/modules/dwl/ags/modules/notifications.js index 21a929a..ce3f074 100644 --- a/modules/dwl/ags/modules/notifications.js +++ b/modules/dwl/ags/modules/notifications.js @@ -1,9 +1,9 @@ import { FontIcon } from "../misc.js"; const { GLib } = imports.gi; -const { Notifications } = ags.Service; -const { lookUpIcon, timeout } = ags.Utils; -const { Box, Icon, Label, EventBox, Button, Stack, Revealer } = ags.Widget; +import Notifications from 'resource:///com/github/Aylur/ags/service/notifications.js' +import { lookUpIcon, timeout } from 'resource:///com/github/Aylur/ags/utils.js'; +import { Box, Icon, Label, EventBox, Button, Stack, Revealer } from 'resource:///com/github/Aylur/ags/widget.js'; export const Indicator = ({ ...props }) => Box({ diff --git a/modules/dwl/ags/services/brightness.js b/modules/dwl/ags/services/brightness.js index 0fc2b68..acaa188 100644 --- a/modules/dwl/ags/services/brightness.js +++ b/modules/dwl/ags/services/brightness.js @@ -1,5 +1,5 @@ -const { Service } = ags; -const { exec, execAsync } = ags.Utils; +import Service from 'resource:///com/github/Aylur/ags/service.js'; +import { exec, execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; class BrightnessService extends Service { static { @@ -36,4 +36,5 @@ class BrightnessService extends Service { } export const Brightness = new BrightnessService(); -ags.Service.Brightness = Brightness; +export default Brightness; +globalThis.brightness = Brightness; diff --git a/modules/dwl/ags/services/dwl.js b/modules/dwl/ags/services/dwl.js index eda7ce5..0944121 100644 --- a/modules/dwl/ags/services/dwl.js +++ b/modules/dwl/ags/services/dwl.js @@ -1,6 +1,6 @@ import Gio from "gi://Gio"; -const { Service } = ags; +import Service from 'resource:///com/github/Aylur/ags/service.js' class DwlService extends Service { static { diff --git a/modules/dwl/ags/services/osd.js b/modules/dwl/ags/services/osd.js index e1c4b67..9b39d6b 100644 --- a/modules/dwl/ags/services/osd.js +++ b/modules/dwl/ags/services/osd.js @@ -1,5 +1,8 @@ -const { App, Service } = ags; -const { timeout, connect } = ags.Utils; +import App from 'resource:///com/github/Aylur/ags/app.js'; +import Service from 'resource:///com/github/Aylur/ags/service.js'; +import Audio from 'resource:///com/github/Aylur/ags/service/audio.js'; +import Brightness from '../services/brightness.js'; +import { timeout } from 'resource:///com/github/Aylur/ags/utils.js'; class IndicatorService extends Service { static { @@ -31,7 +34,7 @@ class IndicatorService extends Service { } speaker() { - const value = ags.Service.Audio.speaker.volume; + const value = Audio.speaker.volume; const icon = (value) => { const icons = []; icons[0] = "audio-volume-muted-symbolic"; @@ -39,7 +42,7 @@ class IndicatorService extends Service { icons[34] = "audio-volume-medium-symbolic"; icons[67] = "audio-volume-high-symbolic"; icons[101] = "audio-volume-overamplified-symbolic"; - if (ags.Service.Audio.speaker.isMuted) return icons[0]; + if (Audio.speaker.isMuted) return icons[0]; for (const i of [101, 67, 34, 1, 0]) { if (i <= value * 100) return icons[i]; } @@ -50,7 +53,7 @@ class IndicatorService extends Service { display() { // brightness is async, so lets wait a bit timeout(10, () => { - const value = ags.Service.Brightness.screen; + const value = Brightness.screen; const icon = (value) => { const icons = ["󰛩", "󱩎", "󱩏", "󱩐", "󱩑", "󱩒", "󱩓", "󱩔", "󱩕", "󱩖", "󰛨"]; return icons[Math.ceil(value * 10)]; @@ -62,15 +65,16 @@ class IndicatorService extends Service { kbd() { // brightness is async, so lets wait a bit timeout(10, () => { - const value = ags.Service.Brightness.kbd; + const value = Brightness.kbd; this.popup((value * 33 + 1) / 100, "keyboard-brightness-symbolic"); }); } - - connectWidget(widget, callback) { - connect(this, widget, callback, "popup"); - } + // + // connectWidget(widget, callback) { + // connect(this, widget, callback, "popup"); + // } } export const Indicator = new IndicatorService(); -ags.Service.Indicator = Indicator; +export default Indicator; +globalThis.indicator = Indicator; diff --git a/modules/dwl/ags/services/quicksettings.js b/modules/dwl/ags/services/quicksettings.js index a7019cb..e1266ac 100644 --- a/modules/dwl/ags/services/quicksettings.js +++ b/modules/dwl/ags/services/quicksettings.js @@ -1,28 +1,14 @@ -const { App, Service } = ags; -const { Box, Button, Icon } = ags.Widget; -const { timeout } = ags.Utils; +import App from 'resource:///com/github/Aylur/ags/app.js' +import Service from 'resource:///com/github/Aylur/ags/service.js' +import Variable from 'resource:///com/github/Aylur/ags/variable.js'; +import { Box, Button, Icon } from 'resource:///com/github/Aylur/ags/widget.js' +import { timeout } from 'resource:///com/github/Aylur/ags/utils.js'; -export class QSMenu extends Service { - static { - Service.register(this); - } - static instance = new QSMenu(); - static opened = ""; - static toggle(menu) { - QSMenu.opened = QSMenu.opened === menu ? "" : menu; - QSMenu.instance.emit("changed"); - } - - constructor() { - super(); - App.instance.connect("window-toggled", (_a, name, visible) => { - if (name === "quicksettings" && !visible) { - QSMenu.opened = ""; - QSMenu.instance.emit("changed"); - } - }); - } -} +export const opened = Variable(''); +App.instance.connect('window-toggled', (_, name, visible) => { + if (name === 'quicksettings' && !visible) + timeout(500, () => opened.value = ''); +}); export const ArrowToggle = ({ icon, label, toggle, name, expand, ...props }) => { icon.className = `${icon.className} qs-icon`; @@ -47,14 +33,14 @@ export const Arrow = ({ name, expand, ...props }) => ...props, className: "qs-icon", onClicked: () => { - QSMenu.toggle(name); - if (expand && QSMenu.openned == name) expand(); + opened.value = opened.value === name ? "" : name; + if (expand) expand(); }, connections: [ [ - QSMenu, + opened, (button) => { - button.toggleClassName("opened", QSMenu.opened === name); + button.toggleClassName("opened", opened.value === name); }, ], ], @@ -66,10 +52,10 @@ export const Arrow = ({ name, expand, ...props }) => ], connections: [ [ - QSMenu, + opened, (icon) => { - if ((QSMenu.opened === name && !icon._opened) || (QSMenu.opened !== name && icon._opened)) { - const step = QSMenu.opened === name ? 10 : -10; + if ((opened.value === name && !icon._opened) || (opened.value !== name && icon._opened)) { + const step = opened.value === name ? 10 : -10; icon._opened = !icon._opened; for (let i = 0; i < 9; ++i) { timeout(5 * i, () => { diff --git a/modules/dwl/config.h b/modules/dwl/config.h index d138814..060f09b 100644 --- a/modules/dwl/config.h +++ b/modules/dwl/config.h @@ -177,20 +177,20 @@ static const Key keys[] = { { 0, XKB_KEY_XF86PowerOff, spawn, {.v = (const char*[]){"ags", "-t", "powermenu", NULL}}}, // TODO: Allow those bindings on lockscreen // TODO: Allow those bindings on repeat - { 0, XKB_KEY_XF86MonBrightnessUp, spawn, {.v = (const char*[]){"ags", "run-js", "ags.Service.Brightness.screen += 0.05; ags.Service.Indicator.display()", NULL}}}, - { 0, XKB_KEY_XF86MonBrightnessDown, spawn, {.v = (const char*[]){"ags", "run-js", "ags.Service.Brightness.screen -= 0.05; ags.Service.Indicator.display()", NULL}}}, - { 0, XKB_KEY_XF86KbdBrightnessUp, spawn, {.v = (const char*[]){"ags", "run-js", "ags.Service.Brightness.kbd++; ags.Service.Indicator.kbd()", NULL}}}, - { 0, XKB_KEY_XF86KbdBrightnessDown, spawn, {.v = (const char*[]){"ags", "run-js", "ags.Service.Brightness.kbd--; ags.Service.Indicator.kbd()", NULL}}}, - { 0, XKB_KEY_XF86AudioRaiseVolume, spawn, {.v = (const char*[]){"ags", "run-js", "ags.Service.Audio.speaker.volume += 0.05; ags.Service.Indicator.speaker()", NULL}}}, - { 0, XKB_KEY_XF86AudioLowerVolume, spawn, {.v = (const char*[]){"ags", "run-js", "ags.Service.Audio.speaker.volume -= 0.05; ags.Service.Indicator.speaker()", NULL}}}, - { 0, XKB_KEY_XF86AudioMute, spawn, {.v = (const char*[]){"ags", "run-js", "ags.Service.Audio.speaker.isMuted = !ags.Service.Audio.speaker.isMuted; ags.Service.Indicator.speaker()", NULL}}}, + { 0, XKB_KEY_XF86MonBrightnessUp, spawn, {.v = (const char*[]){"ags", "run-js", "brightness.screen += 0.05; indicator.display()", NULL}}}, + { 0, XKB_KEY_XF86MonBrightnessDown, spawn, {.v = (const char*[]){"ags", "run-js", "brightness.screen -= 0.05; indicator.display()", NULL}}}, + { 0, XKB_KEY_XF86KbdBrightnessUp, spawn, {.v = (const char*[]){"ags", "run-js", "brightness.kbd++; indicator.kbd()", NULL}}}, + { 0, XKB_KEY_XF86KbdBrightnessDown, spawn, {.v = (const char*[]){"ags", "run-js", "brightness.kbd--; indicator.kbd()", NULL}}}, + { 0, XKB_KEY_XF86AudioRaiseVolume, spawn, {.v = (const char*[]){"ags", "run-js", "audio.speaker.volume += 0.05; indicator.speaker()", NULL}}}, + { 0, XKB_KEY_XF86AudioLowerVolume, spawn, {.v = (const char*[]){"ags", "run-js", "audio.speaker.volume -= 0.05; indicator.speaker()", NULL}}}, + { 0, XKB_KEY_XF86AudioMute, spawn, {.v = (const char*[]){"ags", "run-js", "audio.speaker.isMuted = !audio.speaker.isMuted; indicator.speaker()", NULL}}}, { 0, XKB_KEY_XF86AudioMicMute, spawn, {.v = (const char*[]){"pactl", "set-source-mute", "@DEFAULT_SOURCE@", "toggle", NULL}}}, - { 0, XKB_KEY_XF86AudioPlay, spawn, {.v = (const char*[]){"ags", "run-js", "ags.Service.Mpris.getPlayer()?.playPause()", NULL}}}, - { 0, XKB_KEY_XF86AudioStop, spawn, {.v = (const char*[]){"ags", "run-js", "ags.Service.Mpris.getPlayer()?.stop()", NULL}}}, - { 0, XKB_KEY_XF86AudioPause, spawn, {.v = (const char*[]){"ags", "run-js", "ags.Service.Mpris.getPlayer()?.pause()", NULL}}}, - { 0, XKB_KEY_XF86AudioPrev, spawn, {.v = (const char*[]){"ags", "run-js", "ags.Service.Mpris.getPlayer()?.previous()", NULL}}}, - { 0, XKB_KEY_XF86AudioNext, spawn, {.v = (const char*[]){"ags", "run-js", "ags.Service.Mpris.getPlayer()?.next()", NULL}}}, + { 0, XKB_KEY_XF86AudioPlay, spawn, {.v = (const char*[]){"ags", "run-js", "mpris.getPlayer()?.playPause()", NULL}}}, + { 0, XKB_KEY_XF86AudioStop, spawn, {.v = (const char*[]){"ags", "run-js", "mpris.getPlayer()?.stop()", NULL}}}, + { 0, XKB_KEY_XF86AudioPause, spawn, {.v = (const char*[]){"ags", "run-js", "mpris.getPlayer()?.pause()", NULL}}}, + { 0, XKB_KEY_XF86AudioPrev, spawn, {.v = (const char*[]){"ags", "run-js", "mpris.getPlayer()?.previous()", NULL}}}, + { 0, XKB_KEY_XF86AudioNext, spawn, {.v = (const char*[]){"ags", "run-js", "mpris.getPlayer()?.next()", NULL}}}, /* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */ { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} }, diff --git a/overlays/default.nix b/overlays/default.nix index fcb7644..ba5c051 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -67,7 +67,6 @@ in { }; }; - tuxedo-keyboard = super.callPackage ./tuxedo-keyboard {}; slack = enableWayland super.slack ["slack"]; discord = enableWayland super.discord ["discord" "Discord"]; vscode = enableWayland super.vscode ["code"]; diff --git a/overlays/tuxedo-keyboard.nix b/overlays/tuxedo-keyboard.nix deleted file mode 100644 index cf0a5a9..0000000 --- a/overlays/tuxedo-keyboard.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ lib, stdenv, fetchFromGitHub, kernel, linuxHeaders }: - -stdenv.mkDerivation rec { - pname = "tuxedo-keyboard-${kernel.version}"; - version = "3.1.4"; - - src = fetchFromGitHub { - owner = "tuxedocomputers"; - repo = "tuxedo-keyboard"; - rev = "v${version}"; - sha256 = "h6+br+JPEItym83MaVt+xo6o/zMtTv8+wsBoTeYa2AM="; - }; - - buildInputs = [ linuxHeaders ]; - - makeFlags = [ "KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" ]; - - installPhase = '' - mkdir -p "$out/lib/modules/${kernel.modDirVersion}" - - for module in clevo_acpi.ko clevo_wmi.ko tuxedo_keyboard.ko tuxedo_io/tuxedo_io.ko uniwill_wmi.ko; do - mv src/$module $out/lib/modules/${kernel.modDirVersion} - done - ''; - - meta = with lib; { - description = "Keyboard and hardware I/O driver for TUXEDO Computers laptops"; - longDescription = '' - This driver provides support for Fn keys, brightness/color/mode for most TUXEDO - keyboards (except white backlight-only models). - - Can be used with the "hardware.tuxedo-keyboard" NixOS module. - ''; - homepage = "https://github.com/tuxedocomputers/tuxedo-keyboard/"; - license = licenses.gpl3Plus; - platforms = platforms.linux; - broken = stdenv.isAarch64; - maintainers = [ maintainers.blanky0230 ]; - }; -}