Skip to content

Commit

Permalink
Fix swayosd-server exiting when no monitors exist (e.g. on switch to …
Browse files Browse the repository at this point in the history
…another tty)

The GApplication exits when no monitors exist. Counteract this by always
keeping a reference to the GApplication, which avoids this. Since
swayosd-server is a daemon, the normal behaviour of exiting after the
last window is gone is unwanted.
  • Loading branch information
Ferdi265 committed Nov 25, 2024
1 parent c21d34d commit 1506b27
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/server/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ pub struct SwayOSDApplication {
#[shrinkwrap(main_field)]
app: gtk::Application,
windows: Rc<RefCell<Vec<SwayosdWindow>>>,
_hold: Rc<gio::ApplicationHoldGuard>,
}

impl SwayOSDApplication {

Check warning on line 33 in src/server/application.rs

View workflow job for this annotation

GitHub Actions / cargo fmt

Diff in /home/runner/work/SwayOSD/SwayOSD/src/server/application.rs
pub fn new(server_config: ServerConfig, action_receiver: Receiver<(ArgTypes, String)>) -> Self {
let app = Application::new(Some(APPLICATION_NAME), ApplicationFlags::FLAGS_NONE);
let hold = Rc::new(app.hold());

app.add_main_option(
"config",
Expand Down Expand Up @@ -66,6 +68,7 @@ impl SwayOSDApplication {
let osd_app = SwayOSDApplication {

Check warning on line 68 in src/server/application.rs

View workflow job for this annotation

GitHub Actions / cargo fmt

Diff in /home/runner/work/SwayOSD/SwayOSD/src/server/application.rs
app: app.clone(),
windows: Rc::new(RefCell::new(Vec::new())),
_hold: hold,
};

// Apply Server Config
Expand Down

0 comments on commit 1506b27

Please sign in to comment.