mirror of
https://forge.katzen.cafe/schrottkatze/nix-configs.git
synced 2026-06-22 05:31:16 +02:00
niri update
This commit is contained in:
parent
040ad93106
commit
b85f0a45d6
4 changed files with 84 additions and 31 deletions
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
|||
[dependencies]
|
||||
serde = { version = "1.0.209", features = [ "derive" ] }
|
||||
serde_json = "1.0.127"
|
||||
niri-ipc = "25.5.1"
|
||||
niri-ipc = "26.4"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use core::panic;
|
||||
use std::{collections::HashMap, io::Write};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use niri_ipc::{
|
||||
socket::Socket,
|
||||
|
|
@ -19,18 +19,14 @@ const COLORS: [[&str; 2]; 7] = [
|
|||
["#cc241d", "#fb4934"], // red
|
||||
];
|
||||
|
||||
const ERR_COLORS: [&str; 2] = ["#ff0000", "#ffff00"];
|
||||
|
||||
// tildes because they're at the end of the ascii
|
||||
const BROKEN_NAME: &str = "~~~~~~~";
|
||||
|
||||
fn main() -> Result<(), std::io::Error> {
|
||||
let mut state = EventStreamState::default();
|
||||
let mut sock = Socket::connect()?;
|
||||
// let mut func = sock.send(Request::EventStream).and_then(|it| match it {
|
||||
// (Ok(Response::Handled), func) => Ok(func),
|
||||
// _ => unreachable!(),
|
||||
// })?;
|
||||
// let mut func = sock.send(Request::EventStream).and_then(|it| match it {
|
||||
// Ok(Response::Handled) => {}
|
||||
// Ok(_) => panic!("???"),
|
||||
// Err(e) => panic!("e"),
|
||||
// });
|
||||
let r = sock.send(Request::EventStream)?;
|
||||
match r {
|
||||
Ok(Response::Handled) => {}
|
||||
|
|
@ -38,7 +34,7 @@ fn main() -> Result<(), std::io::Error> {
|
|||
}
|
||||
|
||||
let mut receiver = sock.read_events();
|
||||
while let Ok(ev) = receiver() {
|
||||
'outer: while let Ok(ev) = receiver() {
|
||||
// check only relevant later, only done here to avoid a clone
|
||||
let ev_is_ws_related = matches!(
|
||||
&ev,
|
||||
|
|
@ -55,21 +51,26 @@ fn main() -> Result<(), std::io::Error> {
|
|||
.workspaces
|
||||
.workspaces
|
||||
.values()
|
||||
.map(|it| it.clone())
|
||||
.cloned()
|
||||
.collect::<Vec<Workspace>>();
|
||||
|
||||
workspaces.sort_by(|a, b| a.idx.cmp(&b.idx));
|
||||
workspaces.sort_by_key(|a| a.idx);
|
||||
workspaces.sort_by(|a, b| {
|
||||
a.output
|
||||
.clone()
|
||||
.expect("unreachable")
|
||||
.unwrap_or_else(|| BROKEN_NAME.to_string())
|
||||
.to_lowercase()
|
||||
.cmp(&b.output.clone().expect("unreachable").to_lowercase())
|
||||
.cmp(
|
||||
&b.output
|
||||
.clone()
|
||||
.unwrap_or_else(|| BROKEN_NAME.to_string())
|
||||
.to_lowercase(),
|
||||
)
|
||||
});
|
||||
|
||||
let output_colors_lut = workspaces
|
||||
.iter()
|
||||
.map(|it| it.output.clone().expect("unreachable"))
|
||||
.map(|it| it.output.clone().unwrap_or_else(|| BROKEN_NAME.to_string()))
|
||||
.fold(Vec::new(), |mut acc, it| {
|
||||
if !acc.contains(&it) {
|
||||
acc.push(it);
|
||||
|
|
@ -92,15 +93,16 @@ fn main() -> Result<(), std::io::Error> {
|
|||
name,
|
||||
..
|
||||
}| WsData {
|
||||
color: output_colors_lut[&output.clone().expect("unreachable")]
|
||||
[if *is_active { 1 } else { 0 }],
|
||||
color: output
|
||||
.as_ref()
|
||||
.map(|output| output_colors_lut[output])
|
||||
.unwrap_or(&ERR_COLORS)[if *is_active { 1 } else { 0 }],
|
||||
idx: *idx,
|
||||
focused: *is_focused,
|
||||
active: *is_active,
|
||||
icon: name.as_ref().map(|name| match name.as_str() {
|
||||
"aaa social" => "",
|
||||
"bbb browser" => "",
|
||||
"ccc notes" => "",
|
||||
"social" => "",
|
||||
"browser" => "",
|
||||
&_ => "!",
|
||||
}),
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue