mirror of
https://github.com/vale981/bspwm
synced 2025-03-06 10:11:43 -05:00
Add index selector for desktops and monitors
This commit is contained in:
parent
8448fe0759
commit
e2f085815a
7 changed files with 77 additions and 3 deletions
26
doc/bspwm.1
26
doc/bspwm.1
|
@ -2,12 +2,12 @@
|
||||||
.\" Title: bspwm
|
.\" Title: bspwm
|
||||||
.\" Author: [see the "Author" section]
|
.\" Author: [see the "Author" section]
|
||||||
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
|
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
|
||||||
.\" Date: 08/28/2013
|
.\" Date: 09/02/2013
|
||||||
.\" Manual: Bspwm Manual
|
.\" Manual: Bspwm Manual
|
||||||
.\" Source: Bspwm 0.8
|
.\" Source: Bspwm 0.8
|
||||||
.\" Language: English
|
.\" Language: English
|
||||||
.\"
|
.\"
|
||||||
.TH "BSPWM" "1" "08/28/2013" "Bspwm 0\&.8" "Bspwm Manual"
|
.TH "BSPWM" "1" "09/02/2013" "Bspwm 0\&.8" "Bspwm Manual"
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
.\" * Define some portability stuff
|
.\" * Define some portability stuff
|
||||||
.\" -----------------------------------------------------------------
|
.\" -----------------------------------------------------------------
|
||||||
|
@ -277,6 +277,7 @@ Select a desktop\&.
|
||||||
.\}
|
.\}
|
||||||
.nf
|
.nf
|
||||||
DESKTOP_SEL := <desktop_name>
|
DESKTOP_SEL := <desktop_name>
|
||||||
|
| ^<n>
|
||||||
| (CYCLE_DIR|last|focused)[\&.occupied|\&.free][\&.urgent|\&.nonurgent]
|
| (CYCLE_DIR|last|focused)[\&.occupied|\&.free][\&.urgent|\&.nonurgent]
|
||||||
.fi
|
.fi
|
||||||
.if n \{\
|
.if n \{\
|
||||||
|
@ -291,6 +292,16 @@ DESKTOP_SEL := <desktop_name>
|
||||||
\fBPrimary Selectors\fR
|
\fBPrimary Selectors\fR
|
||||||
.RS 4
|
.RS 4
|
||||||
.PP
|
.PP
|
||||||
|
<desktop_name>
|
||||||
|
.RS 4
|
||||||
|
Selects the desktop with the given name\&.
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
|
^<n>
|
||||||
|
.RS 4
|
||||||
|
Selects the nth desktop\&.
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
\fICYCLE_DIR\fR
|
\fICYCLE_DIR\fR
|
||||||
.RS 4
|
.RS 4
|
||||||
Selects the desktop in the given direction relative to the active desktop\&.
|
Selects the desktop in the given direction relative to the active desktop\&.
|
||||||
|
@ -344,6 +355,7 @@ Select a monitor\&.
|
||||||
.\}
|
.\}
|
||||||
.nf
|
.nf
|
||||||
MONITOR_SEL := <monitor_name>
|
MONITOR_SEL := <monitor_name>
|
||||||
|
| ^<n>
|
||||||
| (DIR|CYCLE_DIR|last|focused)[\&.occupied|\&.free]
|
| (DIR|CYCLE_DIR|last|focused)[\&.occupied|\&.free]
|
||||||
.fi
|
.fi
|
||||||
.if n \{\
|
.if n \{\
|
||||||
|
@ -358,6 +370,16 @@ MONITOR_SEL := <monitor_name>
|
||||||
\fBPrimary Selectors\fR
|
\fBPrimary Selectors\fR
|
||||||
.RS 4
|
.RS 4
|
||||||
.PP
|
.PP
|
||||||
|
<monitor_name>
|
||||||
|
.RS 4
|
||||||
|
Selects the monitor with the given name\&.
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
|
^<n>
|
||||||
|
.RS 4
|
||||||
|
Selects the nth monitor\&.
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
\fIDIR\fR
|
\fIDIR\fR
|
||||||
.RS 4
|
.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 active monitor\&.
|
||||||
|
|
|
@ -197,12 +197,19 @@ Select a desktop.
|
||||||
|
|
||||||
----
|
----
|
||||||
DESKTOP_SEL := <desktop_name>
|
DESKTOP_SEL := <desktop_name>
|
||||||
|
| ^<n>
|
||||||
| (CYCLE_DIR|last|focused)[.occupied|.free][.urgent|.nonurgent]
|
| (CYCLE_DIR|last|focused)[.occupied|.free][.urgent|.nonurgent]
|
||||||
----
|
----
|
||||||
|
|
||||||
Primary Selectors
|
Primary Selectors
|
||||||
^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
<desktop_name>::
|
||||||
|
Selects the desktop with the given name.
|
||||||
|
|
||||||
|
^<n>::
|
||||||
|
Selects the nth desktop.
|
||||||
|
|
||||||
'CYCLE_DIR'::
|
'CYCLE_DIR'::
|
||||||
Selects the desktop in the given direction relative to the active desktop.
|
Selects the desktop in the given direction relative to the active desktop.
|
||||||
|
|
||||||
|
@ -234,12 +241,19 @@ Select a monitor.
|
||||||
|
|
||||||
----
|
----
|
||||||
MONITOR_SEL := <monitor_name>
|
MONITOR_SEL := <monitor_name>
|
||||||
|
| ^<n>
|
||||||
| (DIR|CYCLE_DIR|last|focused)[.occupied|.free]
|
| (DIR|CYCLE_DIR|last|focused)[.occupied|.free]
|
||||||
----
|
----
|
||||||
|
|
||||||
Primary Selectors
|
Primary Selectors
|
||||||
^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
<monitor_name>::
|
||||||
|
Selects the monitor with the given name.
|
||||||
|
|
||||||
|
^<n>::
|
||||||
|
Selects the nth monitor.
|
||||||
|
|
||||||
'DIR'::
|
'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 active monitor.
|
||||||
|
|
||||||
|
|
1
ewmh.c
1
ewmh.c
|
@ -39,7 +39,6 @@ uint32_t ewmh_get_desktop_index(desktop_t *d)
|
||||||
for (desktop_t *cd = m->desk_head; cd != NULL; cd = cd->next, i++)
|
for (desktop_t *cd = m->desk_head; cd != NULL; cd = cd->next, i++)
|
||||||
if (d == cd)
|
if (d == cd)
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -926,3 +926,8 @@ bool parse_window_id(char *s, long int *i)
|
||||||
*i = ret;
|
*i = ret;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool parse_index(char *s, int *i)
|
||||||
|
{
|
||||||
|
return sscanf(s, "^%i", i) == 1;
|
||||||
|
}
|
||||||
|
|
|
@ -31,5 +31,6 @@ bool parse_fence_move(char *, fence_move_t *);
|
||||||
bool parse_pointer_action(char *, pointer_action_t *);
|
bool parse_pointer_action(char *, pointer_action_t *);
|
||||||
bool parse_degree(char *, int *);
|
bool parse_degree(char *, int *);
|
||||||
bool parse_window_id(char *, long int *);
|
bool parse_window_id(char *, long int *);
|
||||||
|
bool parse_index(char *, int *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
31
query.c
31
query.c
|
@ -205,9 +205,12 @@ bool desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
|
||||||
dst->desktop = NULL;
|
dst->desktop = NULL;
|
||||||
|
|
||||||
cycle_dir_t cyc;
|
cycle_dir_t cyc;
|
||||||
|
int idx;
|
||||||
if (parse_cycle_direction(desc, &cyc)) {
|
if (parse_cycle_direction(desc, &cyc)) {
|
||||||
dst->monitor = ref->monitor;
|
dst->monitor = ref->monitor;
|
||||||
dst->desktop = closest_desktop(ref->monitor, ref->desktop, cyc, sel);
|
dst->desktop = closest_desktop(ref->monitor, ref->desktop, cyc, sel);
|
||||||
|
} else if (parse_index(desc, &idx)) {
|
||||||
|
desktop_from_index(idx, dst);
|
||||||
} else if (streq("last", desc)) {
|
} else if (streq("last", desc)) {
|
||||||
if (mon->last_desk != NULL && desktop_matches(mon->last_desk, sel)) {
|
if (mon->last_desk != NULL && desktop_matches(mon->last_desk, sel)) {
|
||||||
dst->monitor = mon;
|
dst->monitor = mon;
|
||||||
|
@ -245,10 +248,13 @@ bool monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
|
||||||
|
|
||||||
direction_t dir;
|
direction_t dir;
|
||||||
cycle_dir_t cyc;
|
cycle_dir_t cyc;
|
||||||
|
int idx;
|
||||||
if (parse_direction(desc, &dir)) {
|
if (parse_direction(desc, &dir)) {
|
||||||
dst->monitor = nearest_monitor(ref->monitor, dir, sel);
|
dst->monitor = nearest_monitor(ref->monitor, dir, sel);
|
||||||
} else if (parse_cycle_direction(desc, &cyc)) {
|
} else if (parse_cycle_direction(desc, &cyc)) {
|
||||||
dst->monitor = closest_monitor(ref->monitor, cyc, sel);
|
dst->monitor = closest_monitor(ref->monitor, cyc, sel);
|
||||||
|
} else if (parse_index(desc, &idx)) {
|
||||||
|
monitor_from_index(idx, dst);
|
||||||
} else if (streq("last", desc)) {
|
} else if (streq("last", desc)) {
|
||||||
if (last_mon != NULL && desktop_matches(last_mon->desk, sel)) {
|
if (last_mon != NULL && desktop_matches(last_mon->desk, sel)) {
|
||||||
dst->monitor = last_mon;
|
dst->monitor = last_mon;
|
||||||
|
@ -299,3 +305,28 @@ bool locate_monitor(char *name, coordinates_t *loc)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool desktop_from_index(int i, coordinates_t *loc)
|
||||||
|
{
|
||||||
|
for (monitor_t *m = mon_head; m != NULL; m = m->next)
|
||||||
|
for (desktop_t *d = m->desk_head; d != NULL; d = d->next, i--)
|
||||||
|
if (i == 1) {
|
||||||
|
loc->monitor = m;
|
||||||
|
loc->desktop = d;
|
||||||
|
loc->node = NULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool monitor_from_index(int i, coordinates_t *loc)
|
||||||
|
{
|
||||||
|
for (monitor_t *m = mon_head; m != NULL; m = m->next, i--)
|
||||||
|
if (i == 1) {
|
||||||
|
loc->monitor = m;
|
||||||
|
loc->desktop = NULL;
|
||||||
|
loc->node = NULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
2
query.h
2
query.h
|
@ -20,5 +20,7 @@ bool locate_monitor(char *, coordinates_t *);
|
||||||
bool node_from_desc(char *, coordinates_t *, coordinates_t *);
|
bool node_from_desc(char *, coordinates_t *, coordinates_t *);
|
||||||
bool desktop_from_desc(char *, coordinates_t *, coordinates_t *);
|
bool desktop_from_desc(char *, coordinates_t *, coordinates_t *);
|
||||||
bool monitor_from_desc(char *, coordinates_t *, coordinates_t *);
|
bool monitor_from_desc(char *, coordinates_t *, coordinates_t *);
|
||||||
|
bool desktop_from_index(int, coordinates_t *);
|
||||||
|
bool monitor_from_index(int, coordinates_t *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue