@@ -496,11 +496,25 @@ func DetectOutputs() (Outputs, error) {
496
496
return RandrParse (bytes .NewReader (output ))
497
497
}
498
498
499
+ type (
500
+ commands []command
501
+ command []string
502
+ )
503
+
504
+ func (c command ) Cmd () * exec.Cmd {
505
+ return exec .Command (c [0 ], c [1 :]... ) // #nosec
506
+ }
507
+
508
+ func newCommand (cmd string , args ... string ) command {
509
+ c := command {cmd }
510
+ return append (c , args ... )
511
+ }
512
+
499
513
// BuildCommandOutputRow return a sequence of calls to `xrandr` to configure
500
514
// all named outputs in a row, left to right, given the currently active
501
515
// Outputs and a list of output names, optionally followed by "@" and the
502
516
// desired mode, e.g. LVDS1@1377x768.
503
- func BuildCommandOutputRow (rule Rule , current Outputs ) ([] * exec. Cmd , error ) {
517
+ func BuildCommandOutputRow (rule Rule , current Outputs ) (commands , error ) {
504
518
var outputs []string
505
519
var row bool
506
520
@@ -606,18 +620,17 @@ func BuildCommandOutputRow(rule Rule, current Outputs) ([]*exec.Cmd, error) {
606
620
for _ , enableArgs := range enableOutputArgs {
607
621
args = append (args , enableArgs ... )
608
622
}
609
- cmd := exec .Command (command , args ... )
610
- return []* exec.Cmd {cmd }, nil
623
+ return commands {newCommand (command , args ... )}, nil
611
624
}
612
625
613
626
V ("splitting the configuration into several calls to xrandr\n " )
614
627
615
628
// otherwise return several calls to xrandr
616
- cmds := [] * exec. Cmd {}
629
+ cmds := commands {}
617
630
618
631
// disable an output
619
632
if len (disableOutputArgs ) > 0 {
620
- cmds = append (cmds , exec . Command (command , disableOutputArgs [0 ]... ))
633
+ cmds = append (cmds , newCommand (command , disableOutputArgs [0 ]... ))
621
634
disableOutputArgs = disableOutputArgs [1 :]
622
635
}
623
636
@@ -633,7 +646,7 @@ func BuildCommandOutputRow(rule Rule, current Outputs) ([]*exec.Cmd, error) {
633
646
enableOutputArgs = enableOutputArgs [1 :]
634
647
}
635
648
636
- cmds = append (cmds , exec . Command (command , args ... ))
649
+ cmds = append (cmds , newCommand (command , args ... ))
637
650
}
638
651
639
652
return cmds , nil
0 commit comments