Skip to content

Commit

Permalink
Fixed firefoxdeveloperedition icon and avoid crashing on i3 restart
Browse files Browse the repository at this point in the history
  • Loading branch information
Psykopear committed Mar 3, 2020
1 parent 52a0303 commit 65987dd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2583,6 +2583,7 @@ lazy_static! {
m.insert("hot".to_string(), '\u{f134}');
m.insert("rescue".to_string(), '\u{f134}');
m.insert("firefox".to_string(), '\u{f269}');
m.insert("firefoxdeveloperedition".to_string(), '\u{f269}');
m.insert("browser".to_string(), '\u{f269}');
m.insert("firefox-browser".to_string(), '\u{f907}');
m.insert("browser".to_string(), '\u{f907}');
Expand Down
52 changes: 31 additions & 21 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,28 +93,38 @@ fn rename_workspaces() {
}

fn main() {
// First set the correct names for the first time
rename_workspaces();
// Then listen to window events and update names when necessary
let mut listener = I3EventListener::connect().unwrap();
let subs = [Subscription::Window];
listener.subscribe(&subs).unwrap();
// Loop so that when i3 restarts it keeps working
// TODO: This might get out of hand, maybe
// add a sleep before restarting?
loop {
// Then listen to window events and update names when necessary
let mut listener = match I3EventListener::connect() {
Ok(listener) => listener,
Err(_) => continue
};

for event in listener.listen() {
match event.unwrap() {
Event::WindowEvent(e) => match e.change {
WindowChange::New => {
rename_workspaces();
}
WindowChange::Close => {
rename_workspaces();
}
WindowChange::Move => {
rename_workspaces();
}
_ => (),
},
_ => unreachable!(),
let subs = [Subscription::Window];
listener.subscribe(&subs).unwrap();

// First set the correct names for the first time
rename_workspaces();

for event in listener.listen() {
match event {
Ok(Event::WindowEvent(e)) => match e.change {
WindowChange::New => {
rename_workspaces();
}
WindowChange::Close => {
rename_workspaces();
}
WindowChange::Move => {
rename_workspaces();
}
_ => (),
},
_ => break,
}
}
}
}

0 comments on commit 65987dd

Please sign in to comment.