Make --output parameter optional
This commit is contained in:
parent
fe4e18f3b5
commit
fd6ece0041
3 changed files with 16 additions and 17 deletions
18
README.md
18
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] <path> <output>
|
||||
usage: sway-wallpaper [options] <path>
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue