diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a57078d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +builddir diff --git a/meson.build b/meson.build index 5da9583..34c75cc 100644 --- a/meson.build +++ b/meson.build @@ -1,3 +1,3 @@ project('dotty', 'cpp') -executable('dotty', 'main.cpp', dependencies: []) +executable('dotty', 'src/main.cpp', dependencies: []) diff --git a/mise.toml b/mise.toml index c794c76..bc94a6c 100644 --- a/mise.toml +++ b/mise.toml @@ -8,3 +8,7 @@ run = "meson setup --reconfigure builddir" [tasks.compile] dir = "{{ cwd }}/builddir" run = "meson compile" + +[tasks.run] +dir = "{{ cwd }}/builddir" +run = "chmod +x dotty; sudo ./dotty" diff --git a/main.cpp b/src/main.cpp similarity index 77% rename from main.cpp rename to src/main.cpp index dbf8f8e..b3744b0 100644 --- a/main.cpp +++ b/src/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include using namespace std; using namespace std::filesystem; @@ -14,6 +15,11 @@ const path PACMAN_HOOKS = "/etc/pacman.d/hooks"; // int main(int argc, char **argv) { + if (geteuid() != 0) { + cout << "Sudo permissions are required to run this application"; + return 0; + } + if (!exists(PACMAN_HOOKS)) { create_directory(PACMAN_HOOKS); cout << "Directory created: " << PACMAN_HOOKS << endl;