diff --git a/contrib/bash/polybar b/contrib/bash/polybar index 0df9a440..22982d37 100644 --- a/contrib/bash/polybar +++ b/contrib/bash/polybar @@ -31,10 +31,11 @@ _polybar() { -v --version -l --log= -q --quiet - -c --config= + -c --config= -r --reload -d --dump= -m --list-monitors + -M --list-all-monitors -w --print-wmname -s --stdout -p --png=' diff --git a/contrib/zsh/_polybar b/contrib/zsh/_polybar index ed6254de..41c121af 100644 --- a/contrib/zsh/_polybar +++ b/contrib/zsh/_polybar @@ -10,6 +10,7 @@ _polybar() { local R='-r --reload' local D='-d --dump' local M='-m --list-monitors' + local MM='-M --list-all-monitors' local W='-w --print-wmname' local S='-s --stdout' @@ -21,7 +22,8 @@ _polybar() { "($C)"{-c,--config=}'[Path to the configuration file]:configuration file:_files' \ "($R)"{-r,--reload}'[Reload when the configuration has been modified]' \ "($D $R $M $W $S)"{-d,--dump=}'[Print parameter value in bar section and exit]:parameter name' \ - "($M $D $R $W $S)"{-m,--list-monitors}'[Print list of available monitors and exit]' \ + "($MM $M $D $R $W $S)"{-m,--list-monitors}'[Print list of available monitors and exit (Removes cloned monitors)]' \ + "($MM $M $D $R $W $S)"{-M,--list-all-monitors}'[Print list of all available monitors (Including cloned monitors) and exit]' \ "($W $R $D $M $S)"{-w,--print-wmname}'[Print the generated WM_NAME and exit]' \ "($S)"{-s,--stdout}'[Output data to stdout instead of drawing the X window]' \ '::bar name:_polybar_list_names' diff --git a/doc/man/polybar.1.rst b/doc/man/polybar.1.rst index 58845034..3ccaa05f 100644 --- a/doc/man/polybar.1.rst +++ b/doc/man/polybar.1.rst @@ -44,6 +44,13 @@ OPTIONS .. option:: -m, --list-monitors Print list of available monitors and exit + + If some monitors are cloned, this will remove all but one of them +.. option:: -M, --list-all-monitors + + Print list of available monitors and exit + + This will also include all cloned monitors. .. option:: -w, --print-wmname Print the generated *WM_NAME* and exit diff --git a/src/main.cpp b/src/main.cpp index c3f1d441..b3996025 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,7 +21,8 @@ int main(int argc, char** argv) { command_line::option{"-c", "--config", "Path to the configuration file", "FILE"}, command_line::option{"-r", "--reload", "Reload when the configuration has been modified"}, command_line::option{"-d", "--dump", "Print value of PARAM in bar section and exit", "PARAM"}, - command_line::option{"-m", "--list-monitors", "Print list of available monitors and exit"}, + command_line::option{"-m", "--list-monitors", "Print list of available monitors and exit (Removes cloned monitors)"}, + command_line::option{"-M", "--list-all-monitors", "Print list of all available monitors (Including cloned monitors) and exit"}, command_line::option{"-w", "--print-wmname", "Print the generated WM_NAME and exit"}, command_line::option{"-s", "--stdout", "Output data to stdout instead of drawing it to the X window"}, command_line::option{"-p", "--png", "Save png snapshot to FILE after running for 3 seconds", "FILE"}, @@ -76,8 +77,10 @@ int main(int argc, char** argv) { //================================================== // List available XRandR entries //================================================== - if (cli->has("list-monitors")) { - for (auto&& mon : randr_util::get_monitors(conn, conn.root(), true)) { + if (cli->has("list-monitors") || cli->has("list-all-monitors")) { + bool purge_clones = !cli->has("list-all-monitors"); + auto monitors = randr_util::get_monitors(conn, conn.root(), true, purge_clones); + for (auto&& mon : monitors) { if (WITH_XRANDR_MONITORS && mon->output == XCB_NONE) { printf("%s: %ix%i+%i+%i (XRandR monitor%s)\n", mon->name.c_str(), mon->w, mon->h, mon->x, mon->y, mon->primary ? ", primary" : "");