leftwm-{config,theme}: update, migrate to by-name, refactor

(cherry picked from commit 8f8d42c893)
This commit is contained in:
Denperidge
2024-06-06 20:23:32 +02:00
committed by github-actions[bot]
parent e484e2433a
commit 21222437de
7 changed files with 71 additions and 159 deletions

View File

@@ -1,93 +0,0 @@
diff --git a/src/main.rs b/src/main.rs
index f9ccde5..3253b17 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,3 @@
-#![feature(is_some_with)]
#![allow(
clippy::module_name_repetitions,
clippy::too_many_lines,
diff --git a/src/tui/key_handler.rs b/src/tui/key_handler.rs
index 25cede0..cc875cc 100644
--- a/src/tui/key_handler.rs
+++ b/src/tui/key_handler.rs
@@ -247,7 +247,7 @@ fn right(app: &mut App) -> Result<bool> {
}
}
Window::WindowRules { index, empty } => {
- if app.current_popup.is_some_and(|i| *i == 2) {
+ if app.current_popup.map(|i| i == 2).unwrap_or(false) {
if let PopupState::Int { current, min, max } = app.current_popup_state {
if current < max {
app.current_popup_state = PopupState::Int {
@@ -315,7 +315,7 @@ fn left(app: &mut App) -> Result<bool> {
}
}
Window::WindowRules { index, empty } => {
- if app.current_popup.is_some_and(|i| *i == 2) {
+ if app.current_popup.map(|i| i == 2).unwrap_or(false) {
if let PopupState::Int { current, min, max } = app.current_popup_state {
if current > min {
app.current_popup_state = PopupState::Int {
@@ -491,7 +491,8 @@ fn enter_home(app: &mut App) -> Result<bool> {
.current_config
.workspaces
.as_ref()
- .is_some_and(|v| v.is_empty())
+ .map(|v| v.is_empty())
+ .unwrap_or(false)
|| app.current_config.workspaces.as_ref().is_none(),
};
}
@@ -502,7 +503,8 @@ fn enter_home(app: &mut App) -> Result<bool> {
.current_config
.tags
.as_ref()
- .is_some_and(|v| v.is_empty())
+ .map(|v| v.is_empty())
+ .unwrap_or(false)
|| app.current_config.tags.as_ref().is_none(),
}
}
@@ -513,7 +515,8 @@ fn enter_home(app: &mut App) -> Result<bool> {
.current_config
.window_rules
.as_ref()
- .is_some_and(|v| v.is_empty())
+ .map(|v| v.is_empty())
+ .unwrap_or(false)
|| app.current_config.window_rules.as_ref().is_none(),
}
}
@@ -524,7 +527,8 @@ fn enter_home(app: &mut App) -> Result<bool> {
.current_config
.scratchpad
.as_ref()
- .is_some_and(|v| v.is_empty())
+ .map(|v| v.is_empty())
+ .unwrap_or(false)
|| app.current_config.scratchpad.as_ref().is_none(),
}
}
@@ -1445,7 +1449,7 @@ fn enter_scratchpads(app: &mut App, index: usize, empty: bool) -> Result<bool> {
}
fn enter_keybinds(app: &mut App, index: usize, empty: bool) -> Result<bool> {
- if empty && app.config_list_state.selected().is_some_and(|i| *i == 2) {
+ if empty && app.config_list_state.selected().map(|i| i == 2).unwrap_or(false) {
app.current_config.keybind.push(Keybind::default());
} else {
match app.current_popup {
diff --git a/src/tui/popups.rs b/src/tui/popups.rs
index 7dddc12..c73edc5 100644
--- a/src/tui/popups.rs
+++ b/src/tui/popups.rs
@@ -130,7 +130,7 @@ pub fn modkey(
}
fn check_modifier(modifier: &Option<KeyModifier>, name: &str) -> bool {
- modifier.is_some_and(|m| if let Single(s) = m { *s == name } else { false })
+ modifier.as_ref().map(|m| if let Single(s) = m { s == name } else { false }).unwrap_or(false)
}
pub fn max_window_width(

View File

@@ -1,26 +0,0 @@
{ stdenv, lib, fetchFromGitHub, rustPlatform }:
rustPlatform.buildRustPackage rec {
pname = "leftwm-config";
version = "0.1.0";
src = fetchFromGitHub {
owner = "leftwm";
repo = pname;
rev = version;
sha256 = "sha256-hWxyzgWWh6CBxpbbXfd888Q70cCZQ9FESDijOSXtdZA=";
};
cargoSha256 = "sha256-NfBteoknxveIGrpSuDe70LLnGvN3nb9gvbVbbwsYD4A=";
patches = [ ./0001-rm-unstable-is-some-with-feature.patch ];
meta = with lib; {
broken = (stdenv.isLinux && stdenv.isAarch64);
description = "A little satellite utility for LeftWM";
homepage = "https://github.com/leftwm/leftwm-config";
license = licenses.bsd3;
platforms = platforms.linux;
maintainers = with maintainers; [ yanganto ];
};
}

View File

@@ -1,35 +0,0 @@
{ stdenv, lib, fetchFromGitHub, rustPlatform, openssl, pkg-config }:
rustPlatform.buildRustPackage rec {
pname = "leftwm-theme";
version = "unstable-2022-12-24";
src = fetchFromGitHub {
owner = "leftwm";
repo = pname;
rev = "7f2292f91f31d14a30d49372198c0e7cbe183223";
sha256 = "sha256-tYT1eT7Rbs/6zZcl9eWsOA651dUGoXc7eRtVK8fn610=";
};
cargoSha256 = "sha256-3ZwVmyLvDq2z1FEqNuBlEgJLQ9KwcWj/jRlPNCNjCE4=";
checkFlags = [
# direct writing /tmp
"--skip=models::config::test::test_config_new"
# with network access when testing
"--skip=operations::update::test::test_update_repos"
];
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl ];
meta = with lib; {
broken = (stdenv.isLinux && stdenv.isAarch64);
description = "A theme manager for LeftWM";
homepage = "https://github.com/leftwm/leftwm-theme";
license = licenses.bsd3;
platforms = platforms.linux;
maintainers = with maintainers; [ yanganto ];
};
}

View File

@@ -0,0 +1,27 @@
{
lib,
fetchFromGitHub,
rustPlatform,
}:
rustPlatform.buildRustPackage {
pname = "leftwm-config";
version = "0-unstable-2024-03-13";
src = fetchFromGitHub {
owner = "leftwm";
repo = "leftwm-config";
rev = "a9f2f21ece3a01d6c36610295ae3163644d3f99e";
hash = "sha256-wyb/26EyNyBJeTDUvnMxlMiQjaCGBES8t4VteNY1I/A=";
};
cargoHash = "sha256-U3mgbG9h2cDqr0aqxbI2CJUOweIoDXDxmsWg0zxolSo=";
meta = {
description = "Little satellite utility for LeftWM";
homepage = "https://github.com/leftwm/leftwm-config";
maintainers = with lib.maintainers; [ denperidge ];
license = lib.licenses.bsd3;
platforms = lib.platforms.linux;
};
}

View File

@@ -0,0 +1,43 @@
{
lib,
fetchFromGitHub,
rustPlatform,
openssl,
pkg-config,
}:
rustPlatform.buildRustPackage {
pname = "leftwm-theme";
version = "unstable-2024-03-05";
src = fetchFromGitHub {
owner = "leftwm";
repo = "leftwm-theme";
rev = "b394824ff874b269a90c29e2d45b0cacc4d209f5";
hash = "sha256-cV4tY1qKNluSSGf+WwKFK3iVE7cMevafl6qQvhy1flE=";
};
cargoHash = "sha256-VEQn1LFXiZCVR2WgOFoHo18d3cdIoq9/zNjg8GMs0j8=";
checkFlags = [
# direct writing /tmp
"--skip=models::config::test::test_config_new"
# with network access when testing
"--skip=operations::update::test::test_update_repos"
];
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl ];
env = {
OPENSSL_NO_VENDOR = 1;
};
meta = {
description = "Theme manager for LeftWM";
homepage = "https://github.com/leftwm/leftwm-theme";
license = lib.licenses.bsd3;
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [ denperidge ];
};
}

View File

@@ -31561,11 +31561,7 @@ with pkgs;
keylight-controller-mschneider82 = callPackage ../applications/misc/keylight-controller-mschneider82 { };
leftwm = callPackage ../applications/window-managers/leftwm/leftwm { };
leftwm-config = callPackage ../applications/window-managers/leftwm/leftwm-config { };
leftwm-theme = callPackage ../applications/window-managers/leftwm/leftwm-theme { };
leftwm = callPackage ../applications/window-managers/leftwm { };
levant = callPackage ../applications/networking/cluster/levant { };