Tighten --help
75 lines to 51. The format section had grown into prose that explained the same thing twice, and two of the three examples were variations on one idea, so one worked example survives. The samples were also taken verbatim from the machine this was developed on — a real toplevel identifier, a real output name, real app ids — which reads like configuration rather than illustration. They are generic now.
This commit is contained in:
+21
-45
@@ -728,77 +728,53 @@ wlgrid — a live grid of window and display previews, for picking one
|
|||||||
|
|
||||||
usage: wlgrid [options]
|
usage: wlgrid [options]
|
||||||
|
|
||||||
--format tsv|json|portal how to report the pick [tsv]; see FORMATS
|
--format tsv|json|portal how to report the pick [tsv]
|
||||||
--live all|current|none which tiles keep updating live [all]
|
--live all|current|none which tiles keep updating live [all]
|
||||||
(display tiles are always a single snapshot)
|
(displays are always a single snapshot)
|
||||||
--fps N cap on live updates per tile per second [12]
|
--fps N cap on live updates per tile per second [12]
|
||||||
--no-outputs windows only; by default whole displays are
|
--no-outputs windows only; displays are included by default
|
||||||
included too, labelled \"NAME · display\"
|
|
||||||
--hide-labels draw an icon-only grid
|
--hide-labels draw an icon-only grid
|
||||||
--font FAMILY label font family [Berkeley Mono]
|
--font FAMILY label font family [Berkeley Mono]
|
||||||
--font-size PX label size in logical px [13.3]
|
--font-size PX label size in logical px [13.3]
|
||||||
--timeout SECS exit after SECS regardless [off]
|
--timeout SECS exit anyway after SECS, in case the keyboard
|
||||||
(a safety valve: the overlay grabs the keyboard)
|
grab ever traps you [off]
|
||||||
-v, --verbose phase timings, the tile list, and capture stats
|
-v, --verbose phase timings, tile list and capture stats
|
||||||
-h, --help this
|
-h, --help this
|
||||||
|
|
||||||
keys: arrows, hjkl, or Tab/Shift+Tab move; Home/End jump; Enter picks;
|
keys: arrows, hjkl or Tab/Shift+Tab move; Home/End jump; Enter picks;
|
||||||
Escape or q cancels
|
Escape or q cancels
|
||||||
|
|
||||||
The pick goes to stdout, nothing does if you cancel; exit status is 0 for a
|
The pick goes to stdout and nothing does if you cancel, so exit status is
|
||||||
pick and 1 for a cancel.
|
0 for a pick and 1 for a cancel. Acting on it is the caller's job.
|
||||||
|
|
||||||
FORMATS
|
formats:
|
||||||
|
|
||||||
tsv One line of tab-separated columns; the default, meant for
|
tsv TYPE<TAB>ID<TAB>TOPLEVEL_ID<TAB>APP<TAB>TITLE, e.g.
|
||||||
`IFS=$'\\t' read` or cut(1):
|
|
||||||
|
|
||||||
TYPE<TAB>ID<TAB>TOPLEVEL_ID<TAB>APP<TAB>TITLE
|
window 1234 f0e1d2c3b4a59687 firefox Wikipedia
|
||||||
|
output HDMI-A-1 display HDMI-A-1
|
||||||
|
|
||||||
window 68 8e38849641c86be05bb1a68c163a1c41 dev.zed.Zed jobchi
|
ID is the thing to act on: a sway con_id, or the display name.
|
||||||
output DP-1 display DP-1
|
TOPLEVEL_ID is the ext-foreign-toplevel-list-v1 identifier that
|
||||||
|
capture tools address a window by (grim -T, the desktop portal),
|
||||||
|
empty for a display.
|
||||||
|
|
||||||
TYPE is \"window\" or \"output\", so a caller knows which kind of
|
json the same fields as one object, every key always present, for jq
|
||||||
thing it got. ID is the one to act on: a sway con_id for a
|
|
||||||
window, the name for a display. TOPLEVEL_ID is the
|
|
||||||
ext-foreign-toplevel-list-v1 identifier, which is what capture
|
|
||||||
tools address a window by (grim -T, the desktop portal); it is
|
|
||||||
empty for a display. APP is the app id, or \"display\".
|
|
||||||
|
|
||||||
json The same record as one object, with every key always present so
|
portal \"Window: TOPLEVEL_ID\" or \"Monitor: NAME\", what
|
||||||
jq can rely on it:
|
xdg-desktop-portal-wlr's simple chooser reads:
|
||||||
|
|
||||||
{\"type\":\"window\",\"con_id\":68,\"toplevel_id\":\"8e3884...\",
|
|
||||||
\"output\":null,\"app\":\"dev.zed.Zed\",\"title\":\"jobchi\"}
|
|
||||||
|
|
||||||
portal What xdg-desktop-portal-wlr's \"simple\" chooser reads, which lets
|
|
||||||
wlgrid be the picker a screencast pops up (getDisplayMedia in a
|
|
||||||
browser, for instance) with live previews of both windows and
|
|
||||||
whole displays:
|
|
||||||
|
|
||||||
Window: 8e38849641c86be05bb1a68c163a1c41
|
|
||||||
Monitor: DP-1
|
|
||||||
|
|
||||||
Put this in ~/.config/xdg-desktop-portal-wlr/config:
|
|
||||||
|
|
||||||
[screencast]
|
[screencast]
|
||||||
chooser_type=simple
|
chooser_type=simple
|
||||||
chooser_cmd=wlgrid --format portal
|
chooser_cmd=wlgrid --format portal
|
||||||
|
|
||||||
EXAMPLES, on sway
|
focusing on sway:
|
||||||
|
|
||||||
Focus a window:
|
|
||||||
swaymsg \"[con_id=$(wlgrid --no-outputs | cut -f2)] focus\"
|
|
||||||
|
|
||||||
Focus a window or move to a display, whichever was picked:
|
|
||||||
IFS=$'\\t' read -r type id toplevel app title < <(wlgrid) &&
|
IFS=$'\\t' read -r type id toplevel app title < <(wlgrid) &&
|
||||||
case $type in
|
case $type in
|
||||||
window) swaymsg \"[con_id=$id] focus\" ;;
|
window) swaymsg \"[con_id=$id] focus\" ;;
|
||||||
output) swaymsg \"focus output $id\" ;;
|
output) swaymsg \"focus output $id\" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
Screenshot whatever you pick:
|
|
||||||
grim -T \"$(wlgrid --no-outputs | cut -f3)\" shot.png
|
|
||||||
";
|
";
|
||||||
|
|
||||||
struct Args {
|
struct Args {
|
||||||
|
|||||||
Reference in New Issue
Block a user