67 lines
2.9 KiB
Lua
67 lines
2.9 KiB
Lua
-- This file is part of Reno desktop.
|
|
--
|
|
-- Reno desktop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
--
|
|
-- Reno desktop is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
--
|
|
-- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>.
|
|
-- Power/lock/suspend buttons for the global context menu
|
|
local awmtk2 = require("awmtk2")
|
|
local wibox = require("wibox")
|
|
local gears = require("gears")
|
|
local awful = require("awful")
|
|
local beautiful = require("beautiful")
|
|
|
|
return function(args)
|
|
local style = awmtk2.create_style("root_buttons",
|
|
awmtk2.generic.button_list,args.style)
|
|
local templates = awmtk2.create_template_lib("root_buttons",awmtk2.templates,args.templates)
|
|
local t = awmtk2.build_templates(templates,style,args.vertical)
|
|
local poweroff = wibox.widget(t.button({
|
|
image = beautiful["action-poweroff-symbolic"],
|
|
widget = wibox.widget.imagebox,
|
|
},{
|
|
forced_width = style.button.forced_width,
|
|
forced_height = style.button.forced_height
|
|
}))
|
|
poweroff:connect_signal("button::press",style.button.onpress)
|
|
poweroff:connect_signal("button::release",style.button.onrelease)
|
|
poweroff:connect_signal("button::press",function()
|
|
awful.spawn("systemctl poweroff") -- Works only with systemd
|
|
awful.spawn("loginctl poweroff") -- Works only with elogind
|
|
end)
|
|
local lock = wibox.widget(t.button({
|
|
image = beautiful["action-lock-screen-symbolic"],
|
|
widget = wibox.widget.imagebox,
|
|
},{
|
|
forced_width = style.button.forced_width,
|
|
forced_height = style.button.forced_height
|
|
}))
|
|
lock:connect_signal("button::press",style.button.onpress)
|
|
lock:connect_signal("button::release",style.button.onrelease)
|
|
lock:connect_signal("button::press",function()
|
|
awesome.emit_signal("lock_screen")
|
|
end)
|
|
local suspend = wibox.widget(t.button({
|
|
image = beautiful["action-suspend-symbolic"],
|
|
widget = wibox.widget.imagebox,
|
|
},{
|
|
forced_width = style.button.forced_width,
|
|
forced_height = style.button.forced_height
|
|
}))
|
|
suspend:connect_signal("button::press",style.button.onpress)
|
|
suspend:connect_signal("button::release",style.button.onrelease)
|
|
suspend:connect_signal("button::press",function()
|
|
awful.spawn("systemctl suspend")
|
|
awful.spawn("loginctl suspend")
|
|
end)
|
|
local widget = wibox.widget {
|
|
poweroff,
|
|
lock,
|
|
suspend,
|
|
layout = wibox.layout.fixed.horizontal,
|
|
spacing = style.base.spacing
|
|
}
|
|
return widget
|
|
end
|