diff --git a/README.md b/README.md index e951d72..3a00dde 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Sway Wallpaper -Display wallpapers on Sway, this is essentially a wrapper for `swaybg`. +Display wallpapers on Sway, this is essentially a wrapper for `swaybg` and `swaylock`, they are +required to run this utility. ## Features @@ -14,21 +15,22 @@ Display wallpapers on Sway, this is essentially a wrapper for `swaybg`. ## Usage ``` -usage: sway-wallpaper [options] +usage: sway-wallpaper [options] required: - output The outputs as shown with the command `swaymsg -t get_outputs` - path The path to the directory containing the wallpapers + path The path to the directory containing the wallpapers options: - -h, --help Show help - -i, --interval Specify the interval between wallpapers in seconds - --never-random if set, wallpapers order is based on the names of the files + -h, --help Show help + -i, --interval Specify the interval between wallpapers in seconds + --lock Lock the screen using swaylock instead of applying a wallpaper + --never-random if set, wallpapers order is based on the names of the files + -o, --output The outputs as shown with the command `swaymsg -t get_outputs`, by default the wallpaper will be applied to all outputs ``` Example: -`./sway-wallpaper /path/to/wallpapers -i 3600 DP-1` +`./sway-wallpaper /path/to/wallpapers -i 3600 -o DP-1` ## Installation diff --git a/src/CliArguments.h b/src/CliArguments.h index 85695df..476e9f4 100644 --- a/src/CliArguments.h +++ b/src/CliArguments.h @@ -40,7 +40,7 @@ namespace CliArguments { std::string getString(const std::string& argName) const { auto value = argumentsValue_.find(argName); if (value == argumentsValue_.end()) { - throw std::logic_error("trying to access non existant argument '" + argName + "'"); + throw std::logic_error("CliArguments Error: trying to access non existant argument '" + argName + "'"); } return value->second; } @@ -50,7 +50,7 @@ namespace CliArguments { try { return std::stoi(valueStr); } catch (std::exception& e) { - throw std::logic_error("trying to access argument '" + argName + "' (value: '" + valueStr + "')" + " as integer"); + throw std::logic_error("CliArguments Error: trying to access argument '" + argName + "' (value: '" + valueStr + "')" + " as integer"); } } @@ -67,7 +67,7 @@ namespace CliArguments { bool getBool(const std::string& argName) const { auto valueStr = getString(argName); if (valueStr != "true" && valueStr != "false") { - throw std::logic_error("trying to access argument '" + argName + "' (value: '" + valueStr + "')" + " as bool"); + throw std::logic_error("CliArguments Error: trying to access argument '" + argName + "' (value: '" + valueStr + "')" + " as bool"); } return valueStr == "true"; } diff --git a/src/main.cpp b/src/main.cpp index eb40ba8..5019dff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,8 +10,6 @@ int main(int argc, char** argv, char** envp) { try { - - CliArguments::CliArguments arguments{ argc, argv, { @@ -22,10 +20,9 @@ int main(int argc, char** argv, char** envp) { .direct = true }}, {"output", { - .description = "The outputs as shown with the command `swaymsg -t get_outputs`", + .aliases = {"o"}, + .description = "The outputs as shown with the command `swaymsg -t get_outputs`, by default the wallpaper will be applied to all outputs", .type = CliArguments::String, - .order = 1, - .direct = true }}, {"interval", { .aliases = {"i"}, @@ -60,7 +57,7 @@ int main(int argc, char** argv, char** envp) { } const std::string path = arguments.getString("path"); - const std::string output = arguments.getString("output"); + const std::string output = arguments.exists("output") ? arguments.getString("output") : "*"; Wallpapers wallpapers(path);