Table of contents:
There is no real support for it, so you need to go manual and save the current location + re-apply it after focus change:
local function switch_focus_without_mouse(c, dir)
-- Get the mouse position
mouselocation_x = mouse.coords().x
mouselocation_y = mouse.coords().y
awful.client.focus.global_bydirection(dir, c, true)
-- Keep the mouse position
mouse.coords {
x = mouselocation_x,
y = mouselocation_y
}
end
This sets it on top + sticky so client always hangs there. Also reverts on second run.
local function float_toggle(c)
awful.client.floating.toggle()
if c.floating then
c.ontop=true
c.sticky=true
c.skip_taskbar=true
c.width=533
c.height=860
awful.placement.top_right(client.focus)
else
c.ontop=false
c.sticky=false
c.skip_taskbar=false
end
end
Suspends and puts client on color. Reverts on second run.
local function suspend_toggle(c)
awful.spawn.easy_async(
"ps -q " .. c.pid .. " -o state --no-headers",
function(stdout, stderr, reason, exit_code)
if stdout == "T\n" then
-- suspended, let's wake up
c.border_color = beautiful.border_normal
c.border_width = beautiful.border_width
c.opacity = 1
naughty.notify { text = "waking up client: " .. c.class .. " (" .. c.pid .. ")"}
awful.spawn("kill -18 " .. c.pid)
else
-- working, let's suspend
c.border_color = '#ff0000'
c.border_width = 10
c.opacity = 0.8
naughty.notify { text = "suspending client: " .. c.class .. " (" .. c.pid .. ")"}
awful.spawn("kill -19 " .. c.pid)
end
end
)
end
This is a dirty workaround instead of using screen.connect_signal("added"
etc. because if you're plugging/removing multiple monitors at once (e.g. docking station), you'll have weird issues due to multiple very-close restarts.
docked = false
if screen:count() > 1 then
docked = true
end
local function check_available_screens()
if ( docked and screen:count() == 1 ) or ( not docked and screen:count() == 2 ) then
print(">>>>>> Detected docking change, restarting awesomewm")
awesome.restart()
end
end
restart_timer = gears.timer {
timeout = 3,
autostart = true,
callback = function()
check_available_screens()
end
}
psi_timer = gears.timer {
timeout = 15,
autostart = true,
callback = function()
psi_widget:check()
end
}
Accepts screen object as input. You can bind it to a timer if you want it to change from time to time.
-- Needed helper function
function get_randomseed(b, m, r)
urand = assert (io.open ('/dev/urandom', 'rb'))
b = b or 4
m = m or 256
r = r or urand
local n, s = 0, r:read (b)
for i = 1, s:len () do
n = m * n + s:byte (i)
end
return n
end
function set_wallpaper(s)
-- choose random wallpaper
awful.spawn.easy_async(
"find /my/wallpaper/folder -not -path 'phone*' -type f",
function(stdout, stderr, reason, exit_code)
if exit_code == 0 then
local wallpapers = {}
for wp in stdout:gmatch("[^\r\n]+") do
table.insert(wallpapers, wp)
end
-- lua is the shittiest language ever
-- you need to set seed again, or the "random" will always return same
math.randomseed(get_randomseed())
gears.wallpaper.maximized(wallpapers[math.random(#wallpapers)], s)
else
naughty.notify({text = "Wallpaper assign error: " .. stderr})
end
end)
end