Skip to content

Commit

Permalink
chore: bump to last hyprland-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrinux committed Aug 28, 2024
1 parent e7f1722 commit db232a2
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 10 deletions.
19 changes: 19 additions & 0 deletions .direnv/bin/nix-direnv-reload
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export NIX_CONFIG="extra-experimental-features = nix-command flakes"
use flake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
*.html
.direnv/
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "hyprland-autoname-workspaces"
authors = ["Cyril Levis", "Maxim Baz"]
version = "1.1.14"
version = "1.1.15"
edition = "2021"
categories = ["gui"]
keywords = ["linux", "desktop-application", "hyprland", "waybar", "wayland"]
Expand Down
2 changes: 1 addition & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.1.14"
version = "1.1.15"

[format]
dedup = true
Expand Down
93 changes: 93 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}
);
}
18 changes: 13 additions & 5 deletions src/renamer/formatter.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -194,7 +199,7 @@ mod tests {
title: String::from("Title"),
initial_title: String::from("Title"),
is_active: false,
is_fullscreen: false,
is_fullscreen: FullscreenMode::None,
matched_rule: Inactive(Default(String::from("DefaultIcon"))),
is_dedup_inactive_fullscreen: false,
};
Expand All @@ -206,7 +211,10 @@ mod tests {
assert_eq!(workspace.clients[0].class, "Class");
assert_eq!(workspace.clients[0].title, "Title");
assert_eq!(workspace.clients[0].is_active, false);
assert_eq!(workspace.clients[0].is_fullscreen, false);
assert_eq!(
workspace.clients[0].is_fullscreen,
FullscreenMode::Fullscreen
);
match &workspace.clients[0].matched_rule {
Inactive(Default(icon)) => assert_eq!(icon, "DefaultIcon"),
_ => panic!("Unexpected IconConfig value"),
Expand Down
4 changes: 2 additions & 2 deletions src/renamer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ mod tests {
title: "xplr".to_string(),
initial_title: "zsh".to_string(),
is_active: false,
is_fullscreen: FullscreenMode::None,
is_fullscreen: FullscreenMode::Fullscreen,
matched_rule: Inactive(Class("(kitty|alacritty)".to_string(), "term".to_string())),
is_dedup_inactive_fullscreen: false,
};
Expand Down Expand Up @@ -1644,7 +1644,7 @@ mod tests {
title: "kitty".to_string(),
initial_title: "kitty".to_string(),
is_active: true,
is_fullscreen: FullscreenMode::Fullsreen,
is_fullscreen: FullscreenMode::Fullscreen,
matched_rule: renamer.parse_icon(
"kitty".to_string(),
"kitty".to_string(),
Expand Down

0 comments on commit db232a2

Please sign in to comment.