Commit 39a5a0fd authored by Antonio Yang's avatar Antonio Yang
Browse files

leftwm-config: init at 0.1.0

parent 30ace348
Loading
Loading
Loading
Loading
+93 −0
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(
+26 −0
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 ];
  };
}
+3 −1
Original line number Diff line number Diff line
@@ -29840,7 +29840,9 @@ with pkgs;
  keylight-controller-mschneider82 = callPackage ../applications/misc/keylight-controller-mschneider82 { };
  leftwm = callPackage ../applications/window-managers/leftwm { };
  leftwm = callPackage ../applications/window-managers/leftwm/leftwm { };
  leftwm-config = callPackage ../applications/window-managers/leftwm/leftwm-config { };
  levant = callPackage ../applications/networking/cluster/levant { };