From 0103c4a93c656f9ea503880f44bc21949ec53e94 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 11 Sep 2022 22:13:17 +1000 Subject: [PATCH] rotate all relevant screens when requested, and parse the output of xrandr and xinput better --- init.lua | 13 ++++++++----- rotate.lua | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 12d7e6b..2a071a0 100644 --- a/init.lua +++ b/init.lua @@ -25,12 +25,16 @@ local powermenu = { fullscreen = function(self) self.screen.navbar.visible = not self.screen.navbar.visible end, - rotateLeft = function() - awful.spawn(gears.filesystem.get_configuration_dir() .. "/awesome-powermenu/rotate.lua left") + rotateLeft = function(self) + for k,v in pairs(self.screen.outputs) do + awful.spawn(gears.filesystem.get_configuration_dir() .. "/awesome-powermenu/rotate.lua left " .. tostring(k)) + end awesome.restart() end, - rotateRight = function() - awful.spawn(gears.filesystem.get_configuration_dir() .. "/awesome-powermenu/rotate.lua right") + rotateRight = function(self) + for k,v in pairs(self.screen.outputs) do + awful.spawn(gears.filesystem.get_configuration_dir() .. "/awesome-powermenu/rotate.lua right " .. tostring(k)) + end awesome.restart() end, brightnessUp = function() @@ -86,7 +90,6 @@ function powermenu.new(s) } local powermenuPopup = awful.popup{ layout = wibox.layout.fixed.vertical, --- widget = wibox.container.constraint(powermenuWidget, "min", 512, 512), widget = powermenuWidget, border_color = beautiful.border_focus, border_width = 2, diff --git a/rotate.lua b/rotate.lua index d740af3..b4db45f 100755 --- a/rotate.lua +++ b/rotate.lua @@ -56,13 +56,13 @@ c=f:read("*a") f:close() local line = (c:match("\n("..disp:gsub("%p","%%%1") .. ".-)\n")) print(line) -local orientation = line:match("%S+ %S+ %S+ %S+ (%S+) ") +local orientation = line:match(".-(left) %(") or line:match(".-(right) %(") or line:match(".-(normal) %(") or line:match(".-(inverted) %(") local f = io.popen("xinput --list","r") local xin=f:read("*a"):lower() f:close() --⎜ ↳ Elan Touchscreen id=6 [slave pointer (2)] -local touchscreen = (xin:match("touch.*screen%s-id=(%d+)")) +local touchscreen = (xin:match("touch.*screen%s-id=(%d+)[^\n]-pointer")) print(orientation) print(nextLeft(orientation))