aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2018-11-29 22:40:56 +0100
committerFelix Morgner <felix.morgner@gmail.com>2018-11-29 22:40:56 +0100
commitac34053c57180b042426d82310d9ff57770387c9 (patch)
tree624478409e67fa1164538cbdec563ffe43e881be /src/main.cpp
parent962912ff747e4800720a9b5ccbcd40230421b3d1 (diff)
downloadwanda-ac34053c57180b042426d82310d9ff57770387c9.tar.xz
wanda-ac34053c57180b042426d82310d9ff57770387c9.zip
wanda: extract core components
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/main.cpp b/src/main.cpp
deleted file mode 100644
index 169efd9..0000000
--- a/src/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-#include "control_interface.hpp"
-#include "filesystem.hpp"
-#include "optional.hpp"
-#include "setting.hpp"
-#include "wallpaper.hpp"
-
-#include <boost/asio.hpp>
-
-#include <csignal>
-#include <iostream>
-#include <set>
-#include <string>
-
-namespace
-{
-
-constexpr auto image_filter = [](auto const &path) {
- static auto const extensions = std::set<std::filesystem::path>{
- std::filesystem::path{".jpg"},
- std::filesystem::path{".png"},
- };
-
- if (!std::filesystem::is_regular_file(path))
- {
- return false;
- }
-
- return extensions.find(path.extension()) != extensions.cend();
-};
-
-} // namespace
-
-int main()
-{
- using namespace wanda::std_ext;
-
- with(wanda::scan({"/usr/share/backgrounds"}, image_filter), [](auto const &list) {
- auto wallpaper = wanda::random_pick(list);
- wanda::set_wallpaper(wallpaper);
-
- auto service = boost::asio::io_service{};
- auto interface = wanda::make_interface(service, ".wanda_interface");
- auto status = interface->start();
-
- if (status)
- {
- return;
- }
-
- auto signals = boost::asio::signal_set{service, SIGINT};
- signals.async_wait([&](auto const &error, auto const signal) {
- if (!error && signal == SIGINT)
- {
- interface->shutdown();
- service.stop();
- }
- });
-
- service.run();
- }) || [] { std::cerr << "Directory does not exist\n"; };
-}