From 0c1d1a0f24655c22a373c19aac90a6a225a353e6 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sat, 8 Dec 2018 10:43:50 +0100 Subject: wanda: reformat source code --- src/wandad.cpp | 77 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 39 deletions(-) (limited to 'src/wandad.cpp') diff --git a/src/wandad.cpp b/src/wandad.cpp index 6008b57..e955beb 100644 --- a/src/wandad.cpp +++ b/src/wandad.cpp @@ -9,8 +9,8 @@ #include -#include #include +#include #include #include @@ -18,51 +18,50 @@ namespace { + constexpr auto image_filter = [](auto const & path) { + static auto const extensions = std::set{ + std::filesystem::path{".jpg"}, + std::filesystem::path{".png"}, + }; -constexpr auto image_filter = [](auto const &path) { - static auto const extensions = std::set{ - std::filesystem::path{".jpg"}, - std::filesystem::path{".png"}, - }; - - if (!std::filesystem::is_regular_file(path)) - { - return false; - } - - return extensions.find(path.extension()) != extensions.cend(); -}; + if (!std::filesystem::is_regular_file(path)) + { + return false; + } -struct listener : wanda::control_interface::listener -{ - listener(std::vector const &wallpapers, std::shared_ptr logger) - : m_wallpapers{wallpapers}, - m_logger{logger} - { - } + return extensions.find(path.extension()) != extensions.cend(); + }; - void on_received(wanda::control_interface &interface, wanda::command command) override + struct listener : wanda::control_interface::listener { - switch (command.id) + listener(std::vector const & wallpapers, std::shared_ptr logger) + : m_wallpapers{wallpapers} + , m_logger{logger} { - case wanda::command_id::change: - { - auto wallpaper = wanda::random_pick(m_wallpapers); - m_logger->info("changing wallpaper to '{}'", wallpaper.native()); - wanda::set_wallpaper(wallpaper, m_logger); - break; } - default: - m_logger->error("received unknown command '{}'", static_cast(command.id)); + + void on_received(wanda::control_interface & interface, wanda::command command) override + { + switch (command.id) + { + case wanda::command_id::change: + { + auto wallpaper = wanda::random_pick(m_wallpapers); + m_logger->info("changing wallpaper to '{}'", wallpaper.native()); + wanda::set_wallpaper(wallpaper, m_logger); + break; + } + default: + m_logger->error("received unknown command '{}'", static_cast(command.id)); + } } - } -private: - std::vector const &m_wallpapers; - std::shared_ptr m_logger; -}; + private: + std::vector const & m_wallpapers; + std::shared_ptr m_logger; + }; -} // namespace +} // namespace int main() { @@ -71,7 +70,7 @@ int main() auto log = spdlog::stdout_color_mt("wandad"); log->info("wanda is starting up"); - with(wanda::scan({"/usr/share/backgrounds"}, image_filter), [&](auto const &list) { + with(wanda::scan({"/usr/share/backgrounds"}, image_filter), [&](auto const & list) { auto service = asio::io_service{}; auto socket_path = wanda::xdg_path_for(wanda::xdg_directory::runtime_dir, wanda::environment{}) / ".wanda_interface"; @@ -91,7 +90,7 @@ int main() } auto signals = asio::signal_set{service, SIGINT}; - signals.async_wait([&](auto const &error, auto const signal) { + signals.async_wait([&](auto const & error, auto const signal) { if (!error && signal == SIGINT) { interface->shutdown(); -- cgit v1.2.3