diff --git a/.direnv/bin/nix-direnv-reload b/.direnv/bin/nix-direnv-reload new file mode 100755 index 0000000..560afd5 --- /dev/null +++ b/.direnv/bin/nix-direnv-reload @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -e +if [[ ! -d "/home/cyril/personal/hyprland-autoname-workspaces" ]]; then + echo "Cannot find source directory; Did you move it?" + echo "(Looking for "/home/cyril/personal/hyprland-autoname-workspaces")" + echo 'Cannot force reload with this script - use "direnv reload" manually and then try again' + exit 1 +fi + +# rebuild the cache forcefully +_nix_direnv_force_reload=1 direnv exec "/home/cyril/personal/hyprland-autoname-workspaces" true + +# Update the mtime for .envrc. +# This will cause direnv to reload again - but without re-building. +touch "/home/cyril/personal/hyprland-autoname-workspaces/.envrc" + +# Also update the timestamp of whatever profile_rc we have. +# This makes sure that we know we are up to date. +touch -r "/home/cyril/personal/hyprland-autoname-workspaces/.envrc" "/home/cyril/personal/hyprland-autoname-workspaces/.direnv"/*.rc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..6f12290 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +export NIX_CONFIG="extra-experimental-features = nix-command flakes" +use flake diff --git a/.gitignore b/.gitignore index 6bae391..573fb59 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target *.html +.direnv/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..f8bf521 --- /dev/null +++ b/flake.lock @@ -0,0 +1,93 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1721727458, + "narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=", + "owner": "nix-community", + "repo": "naersk", + "rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 0, + "narHash": "sha256-pP3Azj5d6M5nmG68Fu4JqZmdGt4S4vqI5f8te+E/FTw=", + "path": "/nix/store/ia1zpg1s63v6b3vin3n7bxxjgcs51s2r-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1724395761, + "narHash": "sha256-zRkDV/nbrnp3Y8oCADf5ETl1sDrdmAW6/bBVJ8EbIdQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ae815cee91b417be55d43781eb4b73ae1ecc396c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "naersk": "naersk", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a3396df --- /dev/null +++ b/flake.nix @@ -0,0 +1,29 @@ +{ + inputs = { + naersk.url = "github:nix-community/naersk/master"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, naersk }: + let systems = [ "x86_64-linux" "aarch64-linux" ]; + in flake-utils.lib.eachSystem systems (system: + let + pkgs = import nixpkgs { inherit system; }; + naersk-lib = pkgs.callPackage naersk { }; + libs = with pkgs; [ libxkbcommon libinput libpulseaudio systemd ]; + in + { + defaultPackage = naersk-lib.buildPackage { + src = ./.; + meta.mainProgram = "hyprland-autoname-workspaces"; + nativeBuildInputs = [ pkgs.pkg-config ]; + buildInputs = libs; + }; + devShell = with pkgs; mkShell { + buildInputs = [ cargo rustc rustfmt pre-commit rustPackages.clippy pkg-config ] ++ libs; + RUST_SRC_PATH = rustPlatform.rustLibSrc; + }; + } + ); +} diff --git a/src/renamer/formatter.rs b/src/renamer/formatter.rs index 5158aa3..c7a7d84 100644 --- a/src/renamer/formatter.rs +++ b/src/renamer/formatter.rs @@ -1,6 +1,7 @@ use crate::renamer::ConfigFile; use crate::renamer::IconStatus::*; use crate::{AppClient, Renamer}; +use hyprland::data::FullscreenMode; use std::collections::HashMap; use strfmt::strfmt; @@ -103,8 +104,8 @@ impl Renamer { println!("client: {client:#?}\nformatter vars => {vars:#?}"); } - let is_grouped = - client.is_fullscreen && (client.is_active || !is_dedup_inactive_fullscreen); + let is_grouped = client.is_fullscreen != FullscreenMode::None + && (client.is_active || !is_dedup_inactive_fullscreen); match (is_grouped, is_dedup) { (true, true) => formatter(fmt_client_dup_fullscreen, &vars), @@ -141,7 +142,11 @@ pub fn generate_counted_clients( ) -> Vec<(AppClient, i32)> { if need_dedup { let mut sorted_clients = clients; - sorted_clients.sort_by(|a, b| b.is_fullscreen.cmp(&a.is_fullscreen)); + sorted_clients.sort_by(|a, b| { + let bf = b.is_fullscreen != FullscreenMode::None; + let af = a.is_fullscreen != FullscreenMode::None; + bf.cmp(&af) + }); sorted_clients.sort_by(|a, b| b.is_active.cmp(&a.is_active)); sorted_clients