Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- command=`cat <<EOF
- local naughty = require("naughty")
- local awful = require("awful")
- awful.spawn.easy_async({"bash", "-c", "xrandr"},
- function(out)
- local displays = {}
- local s = {}
- local d = {}
- for l in string.gmatch(out, "[^\n]*") do
- if string.find(l, " connected") then -- display name
- table.insert(d, {string.match(l, "(%u+-?%d+)"),{}})
- else
- if not string.find(l, "disconnected") and not string.find(l, "Screen") and l ~="" then -- size and rate
- local r = {}
- local size = string.match(l, "(%d+x%d+)")
- for i in string.gmatch(l, "(%d+%p%d+)") do
- table.insert(r,{i,"xrandr --output " .. d[#d][1] .. " --mode " .. size .. " --rate " .. i})
- end
- table.insert(s, {size, r} )
- end
- end
- end
- local t = {}
- for _,disp in pairs(d) do
- local t1 = {}
- for _,size in pairs(s) do
- --if string.find( string.gsub(size[2][1][2], "([-])", " "), string.gsub(disp[1], "([-])", " ")) then
- if string.find( string.gsub(size[2][1][2], '[%-%.%+%[%]%(%)%$%^%%%?%*]','%%%1'), string.gsub(disp[1], '[%-%.%+%[%]%(%)%$%^%%%?%*]','%%%1')) then
- table.insert(t1,size)
- end
- end
- table.insert(t,{disp[1],t1})
- end
- local menu = awful.menu(t)
- menu:show()
- end
- )
- EOF
- `
- echo "${command}" | awesome-client
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement