Skip to content

Commit d39b7fd

Browse files
lcolittiammen99
authored andcommitted
wf-background: Load the next background when receiving SIGUSR1.
1 parent b8752d1 commit d39b7fd

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/background/background.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <gtk-utils.hpp>
1717
#include <gtk-layer-shell.h>
18+
#include <glib-unix.h>
1819

1920
#include "background.hpp"
2021

@@ -330,6 +331,7 @@ class WayfireBackgroundApp : public WayfireShellApp
330331
{
331332
WayfireShellApp::instance =
332333
std::make_unique<WayfireBackgroundApp>(argc, argv);
334+
g_unix_signal_add(SIGUSR1, sigusr1_handler, (void*)instance.get());
333335
instance->run();
334336
}
335337

@@ -343,6 +345,16 @@ class WayfireBackgroundApp : public WayfireShellApp
343345
{
344346
backgrounds.erase(output);
345347
}
348+
349+
static gboolean sigusr1_handler(void *instance)
350+
{
351+
for (const auto& [_, bg] : ((WayfireBackgroundApp*)instance)->backgrounds)
352+
{
353+
bg->change_background();
354+
}
355+
356+
return TRUE;
357+
}
346358
};
347359

348360
int main(int argc, char **argv)

src/background/background.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class WayfireBackground
6060

6161
Glib::RefPtr<Gdk::Pixbuf> create_from_file_safe(std::string path);
6262
bool background_transition_frame(int timer);
63-
bool change_background();
6463
bool load_images_from_dir(std::string path);
6564
bool load_next_background(Glib::RefPtr<Gdk::Pixbuf> & pbuf, std::string & path);
6665
void reset_background();
@@ -71,4 +70,5 @@ class WayfireBackground
7170

7271
public:
7372
WayfireBackground(WayfireShellApp *app, WayfireOutput *output);
73+
bool change_background();
7474
};

0 commit comments

Comments
 (0)