diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2018-11-29 22:28:07 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2018-11-29 22:28:07 +0100 |
| commit | 962912ff747e4800720a9b5ccbcd40230421b3d1 (patch) | |
| tree | 3b7dbd80b28887940449baef99d2a0a8957d21bc /src/main.cpp | |
| parent | 1125802463013dd5d4e38e142886ecb5fbafa2d9 (diff) | |
| download | wanda-962912ff747e4800720a9b5ccbcd40230421b3d1.tar.xz wanda-962912ff747e4800720a9b5ccbcd40230421b3d1.zip | |
wanda: fix shutdown code
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/main.cpp b/src/main.cpp index 6f8dcf8..169efd9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,8 @@ +#include "control_interface.hpp" #include "filesystem.hpp" -#include "setting.hpp" #include "optional.hpp" -#include "control_interface.hpp" +#include "setting.hpp" +#include "wallpaper.hpp" #include <boost/asio.hpp> @@ -13,19 +14,6 @@ namespace { -void set_wallpaper(std::filesystem::path wallpaper) -{ - using namespace wanda::literals; - using namespace wanda::std_ext; - using namespace std::string_literals; - - with("org.gnome.desktop.background"_setting, [&](auto &setting) { - with(setting["picture-uri"_key], [&](auto &value) { - value = "file://" + wallpaper.native(); - }) || [] { std::cerr << "No such key!\n"; }; - }) || [] { std::cerr << "No such setting!\n"; }; -} - constexpr auto image_filter = [](auto const &path) { static auto const extensions = std::set<std::filesystem::path>{ std::filesystem::path{".jpg"}, @@ -48,22 +36,22 @@ int main() with(wanda::scan({"/usr/share/backgrounds"}, image_filter), [](auto const &list) { auto wallpaper = wanda::random_pick(list); - std::cout << "changing wallpaper to " << wallpaper << '\n'; - set_wallpaper(wallpaper); + wanda::set_wallpaper(wallpaper); auto service = boost::asio::io_service{}; auto interface = wanda::make_interface(service, ".wanda_interface"); auto status = interface->start(); - if(status) + if (status) { return; } auto signals = boost::asio::signal_set{service, SIGINT}; - signals.async_wait([&](auto const & error, auto const signal){ - if(!error && signal == SIGINT) + signals.async_wait([&](auto const &error, auto const signal) { + if (!error && signal == SIGINT) { + interface->shutdown(); service.stop(); } }); |
