Skip to content

Commit

Permalink
wf-background: Load the next background when receiving SIGUSR1.
Browse files Browse the repository at this point in the history
  • Loading branch information
lcolitti committed Dec 5, 2023
1 parent f734c79 commit e342815
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/background/background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <gtk-utils.hpp>
#include <gtk-layer-shell.h>
#include <glib-unix.h>

#include "background.hpp"

Expand Down Expand Up @@ -283,6 +284,8 @@ void WayfireBackground::setup_window()
background_preserve_aspect.set_callback(reset_background);
background_cycle_timeout.set_callback(reset_cycle);

g_unix_signal_add(SIGHUP, sigusr1_handler, this);

window.property_scale_factor().signal_changed().connect(
sigc::mem_fun(this, &WayfireBackground::set_background));
}
Expand Down
7 changes: 7 additions & 0 deletions src/background/background.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ class WayfireBackground
void set_background();
void reset_cycle_timeout();

static int sigusr1_handler(void* thiz) {
std::cout << "Got SIGUSR1, reloading background" << std::endl;
((WayfireBackground*) thiz)->change_background(0);
g_unix_signal_add(SIGUSR1, sigusr1_handler, thiz);
return 0;
}

void setup_window();

public:
Expand Down

0 comments on commit e342815

Please sign in to comment.