Skip to content

Commit 5a5ee17

Browse files
committed
Allow vertical display configuration
Closes #27
1 parent 805bdcc commit 5a5ee17

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

cmd_apply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func ApplyRule(outputs Outputs, rule Rule) error {
2929
var err error
3030

3131
switch {
32-
case rule.ConfigureSingle != "" || len(rule.ConfigureRow) > 0:
32+
case rule.ConfigureSingle != "" || len(rule.ConfigureRow) > 0 || len(rule.ConfigureColumn) > 0:
3333
cmds, err = BuildCommandOutputRow(rule, outputs)
3434
case rule.ConfigureCommand != "":
3535
cmds = []*exec.Cmd{exec.Command("sh", "-c", rule.ConfigureCommand)}

cmd_rules.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func (cmd CmdRules) Execute(args []string) error {
4141
printList("Present", rule.OutputsPresent)
4242
printList("Absent", rule.OutputsAbsent)
4343
printList("ConfigureRow", rule.ConfigureRow)
44+
printList("ConfigureColumn", rule.ConfigureColumn)
4445
printOne("ConfigureSingle", rule.ConfigureSingle)
4546
printOne("ConfigureCommand", rule.ConfigureCommand)
4647
printList("ExecuteAfter", rule.ExecuteAfter)

doc/grobi.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ rules:
4949
execute_after:
5050
- xautolock -enable
5151

52+
# This is a rule for another docking station.
53+
- name: Docking Station at work
54+
# grobi takes the list of all the
55+
# outputs xrandr returns and verifies that DP2-2 and HDMI3 are present and
56+
# connected.
57+
outputs_connected: [DP2-2, HDMI3]
58+
59+
# when this rule matches, DP2-2 and HDMI3 are activated in their default
60+
# resolution and set above one another.
61+
# configuration: top is DP2-2, bottom is HDMI3
62+
configure_column:
63+
- DP2-2
64+
- HDMI3
65+
5266
# This is a rule for connecting the TV in the living room
5367
- name: TV
5468

randr.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,17 @@ func DetectOutputs() (Outputs, error) {
492492
// desired mode, e.g. LVDS1@1377x768.
493493
func BuildCommandOutputRow(rule Rule, current Outputs) ([]*exec.Cmd, error) {
494494
var outputs []string
495+
var row bool
495496

496497
switch {
497498
case rule.ConfigureSingle != "":
498499
outputs = []string{rule.ConfigureSingle}
499500
case len(rule.ConfigureRow) > 0:
500501
outputs = rule.ConfigureRow
502+
row = true
503+
case len(rule.ConfigureColumn) > 0:
504+
outputs = rule.ConfigureColumn
505+
row = false
501506
default:
502507
return nil, errors.New("empty monitor row configuration")
503508
}
@@ -528,7 +533,11 @@ func BuildCommandOutputRow(rule Rule, current Outputs) ([]*exec.Cmd, error) {
528533
}
529534

530535
if i > 0 {
531-
args = append(args, "--right-of", lastOutput)
536+
if row {
537+
args = append(args, "--right-of", lastOutput)
538+
} else {
539+
args = append(args, "--below", lastOutput)
540+
}
532541
}
533542

534543
if rule.Primary == name {

rule.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type Rule struct {
1010
OutputsAbsent []string `yaml:"outputs_absent"`
1111

1212
ConfigureRow []string `yaml:"configure_row"`
13+
ConfigureColumn []string `yaml:"configure_column"`
1314
ConfigureSingle string `yaml:"configure_single"`
1415
ConfigureCommand string `yaml:"configure_command"`
1516

0 commit comments

Comments
 (0)