Commit 8f8d42c8 authored by Denperidge's avatar Denperidge Committed by Denperidge
Browse files

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

parent f42dbd07
Loading
Loading
Loading
Loading
+0 −93
Original line number Diff line number Diff line
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(
+0 −26
Original line number Diff line number Diff line
{ 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 ];
  };
}
+27 −0
Original line number Diff line number Diff line
{
  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;
  };
}
+43 −0
Original line number Diff line number Diff line
{ stdenv, lib, fetchFromGitHub, rustPlatform, openssl, pkg-config }:
{
  lib,
  fetchFromGitHub,
  rustPlatform,
  openssl,
  pkg-config,
}:

rustPlatform.buildRustPackage rec {
rustPlatform.buildRustPackage {
  pname = "leftwm-theme";
  version = "unstable-2022-12-24";
  version = "unstable-2024-03-05";

  src = fetchFromGitHub {
    owner = "leftwm";
    repo = pname;
    rev = "7f2292f91f31d14a30d49372198c0e7cbe183223";
    sha256 = "sha256-tYT1eT7Rbs/6zZcl9eWsOA651dUGoXc7eRtVK8fn610=";
    repo = "leftwm-theme";
    rev = "b394824ff874b269a90c29e2d45b0cacc4d209f5";
    hash = "sha256-cV4tY1qKNluSSGf+WwKFK3iVE7cMevafl6qQvhy1flE=";
  };

  cargoSha256 = "sha256-3ZwVmyLvDq2z1FEqNuBlEgJLQ9KwcWj/jRlPNCNjCE4=";
  cargoHash = "sha256-VEQn1LFXiZCVR2WgOFoHo18d3cdIoq9/zNjg8GMs0j8=";

  checkFlags = [
    # direct writing /tmp
@@ -21,15 +27,17 @@ rustPlatform.buildRustPackage rec {
  ];

  nativeBuildInputs = [ pkg-config ];

  buildInputs = [ openssl ];

  meta = with lib; {
    broken = (stdenv.isLinux && stdenv.isAarch64);
    description = "A theme manager for LeftWM";
  env = {
    OPENSSL_NO_VENDOR = 1;
  };

  meta = {
    description = "Theme manager for LeftWM";
    homepage = "https://github.com/leftwm/leftwm-theme";
    license = licenses.bsd3;
    platforms = platforms.linux;
    maintainers = with maintainers; [ yanganto ];
    license = lib.licenses.bsd3;
    platforms = lib.platforms.linux;
    maintainers = with lib.maintainers; [ denperidge ];
  };
}
Loading