Fixes #486.
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 05/09/2016
+.\" Date: 05/20/2016
.\" Manual: Bspwm Manual
-.\" Source: Bspwm 0.9.1-57-ge471298
+.\" Source: Bspwm 0.9.1-75-g666af89
.\" Language: English
.\"
-.TH "BSPWM" "1" "05/09/2016" "Bspwm 0\&.9\&.1\-57\-ge471298" "Bspwm Manual"
+.TH "BSPWM" "1" "05/20/2016" "Bspwm 0\&.9\&.1\-75\-g666af89" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.sp
Selectors are used to select a target node, desktop, or monitor\&. A selector can either describe the target relatively or name it globally\&.
.sp
-Selectors consist of a descriptor and any number of non\-conflicting modifiers as follows:
+Selectors consist of an optional reference, a descriptor and any number of non\-conflicting modifiers as follows:
.sp
.if n \{\
.RS 4
.\}
.nf
-DESCRIPTOR(\&.MODIFIER)*
+[REFERENCE#]DESCRIPTOR(\&.MODIFIER)*
.fi
.if n \{\
.RE
.\}
.sp
-An exclamation mark can be prepended to certain modifiers in order to reverse their meaning\&.
+The relative targets are computed in relation to the given reference (the default reference value is \fBfocused\fR)\&.
+.sp
+An exclamation mark can be prepended to any modifier in order to reverse its meaning\&.
.SS "Node"
.sp
Select a node\&.
.RS 4
.\}
.nf
-NODE_SEL := (DIR|CYCLE_DIR|PATH|last|older|newer|focused|pointed|biggest|<node_id>)[\&.[!]focused][\&.[!]automatic][\&.[!]local][\&.[!]leaf][\&.[!]window][\&.[!]STATE][\&.[!]FLAG][\&.[!]LAYER][\&.[!]same_class][\&.[!]descendant_of][\&.[!]ancestor_of]
+NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|last|older|newer|focused|pointed|biggest|<node_id>)[\&.[!]focused][\&.[!]automatic][\&.[!]local][\&.[!]leaf][\&.[!]window][\&.[!]STATE][\&.[!]FLAG][\&.[!]LAYER][\&.[!]same_class][\&.[!]descendant_of][\&.[!]ancestor_of]
STATE := tiled|pseudo_tiled|floating|fullscreen
.PP
[!]local
.RS 4
-Only consider nodes in or not in the current desktop\&.
+Only consider nodes in or not in the reference desktop\&.
.RE
.PP
[!]leaf
.RS 4
.\}
.nf
-DESKTOP_SEL := (CYCLE_DIR|last|older|newer|[MONITOR_SEL:](focused|^<n>)|<desktop_id>|<desktop_name>)[\&.[!]occupied][\&.[!]focused][\&.[!]urgent][\&.[!]local]
+DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|last|older|newer|[MONITOR_SEL:](focused|^<n>)|<desktop_id>|<desktop_name>)[\&.[!]occupied][\&.[!]focused][\&.[!]urgent][\&.[!]local]
.fi
.if n \{\
.RE
.PP
\fICYCLE_DIR\fR
.RS 4
-Selects the desktop in the given direction relative to the active desktop\&.
+Selects the desktop in the given direction relative to the reference desktop\&.
.RE
.PP
last
.RS 4
-Selects the previously focused desktop\&.
+Selects the previously focused desktop relative to the reference desktop\&.
.RE
.PP
older
.RS 4
-Selects the desktop older than the focused desktop in the history\&.
+Selects the desktop older than the reference desktop in the history\&.
.RE
.PP
newer
.RS 4
-Selects the desktop newer than the focused desktop in the history\&.
+Selects the desktop newer than the reference desktop in the history\&.
.RE
.PP
focused
.PP
[!]local
.RS 4
-Only consider inside or outside of the current monitor\&.
+Only consider inside or outside of the reference monitor\&.
.RE
.RE
.SS "Monitor"
.RS 4
.\}
.nf
-MONITOR_SEL := (DIR|CYCLE_DIR|last|older|newer|focused|primary|^<n>|<monitor_id>|<monitor_name>)[\&.[!]occupied][\&.[!]focused]
+MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|last|older|newer|focused|primary|^<n>|<monitor_id>|<monitor_name>)[\&.[!]occupied][\&.[!]focused]
.fi
.if n \{\
.RE
.PP
\fIDIR\fR
.RS 4
-Selects the monitor in the given (spacial) direction relative to the active monitor\&.
+Selects the monitor in the given (spacial) direction relative to the reference monitor\&.
.RE
.PP
\fICYCLE_DIR\fR
.RS 4
-Selects the monitor in the given (cyclic) direction relative to the active monitor\&.
+Selects the monitor in the given (cyclic) direction relative to the reference monitor\&.
.RE
.PP
last
.RS 4
-Selects the previously focused monitor\&.
+Selects the previously focused monitor relative to the reference monitor\&.
.RE
.PP
older
.RS 4
-Selects the monitor older than the focused monitor in the history\&.
+Selects the monitor older than the reference monitor in the history\&.
.RE
.PP
newer
.RS 4
-Selects the monitor newer than the focused monitor in the history\&.
+Selects the monitor newer than the reference monitor in the history\&.
.RE
.PP
focused
.ps +1
\fBCommands\fR
.RS 4
+.sp
+The optional selectors are references\&.
.PP
\fB\-N\fR, \fB\-\-nodes\fR [\fINODE_SEL\fR]
.RS 4
Selectors are used to select a target node, desktop, or monitor. A selector
can either describe the target relatively or name it globally.
-Selectors consist of a descriptor and any number of non-conflicting modifiers
-as follows:
+Selectors consist of an optional reference, a descriptor and any number of
+non-conflicting modifiers as follows:
- DESCRIPTOR(.MODIFIER)*
+ [REFERENCE#]DESCRIPTOR(.MODIFIER)*
-An exclamation mark can be prepended to certain modifiers in order to reverse their meaning.
+The relative targets are computed in relation to the given reference (the
+default reference value is *focused*).
+
+An exclamation mark can be prepended to any modifier in order to reverse its
+meaning.
Node
~~~~
Select a node.
----
-NODE_SEL := (DIR|CYCLE_DIR|PATH|last|older|newer|focused|pointed|biggest|<node_id>)[.[!]focused][.[!]automatic][.[!]local][.[!]leaf][.[!]window][.[!]STATE][.[!]FLAG][.[!]LAYER][.[!]same_class][.[!]descendant_of][.[!]ancestor_of]
+NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|last|older|newer|focused|pointed|biggest|<node_id>)[.[!]focused][.[!]automatic][.[!]local][.[!]leaf][.[!]window][.[!]STATE][.[!]FLAG][.[!]LAYER][.[!]same_class][.[!]descendant_of][.[!]ancestor_of]
STATE := tiled|pseudo_tiled|floating|fullscreen
Only consider nodes in automatic or manual insertion mode.
[!]local::
- Only consider nodes in or not in the current desktop.
+ Only consider nodes in or not in the reference desktop.
[!]leaf::
Only consider leaves or internal nodes.
Select a desktop.
----
-DESKTOP_SEL := (CYCLE_DIR|last|older|newer|[MONITOR_SEL:](focused|^<n>)|<desktop_id>|<desktop_name>)[.[!]occupied][.[!]focused][.[!]urgent][.[!]local]
+DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|last|older|newer|[MONITOR_SEL:](focused|^<n>)|<desktop_id>|<desktop_name>)[.[!]occupied][.[!]focused][.[!]urgent][.[!]local]
----
Descriptors
^^^^^^^^^^^
'CYCLE_DIR'::
- Selects the desktop in the given direction relative to the active desktop.
+ Selects the desktop in the given direction relative to the reference desktop.
last::
- Selects the previously focused desktop.
+ Selects the previously focused desktop relative to the reference desktop.
older::
- Selects the desktop older than the focused desktop in the history.
+ Selects the desktop older than the reference desktop in the history.
newer::
- Selects the desktop newer than the focused desktop in the history.
+ Selects the desktop newer than the reference desktop in the history.
focused::
Selects the currently focused desktop.
Only consider urgent or non urgent desktops.
[!]local::
- Only consider inside or outside of the current monitor.
+ Only consider inside or outside of the reference monitor.
Monitor
~~~~~~~
Select a monitor.
----
-MONITOR_SEL := (DIR|CYCLE_DIR|last|older|newer|focused|primary|^<n>|<monitor_id>|<monitor_name>)[.[!]occupied][.[!]focused]
+MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|last|older|newer|focused|primary|^<n>|<monitor_id>|<monitor_name>)[.[!]occupied][.[!]focused]
----
Descriptors
^^^^^^^^^^^
'DIR'::
- Selects the monitor in the given (spacial) direction relative to the active monitor.
+ Selects the monitor in the given (spacial) direction relative to the reference monitor.
'CYCLE_DIR'::
- Selects the monitor in the given (cyclic) direction relative to the active monitor.
+ Selects the monitor in the given (cyclic) direction relative to the reference monitor.
last::
- Selects the previously focused monitor.
+ Selects the previously focused monitor relative to the reference monitor.
older::
- Selects the monitor older than the focused monitor in the history.
+ Selects the monitor older than the reference monitor in the history.
newer::
- Selects the monitor newer than the focused monitor in the history.
+ Selects the monitor newer than the reference monitor in the history.
focused::
Selects the currently focused monitor.
Commands
^^^^^^^^
+The optional selectors are references.
+
*-N*, *--nodes* ['NODE_SEL']::
List the IDs of the matching nodes.
int node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
{
+ coordinates_t ref_copy = *ref;
+ ref = &ref_copy;
char *desc_copy = copy_string(desc, strlen(desc));
desc = desc_copy;
+
+ char *hash = NULL;
+ char *path = strrchr(desc, '@');
+ if (path == NULL) {
+ hash = strrchr(desc, '#');
+ } else {
+ if (path != desc && *(path - 1) == '#') {
+ hash = path - 1;
+ }
+ }
+
+ if (hash != NULL) {
+ *hash = '\0';
+ int ret;
+ coordinates_t tmp = {mon, mon->desk, mon->desk->focus};
+ if ((ret = node_from_desc(desc, &tmp, ref)) == SELECTOR_OK) {
+ desc = hash + 1;
+ } else {
+ free(desc_copy);
+ return ret;
+ }
+ }
+
node_select_t sel = make_node_select();
char *colon = strrchr(desc, ':');
int desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
{
+ coordinates_t ref_copy = *ref;
+ ref = &ref_copy;
char *desc_copy = copy_string(desc, strlen(desc));
desc = desc_copy;
+
+ char *hash = strrchr(desc, '#');
+
+ if (hash != NULL) {
+ *hash = '\0';
+ int ret;
+ coordinates_t tmp = {mon, mon->desk, NULL};
+ if ((ret = desktop_from_desc(desc, &tmp, ref)) == SELECTOR_OK) {
+ desc = hash + 1;
+ } else {
+ free(desc_copy);
+ return ret;
+ }
+ }
+
desktop_select_t sel = make_desktop_select();
char *colon = strrchr(desc, ':');
int monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
{
+ coordinates_t ref_copy = *ref;
+ ref = &ref_copy;
char *desc_copy = copy_string(desc, strlen(desc));
desc = desc_copy;
+
+ char *hash = strrchr(desc, '#');
+
+ if (hash != NULL) {
+ *hash = '\0';
+ int ret;
+ coordinates_t tmp = {mon, NULL, NULL};
+ if ((ret = monitor_from_desc(desc, &tmp, ref)) == SELECTOR_OK) {
+ desc = hash + 1;
+ } else {
+ free(desc_copy);
+ return ret;
+ }
+ }
+
monitor_select_t sel = make_monitor_select();
if (!parse_monitor_modifiers(desc, &sel)) {