This commit is contained in:
Aire-One 2021-05-25 17:37:29 +02:00
commit 82e9525978
24 changed files with 743 additions and 0 deletions

View File

@ -0,0 +1,15 @@
local applications = {}
applications.terminal = 'xterm'
applications.editor = os.getenv('EDITOR') or 'vim'
applications.open_editor = function (file)
return applications.terminal
.. ' -e ' .. applications.editor .. ' ' .. file
end
applications.open_man = function (file)
return applications.terminal .. ' -e man ' .. file
end
return applications

View File

@ -0,0 +1,65 @@
local akey = require 'awful.key'
local aclient = require 'awful.client'
local control = 'Control'
local modkey = 'Mod4'
local shift = 'Shift'
local client_keybindings = {
akey({ modkey }, 'f',
function (client)
client.fullscreen = not client.fullscreen
client:raise()
end,
{ description = 'toggle fullscreen', group = 'client' }),
akey({ modkey, shift }, 'c',
function (client)
client:kill()
end,
{ description = 'close', group = 'client' }),
akey({ modkey, control }, 'space',
aclient.floating.toggle,
{ description = 'toggle floating', group = 'client' }),
akey({ modkey, control }, 'Return',
function (client)
client:swap(aclient.getmaster())
end,
{ description = 'move to master', group = 'client' }),
akey({ modkey }, 'o',
function (client)
client:move_to_screen()
end,
{ description = 'move to screen', group = 'client' }),
akey({ modkey }, 't',
function (client)
client.ontop = not client.ontop
end,
{ description = 'toggle keep on top', group = 'client' }),
akey({ modkey }, 'n',
function (client)
-- The client currently has the input focus, so it cannot be
-- minimized, since minimized clients can't have the focus.
client.minimized = true
end ,
{ description = 'minimize', group = 'client' }),
akey({ modkey }, 'm',
function (client)
client.maximized = not client.maximized
client:raise()
end,
{ description = '(un)maximize', group = 'client' }),
akey({ modkey, control }, 'm',
function (client)
client.maximized_vertical = not client.maximized_vertical
client:raise()
end,
{ description = '(un)maximize vertically', group = 'client' }),
akey({ modkey, shift }, 'm',
function (client)
client.maximized_horizontal = not client.maximized_horizontal
client:raise()
end,
{ description = '(un)maximize horizontally', group = 'client' })
}
return client_keybindings

View File

@ -0,0 +1,25 @@
local abutton = require 'awful.button'
local modkey = 'Mod4'
local mousebindings = {
abutton({ }, 1, function (client)
client:activate {
context = 'mouse_click'
}
end),
abutton({ modkey }, 1, function (client)
client:activate {
context = 'mouse_click',
action = 'mouse_move'
}
end),
abutton({ modkey }, 3, function (client)
client:activate {
context = 'mouse_click',
action = 'mouse_resize'
}
end)
}
return mousebindings

View File

@ -0,0 +1,64 @@
local akey = require 'awful.key'
local aprompt = require 'awful.prompt'
local autil = require 'awful.util'
local ascreen = require 'awful.screen'
local aspawn = require 'awful.spawn'
local menubar = require 'menubar'
local applications = require 'rc.configuration.applications'
local desktop_bar = require 'rc.ui.desktop_decoration.bar'
local hotkeys_popup = require 'rc.ui.hotkeys_popup'
local mymainmenu = require 'rc.ui.menu.mymainmenu'
local capi = {
awesome = awesome
}
local control = 'Control'
local modkey = 'Mod4'
local shift = 'Shift'
local global_keybindings = {
akey({ modkey }, 's',
hotkeys_popup.show_help,
{ description = 'show help', group = 'awesome' }),
akey({ modkey }, 'w',
function ()
mymainmenu():show()
end,
{ description = 'show main menu', group = 'awesome' }),
akey({ modkey, control }, 'r',
capi.awesome.restart,
{ description = 'reload awesome', group = 'awesome' }),
akey({ modkey, shift }, 'q',
capi.awesome.quit,
{ description = 'quit awesome', group = 'awesome' }),
akey({ modkey }, 'x',
function ()
aprompt.run {
prompt = 'Run Lua code: ',
textbox = desktop_bar(ascreen.focused()).promptbox.widget,
exe_callback = autil.eval,
history_path = autil.get_cache_dir() .. '/history_eval'
}
end,
{ description = 'lua execute prompt', group = 'awesome' }),
akey({ modkey }, 'Return',
function ()
aspawn(applications.terminal)
end,
{ description = 'open a terminal', group = 'launcher' }),
akey({ modkey }, 'r',
function ()
desktop_bar(ascreen.focused()).promptbox:run()
end,
{ description = 'run prompt', group = 'launcher' }),
akey({ modkey }, 'p',
function ()
menubar.show()
end,
{ description = 'show the menubar', group = 'launcher' })
}
return global_keybindings

View File

@ -0,0 +1,14 @@
local abutton = require 'awful.button'
local atag = require 'awful.tag'
local mymainmenu = require 'rc.ui.menu.mymainmenu'
local global_mousebindings = {
abutton({ }, 3, function ()
mymainmenu():toggle()
end),
abutton({ }, 4, atag.viewprev),
abutton({ }, 5, atag.viewnext)
}
return global_mousebindings

17
configuration/init.lua Normal file
View File

@ -0,0 +1,17 @@
local rc_configuration = {}
rc_configuration.applications = require 'rc.configuration.applications'
rc_configuration.client_keybindings = require 'rc.configuration.client_keybindings'
rc_configuration.client_mousebindings = require 'rc.configuration.client_mousebindings'
rc_configuration.global_keybindings = require 'rc.configuration.global_keybindings'
rc_configuration.global_mousebindings = require 'rc.configuration.global_mousebindings'
rc_configuration.menu = require 'rc.configuration.menu'
rc_configuration.rules = require 'rc.configuration.rules'
rc_configuration.tag_layouts = require 'rc.configuration.tag_layouts'
return rc_configuration

View File

@ -0,0 +1,6 @@
local configuration_menu = {}
configuration_menu.myawesomemenu = require 'rc.configuration.menu.myawesomemenu'
configuration_menu.mymainmenu = require 'rc.configuration.menu.mymainmenu'
return configuration_menu

View File

@ -0,0 +1,16 @@
local applications = require 'rc.configuration.applications'
local hotkeys_popup = require 'rc.ui.hotkeys_popup'
local capi = {
awesome = _G.awesome
}
local myawesomemenu = {
{ 'hotkeys', function () hotkeys_popup.show_help() end },
{ 'manual', applications.open_man('awesome') },
{ 'edit config', applications.open_editor(capi.awesome.conffile) },
{ 'restart', capi.awesome.restart },
{ 'quit', capi.awesome.quit }
}
return myawesomemenu

View File

@ -0,0 +1,11 @@
local beautiful = require 'beautiful'
local applications = require 'rc.configuration.applications'
local myawesomemenu = require 'rc.configuration.menu.myawesomemenu'
local mymainmenu = {
{ 'awesome', myawesomemenu, beautiful.awesome_icon },
{ 'open terminal', applications.terminal }
}
return mymainmenu

View File

@ -0,0 +1,7 @@
local firefox_rule = {
id = 'firefox',
rule = { class = 'Firefox' },
properties = { screen = 1, tag = '2' }
}
return firefox_rule

View File

@ -0,0 +1,21 @@
local floating_rule = {
id = 'floating',
rule_any = {
instance = { 'copyq', 'pinentry' },
class = {
'Arandr', 'Blueman-manager', 'Gpick', 'Kruler', 'Sxiv',
'Tor Browser', 'Wpa_gui', 'veromix', 'xtightvncviewer'
},
name = {
'Event Tester', -- xev.
},
role = {
'AlarmWindow', -- Thunderbird's calendar.
'ConfigManager', -- Thunderbird's about:config.
'pop-up',-- e.g. Google Chrome's (detached) Developer Tools.
}
},
properties = { floating = true }
}
return floating_rule

View File

@ -0,0 +1,16 @@
local aclient = require 'awful.client'
local aplacement = require 'awful.placement'
local ascreen = require 'awful.screen'
local global_rule = {
id = 'global',
rule = {},
properties = {
focus = aclient.focus.filter,
raise = true,
screen = ascreen.preferred,
placement = aplacement.no_overlap + aplacement.no_offscreen
}
}
return global_rule

View File

@ -0,0 +1,8 @@
local client_rules = {}
client_rules.global = require 'rc.configuration.rules.client.global'
client_rules.floating = require 'rc.configuration.rules.client.floating'
client_rules.titlebar = require 'rc.configuration.rules.client.titlebars'
-- client_rules.firefox = require 'rc.configuration.rules.client.firefox'
return client_rules

View File

@ -0,0 +1,9 @@
local titlebar_rule = {
id = 'titlebars',
rule_any = {
type = { 'normal', 'dialog' }
},
properties = { titlebars_enabled = true }
}
return titlebar_rule

View File

@ -0,0 +1,6 @@
local rules = {}
rules.client = require 'rc.configuration.rules.client'
rules.notification = require 'rc.configuration.rules.notification'
return rules

View File

@ -0,0 +1,11 @@
local ascreen = require 'awful.screen'
local global_rule = {
rule = {},
properties = {
screen = ascreen.preferred,
implicit_timeout = 5,
}
}
return global_rule

View File

@ -0,0 +1,5 @@
local notification_rules = {}
notification_rules.global = require 'rc.configuration.rules.notification.global'
return notification_rules

View File

@ -0,0 +1,19 @@
local alayout = require 'awful.layout'
local tag_layouts = {
alayout.suit.floating,
alayout.suit.tile,
alayout.suit.tile.left,
alayout.suit.tile.bottom,
alayout.suit.tile.top,
alayout.suit.fair,
alayout.suit.fair.horizontal,
alayout.suit.spiral,
alayout.suit.spiral.dwindle,
alayout.suit.max,
alayout.suit.max.fullscreen,
alayout.suit.magnifier,
alayout.suit.corner.nw
}
return tag_layouts

149
init.lua Normal file
View File

@ -0,0 +1,149 @@
-- awesome_mode: api-level=4:screen=on
-- If LuaRocks is installed, make sure that packages installed through it are
-- found (e.g. lgi). If LuaRocks is not installed, do nothing.
pcall(require, 'luarocks.loader')
local gtimer = require 'gears.timer'
local legacy = require 'awesome-legacy'
local naughty = require 'naughty'
local ruled = require 'ruled'
local slot = require 'awesome-slot'
-- Load global awesome components from the C API
local capi = {
client = _G.client,
screen = _G.screen,
tag = _G.tag
}
-- Beautiful needs to be initialized as soon as possible to make theme
-- variables available to the configuration module.
legacy.beautiful {
base = 'default',
theme = require 'rc.theme'
}
legacy.manage_error()
legacy.autofocus()
legacy.sloppy_focus()
local configuration = require 'rc.configuration'
local my_slots = require 'rc.slots'
-- This needs to be run after awesome has completed C API initialization and
-- the `root` object is available.
gtimer.delayed_call(function ()
legacy.global_mouse_bindings(configuration.global_mousebindings)
legacy.global_keybindings(configuration.global_keybindings)
end)
-- luacheck: ignore unused variable load_wallpaper
local load_wallpaper = slot {
id = 'LOAD_WALLPAPER',
action = slot.actions.CREATE | slot.actions.CONNECT,
target = capi.screen,
signal = 'request::wallpaper',
slot = slot.slots.screen.wallpaper
}
-- luacheck: ignore unused variable default_layout
local default_layout = slot {
id = 'DEFAULT_LAYOUTS',
action = slot.actions.CREATE | slot.actions.CONNECT,
target = capi.tag,
signal = 'request::default_layouts',
slot = slot.slots.tag.default_layouts,
slot_params = {
layouts = configuration.tag_layouts
}
}
-- luacheck: ignore unused variable create_tag
local create_tag = slot {
id = 'CREATE_TAGS',
action = slot.actions.CREATE | slot.actions.CONNECT,
target = capi.screen,
signal = 'request::desktop_decoration',
slot = my_slots.create_tags
}
-- luacheck: ignore unused variable desktop_decoration
local desktop_decoration = slot {
id = 'DESKTOP_DECORATION',
action = slot.actions.CREATE | slot.actions.CONNECT,
target = capi.screen,
signal = 'request::desktop_decoration',
slot = my_slots.build_desktop_decoration
}
-- luacheck: ignore unused variable client_mousebinding
local client_mousebinding = slot {
id = 'CLIENT_MOUSE_BINDINGS',
action = slot.actions.CREATE | slot.actions.CONNECT,
target = capi.client,
signal = 'request::default_mousebindings',
slot = slot.slots.client.append_mousebindings,
slot_params = {
mousebindings = configuration.client_mousebindings
}
}
-- luacheck: ignore unused variable client_keybinding
local client_keybinding = slot {
id = 'CLIENT_KEY_BINDINGS',
action = slot.actions.CREATE | slot.actions.CONNECT,
target = capi.client,
signal = 'request::default_keybindings',
slot = slot.slots.client.append_keybindings,
slot_params = {
keybindings = configuration.client_keybindings
}
}
-- luacheck: ignore unused variable ruled_client
local ruled_client = slot {
id = 'RULED_CLIENT',
action = slot.actions.CREATE | slot.actions.CONNECT,
target = ruled.client,
signal = 'request::rules',
slot = slot.slots.ruled.append_client_rules,
slot_params = {
rules = configuration.rules.client
}
}
-- luacheck: ignore unused variable client_titlebar
local client_titlebar = slot {
id = 'CLIENT_TITLEBAR',
action = slot.actions.CREATE | slot.actions.CONNECT,
target = capi.client,
signal = 'request::titlebars',
slot = my_slots.build_client_titlebars
}
-- luacheck: ignore unused variable ruled_notification
local ruled_notification = slot {
id = 'RULED_NOTIFICATION',
action = slot.actions.CREATE | slot.actions.CONNECT,
target = ruled.notification,
signal = 'request::rules',
slot = slot.slots.ruled.append_notification_rules,
slot_params = {
rules = configuration.rules.notification
}
}
-- luacheck: ignore unused variable naughty_display
local naughty_display = slot {
id = 'NAUGHTY_DISPLAY',
action = slot.actions.CREATE | slot.actions.CONNECT,
target = naughty,
signal = 'request::display',
slot = my_slots.naughty_display
}
naughty.notify {
title = 'Aire-One dots',
message = 'You successfully ran the Aire-One default rc!'
}

80
slots/init.lua Normal file
View File

@ -0,0 +1,80 @@
local abutton = require 'awful.button'
local atag = require 'awful.tag'
local atitlebar = require 'awful.titlebar'
local lalign = require 'wibox.layout.align'
local lfixed = require 'wibox.layout.fixed'
local lflex = require 'wibox.layout.flex'
local naughty = require 'naughty'
-- You can require the configuration module to get access to other
-- configurations.
-- local configuration = require 'rc.configuration'
-- This would result in a depency loop as this file is part of the
-- configuration module.
--
-- If you need to access a configuration from the rc.configuration module,
-- you should add a direct require to the submodule here:
local configuration = {
tag_layouts = require 'rc.configuration.tag_layouts'
}
local slots = {}
function slots.create_tags (screen)
atag(
{ '1', '2', '3', '4', '5', '6', '7', '8', '9' },
screen,
configuration.tag_layouts)
end
function slots.build_desktop_decoration (screen)
local desktop_bar = require 'rc.ui.desktop_decoration.bar'
desktop_bar(screen)
end
function slots.build_client_titlebars (client)
-- Mouse buttons bindings for the titlebar
local buttons = {
abutton({}, 1,
function ()
client:activate { context = 'titlebar', action = 'mouse_move' }
end),
abutton({}, 3,
function ()
client:activate { context = 'titlebar', action = 'mouse_resize' }
end),
}
-- Titlebar UI
atitlebar(client).widget = {
{ -- Left
atitlebar.widget.iconwidget(client),
buttons = buttons,
layout = lfixed.horizontal
},
{ -- Middle
{ -- Title
align = 'center',
widget = atitlebar.widget.titlewidget(client)
},
buttons = buttons,
layout = lflex.horizontal
},
{ -- Right
atitlebar.widget.floatingbutton(client),
atitlebar.widget.maximizedbutton(client),
atitlebar.widget.stickybutton(client),
atitlebar.widget.ontopbutton(client),
atitlebar.widget.closebutton(client),
layout = lfixed.horizontal()
},
layout = lalign.horizontal
}
end
function slots.naughty_display (notification)
naughty.layout.box { notification = notification }
end
return slots

5
theme/init.lua Normal file
View File

@ -0,0 +1,5 @@
local theme = {}
theme.border_color_normal = '#0000ff'
return theme

View File

@ -0,0 +1,130 @@
local awibar = require 'awful.wibar'
local awful = require 'awful'
local beautiful = require 'beautiful'
local wibox = require 'wibox'
local mymainmenu = require 'rc.ui.menu.mymainmenu'
local capi = {
client = _G.client,
screen = _G.screen
}
local modkey = 'Mod4'
local bar = { _private = { instances = {} }, mt = {} }
local function get_screen_id(screen)
local s = capi.screen[screen] or screen
return s.index
end
-- Get the bar instance for a given screen
function bar:instance(screen)
local screen_id = get_screen_id(screen)
local instance = self._private.instances[screen_id]
if not instance then
instance = bar.new(screen)
self._private.instances[screen_id] = instance
end
return instance
end
function bar.new (screen)
local my_bar = {}
my_bar.wibar = awibar {
screen = screen,
position = 'top'
}
my_bar.launcher = awful.widget.launcher {
image = beautiful.awesome_icon,
menu = mymainmenu()
}
my_bar.keyboardlayout = awful.widget.keyboardlayout()
my_bar.textclock = wibox.widget.textclock()
my_bar.promptbox = awful.widget.prompt()
my_bar.layoutbox = awful.widget.layoutbox {
screen = screen,
buttons = {
awful.button({ }, 1, function () awful.layout.inc( 1) end),
awful.button({ }, 3, function () awful.layout.inc(-1) end),
awful.button({ }, 4, function () awful.layout.inc(-1) end),
awful.button({ }, 5, function () awful.layout.inc( 1) end),
}
}
my_bar.taglist = awful.widget.taglist {
screen = screen,
filter = awful.widget.taglist.filter.all,
buttons = {
awful.button({}, 1, function(tag)
tag:view_only()
end),
awful.button({ modkey }, 1, function(tag)
if capi.client.focus then
capi.client.focus:move_to_tag(tag)
end
end),
awful.button({}, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 3, function(tag)
if capi.client.focus then
capi.client.focus:toggle_tag(tag)
end
end),
awful.button({ }, 4, function(tag)
awful.tag.viewprev(tag.screen)
end),
awful.button({ }, 5, function(tag)
awful.tag.viewnext(tag.screen)
end)
}
}
my_bar.tasklist = awful.widget.tasklist {
screen = screen,
filter = awful.widget.tasklist.filter.currenttags,
buttons = {
awful.button({ }, 1, function (c)
c:activate { context = "tasklist", action = "toggle_minimization" }
end),
awful.button({ }, 3, function() awful.menu.client_list { theme = { width = 250 } } end),
awful.button({ }, 4, function() awful.client.focus.byidx(-1) end),
awful.button({ }, 5, function() awful.client.focus.byidx( 1) end),
}
}
my_bar.wibar:setup {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
my_bar.launcher,
my_bar.taglist,
my_bar.promptbox,
},
screen.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
my_bar.keyboardlayout,
wibox.widget.systray(),
my_bar.textclock,
my_bar.layoutbox,
}
}
return my_bar
end
function bar.mt:__call(...)
return self:instance(...)
end
return setmetatable(bar, bar.mt)

12
ui/hotkeys_popup/init.lua Normal file
View File

@ -0,0 +1,12 @@
local hotkeys_popup = require 'awful.hotkeys_popup'
-- luacheck: ignore unset variable keys
local keys = {
vim = require 'awful.hotkeys_popup.keys.vim',
firefox = require 'awful.hotkeys_popup.keys.firefox',
tmux = require 'awful.hotkeys_popup.keys.tmux',
qutebrowser = require 'awful.hotkeys_popup.keys.qutebrowser',
termite = require 'awful.hotkeys_popup.keys.termite'
}
return hotkeys_popup

32
ui/menu/mymainmenu.lua Normal file
View File

@ -0,0 +1,32 @@
local amenu = require 'awful.menu'
local configuration = {
menu = require 'rc.configuration.menu'
}
local mymainmenu = { _private = {}, mt = {} }
function mymainmenu:instance()
local instance = self._private.instance
if not instance then
instance = mymainmenu.new()
self._private.instance = instance
end
return instance
end
function mymainmenu.new ()
local menu = amenu {
items = configuration.menu.mymainmenu
}
return menu
end
function mymainmenu.mt:__call()
return self:instance()
end
return setmetatable(mymainmenu, mymainmenu.mt)