diff --git a/monitor-switch/update-output.scala b/monitor-switch/update-output.scala index 3f140e8..7c744e3 100755 --- a/monitor-switch/update-output.scala +++ b/monitor-switch/update-output.scala @@ -4,6 +4,8 @@ val eDP1 = List("--output", "eDP1", "--primary", "--auto", "--pos", "0x0", "--ro val interfaceMapOn = Map[String, Seq[String]]( "DP1" -> List("--output", "DP1", "--auto", "--right-of", "eDP1", "--rotate", "normal"), + "DP2" -> List("--output", "DP2", "--auto", "--right-of", "eDP2", "--rotate", "normal"), + "HDMI1" -> List("--output", "HDMI1", "--auto", "--left-of", "eDP1", "--rotate", "normal"), "HDMI2" -> List("--output", "HDMI2", "--auto", "--left-of", "eDP1", "--rotate", "normal") ) @@ -14,6 +16,8 @@ val interfaceMapOff = Map[String, Seq[String]]( "HDMI2" -> List("--output", "HDMI2", "--off") ) +Thread.sleep(100) + val interfacesOn = ("/usr/bin/xrandr" #| Seq("grep", "-w", "connected") #| Seq("tr", "-s", "' '") #| Seq("cut", "-d", " ", "-f", "1")).!!.trim.split("\n") val interfacesOff = ("/usr/bin/xrandr" #| Seq("grep", "-w", "disconnected") #| Seq("tr", "-s", "' '") #| Seq("cut", "-d", " ", "-f", "1")).!!.trim.split("\n") var execCmd = "/usr/bin/xrandr" :: eDP1 ++ @@ -25,3 +29,21 @@ println(s"Disabled interfaces: ${interfacesOff.mkString(" ")}") println(s"Executing command line: $execCmd") execCmd.! + +Thread.sleep(100) + +if (interfacesOn.length > 1) { + val moveWorkspace = (workspace: Int, workspaceInterface: String) => { + val exec = Seq("i3-msg", s"workspace number $workspace, move workspace to output $workspaceInterface") + println(exec) + exec.! + } + + val workspaceInterface = interfacesOn.filterNot(_.equalsIgnoreCase("eDP1")).headOption.getOrElse("eDP1") + println(s"Moving workspace 9-10 to eDP1") + (9 to 10).foreach(moveWorkspace(_, "eDP1")) + println(s"Moving workspaces 1-8 to $workspaceInterface") + (1 to 8).foreach(moveWorkspace(_, workspaceInterface)) + + Seq("i3-msg", "workspace number 1").! +}