Initial Commit
This commit is contained in:
19
module/auto-start.lua
Normal file
19
module/auto-start.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
-- MODULE AUTO-START
|
||||
-- Run all the apps listed in configuration/apps.lua as run_on_start_up only once when awesome start
|
||||
|
||||
local awful = require('awful')
|
||||
local apps = require('configuration.apps')
|
||||
|
||||
local function run_once(cmd)
|
||||
local findme = cmd
|
||||
local firstspace = cmd:find(' ')
|
||||
if firstspace then
|
||||
findme = cmd:sub(0, firstspace - 1)
|
||||
end
|
||||
awful.spawn.with_shell(string.format('pgrep -u $USER -x %s > /dev/null || (%s)', findme, cmd))
|
||||
--This broke compton ===> awful.spawn.single_instance(string.format('pgrep -u $USER -x %s > /dev/null || (%s)', findme, cmd))
|
||||
end
|
||||
|
||||
for _, app in ipairs(apps.run_on_start_up) do
|
||||
run_once(app)
|
||||
end
|
545
module/dashboard.lua
Normal file
545
module/dashboard.lua
Normal file
@@ -0,0 +1,545 @@
|
||||
local awful = require('awful')
|
||||
local gears = require('gears')
|
||||
local wibox = require('wibox')
|
||||
local beautiful = require('beautiful')
|
||||
local icons = require('theme.icons')
|
||||
local mat_list_item = require('widget.material.list-item')
|
||||
local mat_icon = require('widget.material.icon')
|
||||
local clickable_container = require('widget.material.clickable-container')
|
||||
local apps = require('configuration.apps')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
|
||||
local icon_size = beautiful.dashboard_icon_size or dpi(140)
|
||||
local username = os.getenv("USER")
|
||||
local panel_style = gears.shape.rounded_rect
|
||||
|
||||
local buildButton = function(icon, name)
|
||||
local button_text = wibox.widget {
|
||||
text = name,
|
||||
font = beautiful.font,
|
||||
align = 'center',
|
||||
valign = 'center',
|
||||
bg = beautiful.primary.hue_900,
|
||||
fg = beautiful.fg_normal,
|
||||
widget = wibox.widget.textbox
|
||||
}
|
||||
|
||||
local a_button = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{image = icon, widget = wibox.widget.imagebox},
|
||||
margins = dpi(16),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
bg = beautiful.groups_bg,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
shape = panel_style,
|
||||
forced_width = dpi(60),
|
||||
forced_height = dpi(60),
|
||||
visible = true,
|
||||
-- bg = beautiful.bg_normal,
|
||||
widget = clickable_container
|
||||
|
||||
},
|
||||
visible = true,
|
||||
-- bg = beautiful.bg_normal,
|
||||
shape = panel_style,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
local build_a_button = wibox.widget {
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
spacing = dpi(5),
|
||||
a_button
|
||||
-- button_text
|
||||
}
|
||||
|
||||
return build_a_button
|
||||
end
|
||||
|
||||
local buildLabel = function(name)
|
||||
local label_text = wibox.widget {
|
||||
{
|
||||
text = name,
|
||||
font = beautiful.font_large,
|
||||
align = 'center',
|
||||
valign = 'center',
|
||||
bg = beautiful.primary.hue_900,
|
||||
fg = beautiful.fg_normal,
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
shape = panel_style,
|
||||
forced_height = dpi(56),
|
||||
visible = true,
|
||||
-- bg = beautiful.bg_normal,
|
||||
widget = clickable_container
|
||||
}
|
||||
|
||||
local build_a_label = wibox.widget {
|
||||
layout = wibox.layout.flex.horizontal,
|
||||
spacing = dpi(5),
|
||||
label_text
|
||||
}
|
||||
|
||||
return build_a_label
|
||||
end
|
||||
|
||||
function suspend_command()
|
||||
dashboard_hide()
|
||||
awful.spawn.with_shell(apps.default.lock .. ' & systemctl suspend')
|
||||
end
|
||||
function exit_command() _G.awesome.quit() end
|
||||
function lock_command()
|
||||
dashboard_hide()
|
||||
awful.spawn.with_shell('sleep 1 && ' .. apps.default.lock)
|
||||
end
|
||||
function poweroff_command()
|
||||
awful.spawn.with_shell('poweroff')
|
||||
awful.keygrabber.stop(_G.dashboard_grabber)
|
||||
end
|
||||
function reboot_command()
|
||||
awful.spawn.with_shell('reboot')
|
||||
awful.keygrabber.stop(_G.dashboard_grabber)
|
||||
end
|
||||
|
||||
local poweroff = buildButton(icons.power, 'Shutdown')
|
||||
poweroff:connect_signal('button::release', function() poweroff_command() end)
|
||||
|
||||
local reboot = buildButton(icons.restart, 'Restart')
|
||||
reboot:connect_signal('button::release', function() reboot_command() end)
|
||||
|
||||
local suspend = buildButton(icons.sleep, 'Sleep')
|
||||
suspend:connect_signal('button::release', function() suspend_command() end)
|
||||
|
||||
local exit = buildButton(icons.logout, 'Logout')
|
||||
exit:connect_signal('button::release', function() exit_command() end)
|
||||
|
||||
local lock = buildButton(icons.lock, 'Lock')
|
||||
lock:connect_signal('button::release', function() lock_command() end)
|
||||
|
||||
local search = buildButton(icons.search, 'Search')
|
||||
search:connect_signal('button::release', function()
|
||||
-- rofi_command()
|
||||
dashboard_hide()
|
||||
_G.awesome.spawn(apps.default.rofi)
|
||||
end)
|
||||
|
||||
local close = buildButton(icons.close_dark, 'Close')
|
||||
close:connect_signal('button::release', function() dashboard_hide() end)
|
||||
|
||||
-- Get screen geometry
|
||||
local screen_geometry = awful.screen.focused().geometry
|
||||
|
||||
-- Create the widget
|
||||
dashboard = wibox({
|
||||
x = screen_geometry.x,
|
||||
y = screen_geometry.y,
|
||||
visible = false,
|
||||
ontop = true,
|
||||
type = 'splash',
|
||||
bg = beautiful.accent.hue_800 .. '66',
|
||||
height = screen_geometry.height,
|
||||
width = screen_geometry.width
|
||||
})
|
||||
|
||||
local dashboard_grabber
|
||||
|
||||
function dashboard_hide()
|
||||
awful.keygrabber.stop(dashboard_grabber)
|
||||
dashboard.visible = false
|
||||
end
|
||||
|
||||
function dashboard_show()
|
||||
dashboard_grabber = awful.keygrabber.run(
|
||||
function(_, key, event)
|
||||
if event == 'release' then return end
|
||||
|
||||
if key == 'Escape' or key == 'q' or key == 'x' or key == 'm' then
|
||||
dashboard_hide()
|
||||
end
|
||||
end)
|
||||
dashboard.visible = true
|
||||
end
|
||||
|
||||
dashboard:buttons(gears.table.join( -- Middle click - Hide dashboard
|
||||
awful.button({}, 2, function() dashboard_hide() end),
|
||||
awful.button({}, 3, function() dashboard_hide() end)))
|
||||
|
||||
local profile_picture = os.getenv("HOME") ..
|
||||
"/.face"
|
||||
|
||||
local profile = wibox.widget {
|
||||
wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
image = profile_picture,
|
||||
resize = true,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
resize = true,
|
||||
top = dpi(12),
|
||||
right = dpi(12),
|
||||
left = dpi(12),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
bg = beautiful.groups_bg,
|
||||
shape = panel_style,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
forced_width = dpi(244),
|
||||
forced_height = dpi(244),
|
||||
visible = true,
|
||||
bg = beautiful.bg_normal,
|
||||
shape = panel_style,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
wibox.widget {
|
||||
{
|
||||
wibox.widget {
|
||||
text = '@' .. username,
|
||||
font = beautiful.font_large,
|
||||
align = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
bottom = dpi(8),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
fg = beautiful.primary.hue_500,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
visible = true,
|
||||
bg = beautiful.bg_normal,
|
||||
shape = panel_style,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
local power_options = wibox.widget {
|
||||
{
|
||||
poweroff,
|
||||
reboot,
|
||||
suspend,
|
||||
exit,
|
||||
lock,
|
||||
layout = wibox.layout.flex.horizontal
|
||||
},
|
||||
visible = true,
|
||||
bg = beautiful.primary.hue_900,
|
||||
shape = panel_style,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
local search_button = wibox.widget {
|
||||
{
|
||||
search,
|
||||
bg = beautiful.primary.hue_600,
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
visible = true,
|
||||
bg = beautiful.primary.hue_200,
|
||||
shape = panel_style,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
local close_button = wibox.widget {
|
||||
{
|
||||
close,
|
||||
bg = beautiful.primary.hue_600,
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
visible = true,
|
||||
bg = beautiful.primary.hue_350,
|
||||
shape = panel_style,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
local quick_settings = wibox.widget {
|
||||
{
|
||||
{
|
||||
require('layout.left-panel.dashboard.quick-settings'),
|
||||
right = dpi(16),
|
||||
bottom = dpi(12),
|
||||
top = dpi(12),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
visible = true,
|
||||
bg = beautiful.bg_normal,
|
||||
shape = panel_style,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
bg = beautiful.bg_normal,
|
||||
shape = panel_style,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
local hardware_monitor = wibox.widget {
|
||||
{
|
||||
require('layout.left-panel.dashboard.hardware-monitor'),
|
||||
right = dpi(16),
|
||||
bottom = dpi(12),
|
||||
top = dpi(12),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
visible = true,
|
||||
bg = beautiful.bg_normal,
|
||||
shape = panel_style,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
local cal = require('widget.calendar')
|
||||
|
||||
--[[local calwidget = wibox.widget {
|
||||
{
|
||||
nil,
|
||||
{cal, margins = dpi(16), widget = wibox.container.margin},
|
||||
nil,
|
||||
layout = wibox.layout.flex.horizontal
|
||||
},
|
||||
resize = true,
|
||||
shape = panel_style,
|
||||
bg = beautiful.bg_normal,
|
||||
widget = wibox.container.background
|
||||
}]]
|
||||
|
||||
-- Fortune widget Credits: u/EmpressNoodle, github/elenapan
|
||||
local fortune_command = "fortune -n 140 -s"
|
||||
local fortune_update_interval = 3600
|
||||
-- local fortune_command = "fortune -n 140 -s computers"
|
||||
local fortune = wibox.widget {
|
||||
font = "Roboto 11",
|
||||
text = "You so poor you don't even have a cookie yet...",
|
||||
widget = wibox.widget.textbox
|
||||
}
|
||||
|
||||
local update_fortune = function()
|
||||
awful.spawn.easy_async_with_shell(fortune_command, function(out)
|
||||
-- Remove trailing whitespaces
|
||||
out = out:gsub('^%s*(.-)%s*$', '%1')
|
||||
fortune.markup = "<i>" .. out .. "</i>"
|
||||
end)
|
||||
end
|
||||
|
||||
gears.timer {
|
||||
autostart = true,
|
||||
timeout = fortune_update_interval,
|
||||
single_shot = false,
|
||||
call_now = true,
|
||||
callback = update_fortune
|
||||
}
|
||||
|
||||
local fortune_widget = wibox.widget {
|
||||
{
|
||||
{fortune, layout = wibox.layout.flex.horizontal},
|
||||
margins = dpi(16),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
bg = beautiful.primary.hue_700,
|
||||
fg = beautiful.primary.hue_900,
|
||||
shape = panel_style,
|
||||
forced_height = dpi(112),
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
local uptime_text = wibox.widget.textbox()
|
||||
uptime_text.font = "Roboto 10"
|
||||
uptime_text.valign = "center"
|
||||
awful.widget.watch("uptime -p | sed 's/^...//'", 60, function(_, stdout)
|
||||
local out = stdout:gsub('^%s*(.-)%s*up', '%1')
|
||||
uptime_text.text = out
|
||||
end)
|
||||
|
||||
local uptime_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
image = icons.uptime,
|
||||
resize = true,
|
||||
forced_width = dpi(24),
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
uptime_text,
|
||||
spacing = dpi(8),
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
margins = dpi(16),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
bg = beautiful.bg_normal,
|
||||
shape = panel_style,
|
||||
forced_height = dpi(48),
|
||||
forced_width = dpi(182),
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
-- Bookmarks
|
||||
function reddit_command()
|
||||
dashboard_hide()
|
||||
awful.spawn(apps.default.browser .. " " .. "reddit.com")
|
||||
end
|
||||
|
||||
function youtube_command()
|
||||
dashboard_hide()
|
||||
awful.spawn(apps.default.browser .. " " .. "youtube.com")
|
||||
end
|
||||
|
||||
function linkedin_command()
|
||||
dashboard_hide()
|
||||
awful.spawn(apps.default.browser .. " " .. "linkedin.com")
|
||||
end
|
||||
|
||||
function github_command()
|
||||
dashboard_hide()
|
||||
awful.spawn(apps.default.browser .. " " .. "github.com")
|
||||
end
|
||||
|
||||
function deviantart_command()
|
||||
dashboard_hide()
|
||||
awful.spawn(apps.default.browser .. " " .. "deviantart.com")
|
||||
end
|
||||
|
||||
function codeforces_command()
|
||||
dashboard_hide()
|
||||
awful.spawn(apps.default.browser .. " " .. "codeforces.com")
|
||||
end
|
||||
|
||||
function files_command(directory)
|
||||
dashboard_hide()
|
||||
awful.spawn(apps.default.files .. " " .. directory)
|
||||
end
|
||||
|
||||
local reddit = buildButton(icons.reddit, 'Reddit')
|
||||
reddit:connect_signal('button::release', function() reddit_command() end)
|
||||
|
||||
local youtube = buildButton(icons.youtube, 'Youtube')
|
||||
youtube:connect_signal('button::release', function() youtube_command() end)
|
||||
|
||||
local linkedin = buildButton(icons.linkedin, 'Linkedin')
|
||||
linkedin:connect_signal('button::release', function() linkedin_command() end)
|
||||
|
||||
local github = buildButton(icons.github, 'Github')
|
||||
github:connect_signal('button::release', function() github_command() end)
|
||||
|
||||
local deviantart = buildButton(icons.deviantart, 'Deviantart')
|
||||
deviantart:connect_signal('button::release', function() deviantart_command() end)
|
||||
|
||||
local codeforces = buildButton(icons.codeforces, 'Codeforces')
|
||||
codeforces:connect_signal('button::release', function() codeforces_command() end)
|
||||
|
||||
local home = buildLabel('Home')
|
||||
home:connect_signal('button::release', function() files_command(".") end)
|
||||
|
||||
local downloads = buildLabel('Downloads')
|
||||
downloads:connect_signal('button::release',
|
||||
function() files_command("Downloads") end)
|
||||
|
||||
local desktop = buildLabel('Desktop')
|
||||
desktop:connect_signal('button::release',
|
||||
function() files_command("Desktop") end)
|
||||
|
||||
local pictures = buildLabel('Pictures')
|
||||
pictures:connect_signal('button::release',
|
||||
function() files_command("Pictures") end)
|
||||
|
||||
local videos = buildLabel('Videos')
|
||||
videos:connect_signal('button::release', function() files_command("Videos") end)
|
||||
|
||||
local documents = buildLabel('Documents')
|
||||
documents:connect_signal('button::release',
|
||||
function() files_command("Documents") end)
|
||||
|
||||
local bookmarks = wibox.widget {
|
||||
{
|
||||
{reddit, youtube, linkedin, layout = wibox.layout.flex.horizontal},
|
||||
{github, deviantart, codeforces, layout = wibox.layout.ratio.horizontal},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
visible = true,
|
||||
bg = beautiful.bg_normal,
|
||||
shape = panel_style,
|
||||
forced_width = dpi(182),
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
local places = wibox.widget {
|
||||
{
|
||||
{
|
||||
home,
|
||||
desktop,
|
||||
downloads,
|
||||
pictures,
|
||||
documents,
|
||||
videos,
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
visible = true,
|
||||
bg = beautiful.bg_normal,
|
||||
shape = panel_style,
|
||||
forced_width = dpi(182),
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
-- Item placement
|
||||
dashboard:setup{
|
||||
nil,
|
||||
{
|
||||
nil,
|
||||
{
|
||||
{
|
||||
search_button,
|
||||
close_button,
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
quick_settings,
|
||||
hardware_monitor,
|
||||
fortune_widget,
|
||||
forced_width = dpi(300),
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
{
|
||||
bookmarks,
|
||||
places,
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
{
|
||||
power_options,
|
||||
uptime_widget,
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
{
|
||||
profile,
|
||||
calWidget,
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
nil,
|
||||
expand = 'none',
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
{nil, expand = 'none', layout = wibox.layout.align.horizontal},
|
||||
expand = 'none',
|
||||
layout = wibox.layout.align.vertical
|
||||
}
|
93
module/decorate-client.lua
Normal file
93
module/decorate-client.lua
Normal file
@@ -0,0 +1,93 @@
|
||||
local awful = require('awful')
|
||||
local gears = require('gears')
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
|
||||
local function renderClient(client, mode)
|
||||
if client.skip_decoration or (client.rendering_mode == mode) then
|
||||
return
|
||||
end
|
||||
|
||||
client.rendering_mode = mode
|
||||
client.floating = false
|
||||
client.maximized = false
|
||||
client.above = false
|
||||
client.below = false
|
||||
client.ontop = false
|
||||
client.sticky = false
|
||||
client.maximized_horizontal = false
|
||||
client.maximized_vertical = false
|
||||
|
||||
client.border_width = beautiful.border_width
|
||||
client.shape = function(cr, w, h)
|
||||
gears.shape.rectangle(cr, w, h)
|
||||
end
|
||||
end
|
||||
|
||||
local changesOnScreenCalled = false
|
||||
|
||||
local function changesOnScreen(currentScreen)
|
||||
local tagIsMax = currentScreen.selected_tag ~= nil and currentScreen.selected_tag.layout == awful.layout.suit.max
|
||||
local clientsToManage = {}
|
||||
|
||||
for _, client in pairs(currentScreen.clients) do
|
||||
if not client.skip_decoration and not client.hidden then
|
||||
table.insert(clientsToManage, client)
|
||||
end
|
||||
end
|
||||
|
||||
if (tagIsMax or #clientsToManage == 1) then
|
||||
currentScreen.client_mode = 'maximized'
|
||||
else
|
||||
currentScreen.client_mode = 'tiled'
|
||||
end
|
||||
|
||||
for _, client in pairs(clientsToManage) do
|
||||
renderClient(client, currentScreen.client_mode)
|
||||
end
|
||||
changesOnScreenCalled = false
|
||||
end
|
||||
|
||||
function clientCallback(client)
|
||||
if not changesOnScreenCalled then
|
||||
if not client.skip_decoration and client.screen then
|
||||
changesOnScreenCalled = true
|
||||
local screen = client.screen
|
||||
gears.timer.delayed_call(function()
|
||||
changesOnScreen(screen)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function tagCallback(tag)
|
||||
if not changesOnScreenCalled then
|
||||
if tag.screen then
|
||||
changesOnScreenCalled = true
|
||||
local screen = tag.screen
|
||||
gears.timer.delayed_call(function()
|
||||
changesOnScreen(screen)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
_G.client.connect_signal('manage', clientCallback)
|
||||
|
||||
_G.client.connect_signal('unmanage', clientCallback)
|
||||
|
||||
_G.client.connect_signal('property::hidden', clientCallback)
|
||||
|
||||
_G.client.connect_signal('property::minimized', clientCallback)
|
||||
|
||||
_G.client.connect_signal('property::fullscreen', function(c)
|
||||
if c.fullscreen then
|
||||
renderClient(c, 'maximized')
|
||||
else
|
||||
clientCallback(c)
|
||||
end
|
||||
end)
|
||||
|
||||
_G.tag.connect_signal('property::selected', tagCallback)
|
||||
|
||||
_G.tag.connect_signal('property::layout', tagCallback)
|
201
module/exit-screen.lua
Normal file
201
module/exit-screen.lua
Normal file
@@ -0,0 +1,201 @@
|
||||
local awful = require('awful')
|
||||
local gears = require('gears')
|
||||
local wibox = require('wibox')
|
||||
local beautiful = require('beautiful')
|
||||
local icons = require('theme.icons')
|
||||
local clickable_container = require('widget.material.clickable-container')
|
||||
local apps = require('configuration.apps')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
|
||||
-- Appearance
|
||||
local icon_size = beautiful.exit_screen_icon_size or dpi(140)
|
||||
|
||||
local buildButton = function(icon)
|
||||
local abutton =
|
||||
wibox.widget {
|
||||
wibox.widget {
|
||||
wibox.widget {
|
||||
wibox.widget {
|
||||
image = icon,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
top = dpi(16),
|
||||
bottom = dpi(16),
|
||||
left = dpi(16),
|
||||
right = dpi(16),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
shape = gears.shape.circle,
|
||||
forced_width = icon_size,
|
||||
forced_height = icon_size,
|
||||
widget = clickable_container
|
||||
},
|
||||
left = dpi(24),
|
||||
right = dpi(24),
|
||||
widget = wibox.container.margin
|
||||
}
|
||||
|
||||
return abutton
|
||||
end
|
||||
|
||||
function suspend_command()
|
||||
exit_screen_hide()
|
||||
awful.spawn.with_shell(apps.default.lock .. ' & systemctl suspend')
|
||||
end
|
||||
function exit_command()
|
||||
_G.awesome.quit()
|
||||
end
|
||||
function lock_command()
|
||||
exit_screen_hide()
|
||||
awful.spawn.with_shell('sleep 1 && ' .. apps.default.lock)
|
||||
end
|
||||
function poweroff_command()
|
||||
awful.spawn.with_shell('poweroff')
|
||||
awful.keygrabber.stop(_G.exit_screen_grabber)
|
||||
end
|
||||
function reboot_command()
|
||||
awful.spawn.with_shell('reboot')
|
||||
awful.keygrabber.stop(_G.exit_screen_grabber)
|
||||
end
|
||||
|
||||
local poweroff = buildButton(icons.power, 'Shutdown')
|
||||
poweroff:connect_signal(
|
||||
'button::release',
|
||||
function()
|
||||
poweroff_command()
|
||||
end
|
||||
)
|
||||
|
||||
local reboot = buildButton(icons.restart, 'Restart')
|
||||
reboot:connect_signal(
|
||||
'button::release',
|
||||
function()
|
||||
reboot_command()
|
||||
end
|
||||
)
|
||||
|
||||
local suspend = buildButton(icons.sleep, 'Sleep')
|
||||
suspend:connect_signal(
|
||||
'button::release',
|
||||
function()
|
||||
suspend_command()
|
||||
end
|
||||
)
|
||||
|
||||
local exit = buildButton(icons.logout, 'Logout')
|
||||
exit:connect_signal(
|
||||
'button::release',
|
||||
function()
|
||||
exit_command()
|
||||
end
|
||||
)
|
||||
|
||||
local lock = buildButton(icons.lock, 'Lock')
|
||||
lock:connect_signal(
|
||||
'button::release',
|
||||
function()
|
||||
lock_command()
|
||||
end
|
||||
)
|
||||
|
||||
-- Get screen geometry
|
||||
local screen_geometry = awful.screen.focused().geometry
|
||||
|
||||
-- Create the widget
|
||||
exit_screen =
|
||||
wibox(
|
||||
{
|
||||
x = screen_geometry.x,
|
||||
y = screen_geometry.y,
|
||||
visible = false,
|
||||
ontop = true,
|
||||
type = 'splash',
|
||||
height = screen_geometry.height,
|
||||
width = screen_geometry.width
|
||||
}
|
||||
)
|
||||
|
||||
exit_screen.bg = '#212121CC'
|
||||
--exit_screen.fg = beautiful.exit_screen_fg or beautiful.wibar_fg or '#FEFEFE'
|
||||
|
||||
local exit_screen_grabber
|
||||
|
||||
function exit_screen_hide()
|
||||
awful.keygrabber.stop(exit_screen_grabber)
|
||||
exit_screen.visible = false
|
||||
end
|
||||
|
||||
function exit_screen_show()
|
||||
-- naughty.notify({text = "starting the keygrabber"})
|
||||
exit_screen_grabber =
|
||||
awful.keygrabber.run(
|
||||
function(_, key, event)
|
||||
if event == 'release' then
|
||||
return
|
||||
end
|
||||
|
||||
if key == 's' then
|
||||
suspend_command()
|
||||
elseif key == 'e' then
|
||||
exit_command()
|
||||
elseif key == 'l' then
|
||||
lock_command()
|
||||
elseif key == 'p' then
|
||||
poweroff_command()
|
||||
elseif key == 'r' then
|
||||
reboot_command()
|
||||
elseif key == 'Escape' or key == 'q' or key == 'x' then
|
||||
-- naughty.notify({text = "Cancel"})
|
||||
exit_screen_hide()
|
||||
-- else awful.keygrabber.stop(exit_screen_grabber)
|
||||
end
|
||||
end
|
||||
)
|
||||
exit_screen.visible = true
|
||||
end
|
||||
|
||||
exit_screen:buttons(
|
||||
gears.table.join(
|
||||
-- Middle click - Hide exit_screen
|
||||
awful.button(
|
||||
{},
|
||||
2,
|
||||
function()
|
||||
exit_screen_hide()
|
||||
end
|
||||
),
|
||||
-- Right click - Hide exit_screen
|
||||
awful.button(
|
||||
{},
|
||||
3,
|
||||
function()
|
||||
exit_screen_hide()
|
||||
end
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
-- Item placement
|
||||
exit_screen:setup {
|
||||
nil,
|
||||
{
|
||||
nil,
|
||||
{
|
||||
-- {
|
||||
poweroff,
|
||||
reboot,
|
||||
suspend,
|
||||
exit,
|
||||
lock,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
-- },
|
||||
-- widget = exit_screen_box
|
||||
},
|
||||
nil,
|
||||
expand = 'none',
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
nil,
|
||||
expand = 'none',
|
||||
layout = wibox.layout.align.vertical
|
||||
}
|
53
module/notifications.lua
Normal file
53
module/notifications.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
local naughty = require('naughty')
|
||||
local beautiful = require('beautiful')
|
||||
local gears = require('gears')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
|
||||
-- Naughty presets
|
||||
naughty.config.padding = 8
|
||||
naughty.config.spacing = 8
|
||||
|
||||
naughty.config.defaults.timeout = 10
|
||||
naughty.config.defaults.screen = 1
|
||||
naughty.config.defaults.position = 'top_right'
|
||||
naughty.config.defaults.margin = dpi(16)
|
||||
naughty.config.defaults.ontop = true
|
||||
naughty.config.defaults.font = beautiful.font
|
||||
--naughty.config.defaults.icon = nil
|
||||
naughty.config.defaults.icon_size = dpi(32)
|
||||
naughty.config.defaults.shape = gears.shape.rounded_rect
|
||||
naughty.config.defaults.border_width = dpi(0)
|
||||
naughty.config.defaults.hover_timeout = nil
|
||||
|
||||
-- Error handling
|
||||
if _G.awesome.startup_errors then
|
||||
naughty.notify({
|
||||
preset = naughty.config.presets.critical,
|
||||
title = 'Oops, there were errors during startup!',
|
||||
text = _G.awesome.startup_errors
|
||||
})
|
||||
end
|
||||
|
||||
do
|
||||
local in_error = false
|
||||
_G.awesome.connect_signal('debug::error', function(err)
|
||||
if in_error then
|
||||
return
|
||||
end
|
||||
in_error = true
|
||||
|
||||
naughty.notify({
|
||||
preset = naughty.config.presets.critical,
|
||||
title = 'Oops, an error happened!',
|
||||
text = tostring(err)
|
||||
})
|
||||
in_error = false
|
||||
end)
|
||||
end
|
||||
|
||||
function log_this(title, txt)
|
||||
naughty.notify({
|
||||
title = 'log: ' .. title,
|
||||
text = txt
|
||||
})
|
||||
end
|
79
module/splash-terminal.lua
Normal file
79
module/splash-terminal.lua
Normal file
@@ -0,0 +1,79 @@
|
||||
local awful = require('awful')
|
||||
local app = require('configuration.apps').default.splash
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local beautiful = require('beautiful')
|
||||
local screen = awful.screen.focused()
|
||||
|
||||
-- Theme
|
||||
beautiful.init(require('theme'))
|
||||
|
||||
local splash_id = 'notnil'
|
||||
local splash_client
|
||||
local opened = false
|
||||
|
||||
function create_shell()
|
||||
splash_id = awful.spawn.with_shell(app)
|
||||
end
|
||||
|
||||
-- Dirty hack to prevent splash from showing up in occupied tags
|
||||
function _splash_to_current_tag()
|
||||
if splash_client then
|
||||
splash_client:move_to_tag(screen.selected_tag)
|
||||
end
|
||||
end
|
||||
|
||||
function open_splash()
|
||||
splash_client.hidden = false
|
||||
end
|
||||
|
||||
function close_splash()
|
||||
splash_client.hidden = true
|
||||
end
|
||||
|
||||
toggle_splash_height = function()
|
||||
if splash_client and opened then
|
||||
splash_client.maximized_vertical = not splash_client.maximized_vertical
|
||||
end
|
||||
end
|
||||
|
||||
toggle_splash = function()
|
||||
opened = not opened
|
||||
if not splash_client then
|
||||
create_shell()
|
||||
else
|
||||
if opened then
|
||||
open_splash()
|
||||
client.focus = splash_client
|
||||
splash_client:raise()
|
||||
else
|
||||
close_splash()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
_G.client.connect_signal('manage', function(c)
|
||||
if (c.pid == splash_id) then
|
||||
splash_client = c
|
||||
c.x = c.screen.geometry.x
|
||||
c.height = (c.screen.geometry.height / 5) * 3
|
||||
c.y = c.screen.geometry.height - c.height - beautiful.border_width - dpi(16)
|
||||
c.floating = true
|
||||
c.skip_taskbar = true
|
||||
c.skip_decoration = true
|
||||
c.ontop = true
|
||||
c.floating = true
|
||||
c.above = true
|
||||
c.sticky = true
|
||||
c.type = 'splash'
|
||||
c.hidden = not opened
|
||||
c.border_width = beautiful.border_width
|
||||
c.maximized_horizontal = true
|
||||
end
|
||||
end)
|
||||
|
||||
_G.client.connect_signal('unmanage', function(c)
|
||||
if (c.pid == splash_id) then
|
||||
opened = false
|
||||
splash_client = nil
|
||||
end
|
||||
end)
|
Reference in New Issue
Block a user