diff options
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(); } }); |
