2022-08-31 12:20:58 +00:00
-- 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
2022-08-25 15:27:31 +00:00
local awmtk2 = require ( " awmtk2 " )
local wibox = require ( " wibox " )
local gears = require ( " gears " )
local awful = require ( " awful " )
local beautiful = require ( " beautiful " )
return function ( args )
2022-09-05 21:54:11 +00:00
local style = awmtk2.create_style ( " root_buttons " ,
awmtk2.generic . button_list , args.style )
2022-08-31 12:20:58 +00:00
local templates = awmtk2.create_template_lib ( " root_buttons " , awmtk2.templates , args.templates )
2022-08-25 15:27:31 +00:00
local t = awmtk2.build_templates ( templates , style )
2022-08-31 12:20:58 +00:00
local poweroff = wibox.widget ( t.button ( {
image = beautiful [ " action-poweroff-symbolic " ] ,
2022-08-25 15:27:31 +00:00
widget = wibox.widget . imagebox ,
} , {
2022-08-31 12:20:58 +00:00
forced_width = style.button . forced_width ,
forced_height = style.button . forced_height
2022-08-25 15:27:31 +00:00
} ) )
2022-08-31 12:20:58 +00:00
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
2022-08-25 15:27:31 +00:00
end )
2022-08-31 12:20:58 +00:00
local lock = wibox.widget ( t.button ( {
image = beautiful [ " action-lock-screen-symbolic " ] ,
2022-08-25 15:27:31 +00:00
widget = wibox.widget . imagebox ,
} , {
2022-08-31 12:20:58 +00:00
forced_width = style.button . forced_width ,
forced_height = style.button . forced_height
2022-08-25 15:27:31 +00:00
} ) )
2022-08-31 12:20:58 +00:00
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 " )
2022-08-25 15:27:31 +00:00
end )
2022-08-31 12:20:58 +00:00
local suspend = wibox.widget ( t.button ( {
image = beautiful [ " action-suspend-symbolic " ] ,
2022-08-25 15:27:31 +00:00
widget = wibox.widget . imagebox ,
} , {
2022-08-31 12:20:58 +00:00
forced_width = style.button . forced_width ,
forced_height = style.button . forced_height
2022-08-25 15:27:31 +00:00
} ) )
2022-08-31 12:20:58 +00:00
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 " )
2022-08-25 15:27:31 +00:00
end )
2022-08-31 12:20:58 +00:00
local widget = wibox.widget {
poweroff ,
lock ,
suspend ,
2022-08-25 15:27:31 +00:00
layout = wibox.layout . fixed.horizontal ,
spacing = style.base . spacing
2022-08-31 12:20:58 +00:00
}
2022-08-25 15:27:31 +00:00
return widget
end