Advertisement
constantin-net

displaymenutest2.sh

Nov 18th, 2024 (edited)
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.59 KB | None | 0 0
  1. #!/bin/bash
  2. command=`cat <<EOF
  3. local naughty = require("naughty")
  4. local awful = require("awful")
  5. awful.spawn.easy_async({"bash", "-c", "xrandr"},
  6.     function(out)
  7.         local displays = {}
  8.         local s = {}
  9.         local d = {}
  10.         for l in string.gmatch(out, "[^\n]*") do
  11.             if string.find(l, " connected") then -- display name
  12.                 table.insert(d, {string.match(l, "(%u+-?%d+)"),{}})
  13.             else
  14.                 if not string.find(l, "disconnected") and not string.find(l, "Screen") and l ~="" then -- size and rate
  15.                     local r = {}
  16.                     local size = string.match(l, "(%d+x%d+)")
  17.                     for i in string.gmatch(l, "(%d+%p%d+)") do
  18.                         table.insert(r,{i,"xrandr --output " .. d[#d][1] .. " --mode " .. size .. " --rate " .. i})
  19.                     end
  20.                     table.insert(s, {size, r} )
  21.                 end
  22.             end
  23.         end
  24.         local t = {}
  25.         for _,disp in pairs(d) do
  26.             local t1 = {}
  27.             for _,size in pairs(s) do
  28.                 --if string.find( string.gsub(size[2][1][2], "([-])", " "), string.gsub(disp[1], "([-])", " ")) then
  29.                 if string.find( string.gsub(size[2][1][2], '[%-%.%+%[%]%(%)%$%^%%%?%*]','%%%1'), string.gsub(disp[1], '[%-%.%+%[%]%(%)%$%^%%%?%*]','%%%1')) then
  30.                     table.insert(t1,size)
  31.                 end
  32.             end
  33.             table.insert(t,{disp[1],t1})
  34.         end
  35.         local menu = awful.menu(t)
  36.         menu:show()
  37.     end
  38. )
  39. EOF
  40. `
  41. echo "${command}" | awesome-client
  42. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement