Tooling and conf for a proper developement environment on VSCode(ium) #1

Merged
Aire-One merged 8 commits from tooling/vscode into master 2021-11-29 19:37:38 +01:00
37 changed files with 694 additions and 512 deletions

12
.editorconfig Normal file
View File

@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

33
.luacheckrc Normal file
View File

@ -0,0 +1,33 @@
-- Only allow symbols available in all Lua versions
std = "min"
-- Get rid of "unused argument self"-warnings
self = false
-- Global objects defined by the C code
read_globals = {
"awesome",
"button",
"dbus",
"drawable",
"drawin",
"key",
"keygrabber",
"mousegrabber",
"selection",
"tag",
"window",
"table.unpack",
"math.atan2",
}
-- screen may not be read-only, because newer luacheck versions complain about
-- screen[1].tags[1].selected = true.
-- The same happens with the following code:
-- local tags = mouse.screen.tags
-- tags[7].index = 4
-- client may not be read-only due to client.focus.
globals = { "screen", "mouse", "root", "client" }
-- Enable cache (uses .luacheckcache relative to this rc file).
cache = true

9
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,9 @@
{
"recommendations": [
"editorconfig.editorconfig",
"tomblind.local-lua-debugger-vscode",
"sumneko.lua",
"johnnymorganz.stylua",
"dwenegar.vscode-luacheck"
]
}

19
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,19 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "lua-local",
"request": "launch",
"name": "Debug with Xephyr",
"program": {
"command": "${workspaceFolder}/start-xephyr.sh"
},
"args": [
"/usr/bin/Xephyr",
"/usr/bin/awesome",
"${workspaceFolder}/init.lua"
],
"postDebugTask": "Terminate All Tasks"
}
]
}

9
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,9 @@
{
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"[markdown]": {
"editor.wordWrap": "on",
"editor.renderWhitespace": "all",
"editor.acceptSuggestionOnEnter": "off"
}
}

19
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,19 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Terminate All Tasks",
"command": "${workspaceFolder}/start-xephyr.sh stop",
"type": "shell",
"problemMatcher": []
}
],
"inputs": [
{
"id": "terminate",
"type": "command",
"command": "workbench.action.tasks.terminate",
"args": "terminateAll"
}
]
}

View File

@ -1,22 +1,21 @@
local applications = {}
applications.terminal = 'kitty'
applications.editor = os.getenv('EDITOR') or 'vim'
applications.terminal = "kitty"
applications.editor = os.getenv "EDITOR" or "vim"
applications.browser = 'firefox-nightly'
applications.web = 'qutebrowser'
applications.browser = "firefox-nightly"
applications.web = "qutebrowser"
applications.open_terminal = function ()
return applications.terminal .. ' -e tmux'
applications.open_terminal = function()
return applications.terminal .. " -e tmux"
end
applications.open_editor = function (file)
return applications.terminal
.. ' -e ' .. applications.editor .. ' ' .. file
applications.open_editor = function(file)
return applications.terminal .. " -e " .. applications.editor .. " " .. file
end
applications.open_man = function (file)
return applications.terminal .. ' -e man ' .. file
applications.open_man = function(file)
return applications.terminal .. " -e man " .. file
end
return applications

View File

@ -1,65 +1,50 @@
local akey = require 'awful.key'
local aclient = require 'awful.client'
local akey = require "awful.key"
local aclient = require "awful.client"
local control = 'Control'
local modkey = 'Mod4'
local shift = 'Shift'
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',
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' })
{ 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

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

View File

@ -1,163 +1,175 @@
local aclient = require 'awful.client'
local akey = require 'awful.key'
local aprompt = require 'awful.prompt'
local ascreen = require 'awful.screen'
local aspawn = require 'awful.spawn'
local atag = require 'awful.tag'
local autil = require 'awful.util'
local aclient = require "awful.client"
local akey = require "awful.key"
local aprompt = require "awful.prompt"
local ascreen = require "awful.screen"
local aspawn = require "awful.spawn"
local atag = require "awful.tag"
local autil = require "awful.util"
local menubar = require 'menubar'
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 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 = _G.awesome,
client = _G.client
client = _G.client,
}
local control = 'Control'
local modkey = 'Mod4'
local shift = 'Shift'
local control = "Control"
local modkey = "Mod4"
local shift = "Shift"
local global_keybindings = {
akey({ modkey }, 's',
function ()
hotkeys_popup.show_help()
end,
{ description = 'show help', group = 'awesome' }),
akey({ modkey }, 'w',
function ()
mymainmenu():show()
end,
{ description = 'show main menu', group = 'awesome' }),
akey({ modkey, control }, 'r',
akey({ modkey }, "s", function()
hotkeys_popup.show_help()
end, {
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',
{ 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.open_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' }),
{ 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.open_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",
}),
-- Client focus
akey {
modifiers = { modkey },
key = 'j',
group = 'client',
description = 'Focus next client by index',
on_press = function ()
key = "j",
group = "client",
description = "Focus next client by index",
on_press = function()
aclient.focus.byidx(1)
end
end,
},
akey {
modifiers = { modkey },
key = 'k',
group = 'client',
description = 'Focus previous by index',
on_press = function ()
key = "k",
group = "client",
description = "Focus previous by index",
on_press = function()
aclient.focus.byidx(-1)
end
end,
},
-- Layout manipulation
akey {
modifiers = { modkey, shift },
key = 'j',
group = 'client',
description = 'Swap with next client',
on_press = function ()
key = "j",
group = "client",
description = "Swap with next client",
on_press = function()
aclient.swap.byidx(1)
end
end,
},
akey {
modifiers = { modkey, shift },
key = 'k',
group = 'client',
description = 'Swap with previous client',
on_press = function ()
key = "k",
group = "client",
description = "Swap with previous client",
on_press = function()
aclient.swap.byidx(-1)
end
end,
},
akey {
modifiers = { modkey, shift },
key = 'Right',
description = 'Increase master width factor',
group = 'client',
on_press = function ()
key = "Right",
description = "Increase master width factor",
group = "client",
on_press = function()
atag.incmwfact(0.01)
end
end,
},
akey {
modifiers = { modkey, shift },
key = 'Left',
description = 'Decrease master width factor',
group = 'client',
on_press = function ()
key = "Left",
description = "Decrease master width factor",
group = "client",
on_press = function()
atag.incmwfact(-0.01)
end
end,
},
-- Tags manipulation
akey {
modifiers = { modkey },
keygroup = akey.keygroup.NUMROW,
description = 'only view tag',
group = 'tag',
on_press = function (index)
description = "only view tag",
group = "tag",
on_press = function(index)
local screen = ascreen.focused()
local tag = screen.tags[index]
if tag then
tag:view_only()
end
end
end,
},
akey {
modifiers = { modkey, control },
keygroup = akey.keygroup.NUMROW,
description = 'toggle tag',
group = 'tag',
on_press = function (index)
description = "toggle tag",
group = "tag",
on_press = function(index)
local screen = ascreen.focused()
local tag = screen.tags[index]
if tag then
atag.viewtoggle(tag)
end
end
end,
},
akey {
modifiers = { modkey, shift },
keygroup = akey.keygroup.NUMROW,
description = 'move focused client to tag',
group = 'tag',
on_press = function (index)
description = "move focused client to tag",
group = "tag",
on_press = function(index)
local screen = ascreen.focused()
local client = capi.client.focus
local tag = screen.tags[index]
@ -165,8 +177,8 @@ local global_keybindings = {
if client and tag then
client:move_to_tag(tag)
end
end
}
end,
},
}
return global_keybindings

View File

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

View File

@ -1,19 +1,23 @@
local rc_configuration = {}
rc_configuration.applications = require 'rc.configuration.applications'
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.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.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.menu = require "rc.configuration.menu"
rc_configuration.rules = require 'rc.configuration.rules'
rc_configuration.rules = require "rc.configuration.rules"
rc_configuration.prompt_commands = require 'rc.configuration.prompt_commands'
rc_configuration.prompt_commands = require "rc.configuration.prompt_commands"
rc_configuration.tag_layouts = require 'rc.configuration.tag_layouts'
rc_configuration.tag_layouts = require "rc.configuration.tag_layouts"
return rc_configuration

View File

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

View File

@ -1,16 +1,21 @@
local applications = require 'rc.configuration.applications'
local hotkeys_popup = require 'rc.ui.hotkeys_popup'
local applications = require "rc.configuration.applications"
local hotkeys_popup = require "rc.ui.hotkeys_popup"
local capi = {
awesome = _G.awesome
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 }
{
"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

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

View File

@ -1,21 +1,21 @@
local atag = require 'awful.tag'
local layout_suit = require 'awful.layout.suit'
local atag = require "awful.tag"
local layout_suit = require "awful.layout.suit"
local commands = {}
commands['o'] = {
callback = function (parameters)
local tag_name = parameters[1] or 'New-Tag'
commands["o"] = {
callback = function(parameters)
local tag_name = parameters[1] or "New-Tag"
atag.add(tag_name, {
layout = layout_suit.tile
layout = layout_suit.tile,
}):view_only()
end
end,
}
commands['O'] = {
callback = function (parameters)
local aspawn = require 'awful.spawn'
commands["O"] = {
callback = function(parameters)
local aspawn = require "awful.spawn"
local application = parameters[1]
local tag_name = parameters[2] or application
@ -26,25 +26,25 @@ commands['O'] = {
})
t:view_only()
aspawn(application, { tag = t })
end
end,
}
commands['q'] = {
callback = function ()
local ascreen = require 'awful.screen'
commands["q"] = {
callback = function()
local ascreen = require "awful.screen"
local tags = ascreen.focused().selected_tags
for _,tag in ipairs(tags) do
for _, tag in ipairs(tags) do
tag.volatile = true
for _,client in ipairs(tag:clients()) do
for _, client in ipairs(tag:clients()) do
client:kill()
end
tag:delete()
end
end
end,
}
return commands

View File

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

View File

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

View File

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

View File

@ -1,8 +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.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

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
local alayout = require 'awful.layout'
local alayout = require "awful.layout"
local tag_layouts = {
alayout.suit.floating,
@ -13,7 +13,7 @@ local tag_layouts = {
alayout.suit.max,
alayout.suit.max.fullscreen,
alayout.suit.magnifier,
alayout.suit.corner.nw
alayout.suit.corner.nw,
}
return tag_layouts

122
init.lua
View File

@ -1,149 +1,153 @@
-- awesome_mode: api-level=4:screen=on
if os.getenv "LOCAL_LUA_DEBUGGER_VSCODE" == "1" then
require("lldebugger").start()
end
-- 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')
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'
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
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'
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'
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 ()
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,
id = "LOAD_WALLPAPER",
connect = true,
target = capi.screen,
signal = 'request::wallpaper',
slot = my_slots.wallpaper
signal = "request::wallpaper",
slot = my_slots.wallpaper,
}
-- luacheck: ignore unused variable default_layout
local default_layout = slot {
id = 'DEFAULT_LAYOUTS',
action = slot.actions.CREATE | slot.actions.CONNECT,
id = "DEFAULT_LAYOUTS",
connect = true,
target = capi.tag,
signal = 'request::default_layouts',
signal = "request::default_layouts",
slot = slot.slots.tag.default_layouts,
slot_params = {
layouts = configuration.tag_layouts
}
layouts = configuration.tag_layouts,
},
}
-- luacheck: ignore unused variable create_tag
local create_tag = slot {
id = 'CREATE_TAGS',
action = slot.actions.CREATE | slot.actions.CONNECT,
id = "CREATE_TAGS",
connect = true,
target = capi.screen,
signal = 'request::desktop_decoration',
slot = my_slots.create_tags
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,
id = "DESKTOP_DECORATION",
connect = true,
target = capi.screen,
signal = 'request::desktop_decoration',
slot = my_slots.build_desktop_decoration
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,
id = "CLIENT_MOUSE_BINDINGS",
connect = true,
target = capi.client,
signal = 'request::default_mousebindings',
signal = "request::default_mousebindings",
slot = slot.slots.client.append_mousebindings,
slot_params = {
mousebindings = configuration.client_mousebindings
}
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,
id = "CLIENT_KEY_BINDINGS",
connect = true,
target = capi.client,
signal = 'request::default_keybindings',
signal = "request::default_keybindings",
slot = slot.slots.client.append_keybindings,
slot_params = {
keybindings = configuration.client_keybindings
}
keybindings = configuration.client_keybindings,
},
}
-- luacheck: ignore unused variable ruled_client
local ruled_client = slot {
id = 'RULED_CLIENT',
action = slot.actions.CREATE | slot.actions.CONNECT,
id = "RULED_CLIENT",
connect = true,
target = ruled.client,
signal = 'request::rules',
signal = "request::rules",
slot = slot.slots.ruled.append_client_rules,
slot_params = {
rules = configuration.rules.client
}
rules = configuration.rules.client,
},
}
-- luacheck: ignore unused variable client_titlebar
local client_titlebar = slot {
id = 'CLIENT_TITLEBAR',
action = slot.actions.CREATE | slot.actions.CONNECT,
id = "CLIENT_TITLEBAR",
connect = true,
target = capi.client,
signal = 'request::titlebars',
slot = my_slots.build_client_titlebars
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,
id = "RULED_NOTIFICATION",
connect = true,
target = ruled.notification,
signal = 'request::rules',
signal = "request::rules",
slot = slot.slots.ruled.append_notification_rules,
slot_params = {
rules = configuration.rules.notification
}
rules = configuration.rules.notification,
},
}
-- luacheck: ignore unused variable naughty_display
local naughty_display = slot {
id = 'NAUGHTY_DISPLAY',
action = slot.actions.CREATE | slot.actions.CONNECT,
id = "NAUGHTY_DISPLAY",
connect = true,
target = naughty,
signal = 'request::display',
slot = my_slots.naughty_display
signal = "request::display",
slot = my_slots.naughty_display,
}
naughty.notify {
title = 'Aire-One dots',
message = 'You successfully ran the Aire-One default rc!'
title = "Aire-One dots",
message = "You successfully ran the Aire-One default rc!",
}

View File

@ -1,23 +1,27 @@
local abutton = require 'awful.button'
local atitlebar = require 'awful.titlebar'
local beautiful = require 'beautiful'
local lalign = require 'wibox.layout.align'
local lfixed = require 'wibox.layout.fixed'
local lflex = require 'wibox.layout.flex'
local naughty = require 'naughty'
local abutton = require "awful.button"
local atitlebar = require "awful.titlebar"
local beautiful = require "beautiful"
local lalign = require "wibox.layout.align"
local lfixed = require "wibox.layout.fixed"
local lflex = require "wibox.layout.flex"
local naughty = require "naughty"
local slots = {}
function slots.wallpaper(screen)
local awallpaper = require 'awful.wallpaper'
local beautiful = require 'beautiful'
local gcolor = require 'gears.color'
local gsurface = require 'gears.surface'
local imagebox = require 'wibox.widget.imagebox'
local cairo = require('lgi').cairo
local awallpaper = require "awful.wallpaper"
local beautiful = require "beautiful"
local gcolor = require "gears.color"
local gsurface = require "gears.surface"
local imagebox = require "wibox.widget.imagebox"
local cairo = require("lgi").cairo
local screen_geo = screen.geometry
local source = cairo.ImageSurface(cairo.Format.RGB32, screen_geo.width, screen_geo.height)
local source = cairo.ImageSurface(
cairo.Format.RGB32,
screen_geo.width,
screen_geo.height
)
local cr = cairo.Context(source)
-- Load base image
@ -32,8 +36,8 @@ function slots.wallpaper(screen)
from = { 0, 0 },
to = { screen.width, screen.height },
stops = {
{ 0, '#26323840' }
}
{ 0, "#26323840" },
},
}
cr:set_source(color_pattern)
cr:paint()
@ -43,41 +47,39 @@ function slots.wallpaper(screen)
widget = {
image = source,
widget = imagebox,
}
},
}
end
function slots.create_tags (screen)
local atag = require 'awful.tag'
local home_layout = require 'MyTagLayout.home_layout'
function slots.create_tags(screen)
local atag = require "awful.tag"
local home_layout = require "MyTagLayout.home_layout"
local first_tag = atag.add('home', {
local first_tag = atag.add("home", {
screen = screen,
icon = beautiful.icon_hometag,
layout = home_layout,
master_width_factor = beautiful.hometag_master_width_factor
master_width_factor = beautiful.hometag_master_width_factor,
})
first_tag:view_only()
end
function slots.build_desktop_decoration (screen)
local desktop_bar = require 'rc.ui.desktop_decoration.bar'
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)
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),
abutton({}, 1, function()
client:activate { context = "titlebar", action = "mouse_move" }
end),
abutton({}, 3, function()
client:activate { context = "titlebar", action = "mouse_resize" }
end),
}
-- Titlebar UI
@ -85,15 +87,15 @@ function slots.build_client_titlebars (client)
{ -- Left
atitlebar.widget.iconwidget(client),
buttons = buttons,
layout = lfixed.horizontal
layout = lfixed.horizontal,
},
{ -- Middle
{ -- Title
align = 'center',
widget = atitlebar.widget.titlewidget(client)
align = "center",
widget = atitlebar.widget.titlewidget(client),
},
buttons = buttons,
layout = lflex.horizontal
layout = lflex.horizontal,
},
{ -- Right
atitlebar.widget.floatingbutton(client),
@ -101,13 +103,13 @@ function slots.build_client_titlebars (client)
atitlebar.widget.stickybutton(client),
atitlebar.widget.ontopbutton(client),
atitlebar.widget.closebutton(client),
layout = lfixed.horizontal()
layout = lfixed.horizontal(),
},
layout = lalign.horizontal
layout = lalign.horizontal,
}
end
function slots.naughty_display (notification)
function slots.naughty_display(notification)
naughty.layout.box { notification = notification }
end

33
start-xephyr.sh Executable file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env sh
killXephyr() {
kill "$(pgrep Xephyr)" >/dev/null 2>&1
}
trap killXephyr EXIT
if [ "$1" = "stop" ]; then
killXephyr
exit 0
fi;
xephyr=$1
awesome=$2
rc_file=$3
# Check for the first free display
for i in $(seq 1 10); do
if [ ! -f "/tmp/.X${i}-lock" ]; then
D=$i;
break;
fi;
done
# Start Xephyr
$xephyr :"$D" -name xephyr_"$D" -ac -br -noreset -screen 1600x900 >/dev/null 2>&1 &
sleep 1
# Start Awesome
DISPLAY=:$D.0 $awesome \
--config "$rc_file"

6
stylua.toml Normal file
View File

@ -0,0 +1,6 @@
column_width = 80
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 4
quote_style = "AutoPreferDouble"
no_call_parentheses = true

View File

@ -1,22 +1,22 @@
local gfs = require 'gears.filesystem'
local gfs = require "gears.filesystem"
local config_dir = gfs.get_configuration_dir()
local theme_dir = config_dir .. 'theme/'
local assets_dir = theme_dir .. 'assets/'
local icons_dir = assets_dir .. 'icons/'
local theme_dir = config_dir .. "theme/"
local assets_dir = theme_dir .. "assets/"
local icons_dir = assets_dir .. "icons/"
local theme = {}
--- Basic
theme.font = 'Noto Mono 9'
theme.font = "Noto Mono 9"
--- Tags
theme.hometag_master_width_factor = 0.65
--- Icons
theme.icon_hometag = icons_dir .. 'home-circle.svg'
theme.icon_apps = icons_dir .. 'apps.svg'
theme.icon_battery_outline = icons_dir .. 'battery-outline.svg'
theme.icon_hometag = icons_dir .. "home-circle.svg"
theme.icon_apps = icons_dir .. "apps.svg"
theme.icon_battery_outline = icons_dir .. "battery-outline.svg"
--- Wibar
-- My wibar is a transparent dock at the bottom of the screen.
@ -26,9 +26,9 @@ theme.wibar_stretch = false
theme.wibar_border_width = 0
theme.wibar_border_color = nil
theme.wibar_ontop = false
theme.wibar_opacity = 1
theme.wibar_type = 'dock'
theme.wibar_bg = '#0000'
theme.wibar_opacity = 1
theme.wibar_type = "dock"
theme.wibar_bg = "#0000"
--- Spacing and margins
-- Naming convention:
@ -38,7 +38,7 @@ theme.margin = 4
theme.padding = 4
theme.bar_height = 32 + (theme.margin * 2) -- This is the outer size of the bar
theme.bar_width = '80%' -- Make the bar size relative to the screen
theme.bar_width = "80%" -- Make the bar size relative to the screen
theme.bar_margin_x = theme.margin * 2
theme.bar_margin_y = theme.margin
theme.bar_padding_x = theme.padding * 2
@ -51,10 +51,10 @@ theme.bar_box_padding_y = theme.padding
theme.bar_box_spacing = theme.spacing
--- Widgets specific
theme.bg_systray = '#455A64'
theme.bg_systray = "#455A64"
theme.systray_icon_spacing = 3
--- Wallpaper
theme.wallpaper = assets_dir .. 'wallpapers/pizza.jpg'
theme.wallpaper = assets_dir .. "wallpapers/pizza.jpg"
return theme

View File

@ -1,37 +1,37 @@
local awibar = require 'awful.wibar'
local awful = require 'awful'
local battery_widget = require 'battery-widget'
local beautiful = require 'beautiful'
local awibar = require "awful.wibar"
local awful = require "awful"
local battery_widget = require "battery-widget"
local beautiful = require "beautiful"
local container_background = require 'wibox.container.background'
local container_margin = require 'wibox.container.margin'
local container_place = require 'wibox.container.place'
local container_background = require "wibox.container.background"
local container_margin = require "wibox.container.margin"
local container_place = require "wibox.container.place"
local gshape = require 'gears.shape'
local gshape = require "gears.shape"
local layout_align = require 'wibox.layout.align'
local layout_fixed = require 'wibox.layout.fixed'
local layout_align = require "wibox.layout.align"
local layout_fixed = require "wibox.layout.fixed"
local systray = require 'wibox.widget.systray'
local textclock = require 'wibox.widget.textclock'
local widget = require 'wibox.widget'
local systray = require "wibox.widget.systray"
local textclock = require "wibox.widget.textclock"
local widget = require "wibox.widget"
local mycommands = require 'rc.configuration.prompt_commands'
local mymainmenu = require 'rc.ui.menu.mymainmenu'
local mytaglist = require 'MyTagListWidget'
local mycommands = require "rc.configuration.prompt_commands"
local mymainmenu = require "rc.ui.menu.mymainmenu"
local mytaglist = require "MyTagListWidget"
local bar_widgets = require 'rc.ui.desktop_decoration.bar.widgets'
local bar_widgets = require "rc.ui.desktop_decoration.bar.widgets"
local mybattery = bar_widgets.battery
local myprompt = bar_widgets.prompt
local capi = {
screen = _G.screen
screen = _G.screen,
}
local abs = math.abs
local dpi = beautiful.xresources.apply_dpi
local function get_screen_id (screen)
local function get_screen_id(screen)
local s = capi.screen[screen or 1]
return s.index
@ -46,13 +46,13 @@ end
-- @tparam[opt] args.bg The box's background.
-- @tpram[opt] args.fg The box's foreground (used mainly for textbox text color).
-- @treturn wibox.container.background The builded widget.
local function build_widget (args)
local function build_widget(args)
local screen_id = get_screen_id(args.screen)
-- Callback for the shape function.
-- If the widget is almost a square: draw a circle. Otherwise, draw a
-- rounded_bar.
local shape_callback = function (cr, width, height)
local shape_callback = function(cr, width, height)
local shape = gshape.circle
-- 10 is an arbitrary value I found after some tests :shrug:
@ -64,10 +64,6 @@ local function build_widget (args)
end
local box_widget = widget {
widget = container_background,
shape = shape_callback,
bg = args.bg,
fg = args.fg,
{
widget = container_margin,
draw_empty = false,
@ -75,8 +71,12 @@ local function build_widget (args)
bottom = dpi(beautiful.bar_box_padding_y, screen_id),
right = dpi(beautiful.bar_box_padding_x, screen_id),
left = dpi(beautiful.bar_box_padding_x, screen_id),
args.widget
}
args.widget,
},
bg = args.bg,
fg = args.fg,
shape = shape_callback,
widget = container_background,
}
return box_widget
@ -90,7 +90,7 @@ bar.widgets = bar_widgets
-- If no instance was found, we build a new one.
-- @tparam screen screen|integer The bar's screen.
-- @treturn wibox.wibar
function bar:instance (screen)
function bar:instance(screen)
local screen_id = get_screen_id(screen)
local instance = self._private.instances[screen_id]
@ -102,138 +102,145 @@ function bar:instance (screen)
return instance
end
function bar.new (screen)
function bar.new(screen)
local my_bar = {}
my_bar.launcher = build_widget {
screen = screen,
bg = '#2196F3',
bg = "#2196F3",
widget = awful.widget.launcher {
image = beautiful.icon_apps,
menu = mymainmenu()
}
menu = mymainmenu(),
},
}
my_bar.textclock = build_widget {
bg = '#FF5722',
fg = '#ECEFF1',
widget = textclock('%l:%M %p')
screen = screen,
bg = "#FF5722",
fg = "#ECEFF1",
widget = textclock "%l:%M %p",
}
my_bar.promptbox = myprompt {
commands = mycommands
commands = mycommands,
}
-- This widget needs to be reworded and integrated inside the project.
my_bar.taglist = mytaglist.new {
screen = screen
screen = screen,
}
my_bar.battery = build_widget {
screen = screen,
bg = '#673AB7',
bg = "#673AB7",
widget = mybattery {
screen = screen,
device_path = battery_widget.get_BAT0_device_path(),
color = '#ECEFF1'
}
color = "#ECEFF1",
},
}
my_bar.systray = build_widget {
screen = screen,
bg = '#455A64',
widget = systray()
bg = "#455A64",
widget = systray(),
}
my_bar.wibar = awibar {
screen = screen,
position = 'bottom',
position = "bottom",
height = dpi(beautiful.bar_height, screen),
width = beautiful.bar_width -- Width is a percentage of the screen size
width = beautiful.bar_width, -- Width is a percentage of the screen size
}
my_bar.wibar:setup {
-- Bar margins
widget = container_margin,
top = dpi(beautiful.bar_margin_y, screen),
bottom = dpi(beautiful.bar_margin_y, screen),
right = dpi(beautiful.bar_margin_x, screen),
left = dpi(beautiful.bar_margin_x, screen),
{
-- Physical bar
widget = container_background,
bg = '#263238D9',
shape = function (cr, width, height)
gshape.rounded_rect(cr, width, height, 10)
end,
{
-- Bar paddings
widget = container_margin,
top = dpi(beautiful.bar_padding_y, screen),
bottom = dpi(beautiful.bar_padding_y, screen),
right = dpi(beautiful.bar_padding_x, screen),
left = dpi(beautiful.bar_padding_x, screen),
{
-- Bar content
layout = layout_align.horizontal,
expand = 'outside',
{
-- Left side of the bar, align on the left
widget = container_place,
halign = "left",
{
-- box margins
widget = container_margin,
{
-- Left widget boxes
my_bar.launcher,
my_bar.promptbox,
spacing = dpi(
beautiful.bar_box_spacing,
screen
),
layout = layout_fixed.horizontal,
},
top = dpi(beautiful.bar_box_margin_y, screen),
bottom = dpi(beautiful.bar_box_margin_y, screen),
right = dpi(beautiful.bar_box_margin_x, screen),
left = dpi(beautiful.bar_box_margin_x, screen),
{
-- Left widget boxes
layout = layout_fixed.horizontal,
spacing = dpi(beautiful.bar_box_spacing, screen),
my_bar.launcher,
my_bar.promptbox
}
}
widget = container_margin,
},
halign = "left",
widget = container_place,
},
expand = "outside",
layout = layout_align.horizontal,
-- Middle widget is the custom taglist
-- it doesn't need box/margins/...
{
my_bar.taglist,
widget = container_place,
my_bar.taglist
},
{
-- Right side of the bar, align on the right
widget = container_place,
halign = "right",
{
-- box margins
widget = container_margin,
{
-- Right widget boxes
my_bar.systray,
my_bar.battery,
my_bar.textclock,
spacing = dpi(
beautiful.bar_box_spacing,
screen
),
layout = layout_fixed.horizontal,
},
top = dpi(beautiful.bar_box_margin_y, screen),
bottom = dpi(beautiful.bar_box_margin_y, screen),
right = dpi(beautiful.bar_box_margin_x, screen),
left = dpi(beautiful.bar_box_margin_x, screen),
{
-- Right widget boxes
layout = layout_fixed.horizontal,
spacing = dpi(beautiful.bar_box_spacing, screen),
my_bar.systray,
my_bar.battery,
my_bar.textclock
}
}
}
}
}
}
widget = container_margin,
},
halign = "right",
widget = container_place,
},
},
top = dpi(beautiful.bar_padding_y, screen),
bottom = dpi(beautiful.bar_padding_y, screen),
right = dpi(beautiful.bar_padding_x, screen),
left = dpi(beautiful.bar_padding_x, screen),
widget = container_margin,
},
bg = "#263238D9",
shape = function(cr, width, height)
gshape.rounded_rect(cr, width, height, 10)
end,
widget = container_background,
},
top = dpi(beautiful.bar_margin_y, screen),
bottom = dpi(beautiful.bar_margin_y, screen),
right = dpi(beautiful.bar_margin_x, screen),
left = dpi(beautiful.bar_margin_x, screen),
widget = container_margin,
}
return my_bar
end
function bar.mt:__call (...)
function bar.mt:__call(...)
return self:instance(...)
end

View File

@ -8,16 +8,16 @@
-- @author Aire-One
-- @copyright 2020 Aire-One
---------------------------------------------------------------------------
local lgi = require 'lgi'
local lgi = require "lgi"
local cairo = lgi.cairo
local rsvg = lgi.Rsvg
local atooltip = require 'awful.tooltip'
local beautiful = require 'beautiful'
local gcolor = require 'gears.color'
local imagebox = require 'wibox.widget.imagebox'
local atooltip = require "awful.tooltip"
local beautiful = require "beautiful"
local gcolor = require "gears.color"
local imagebox = require "wibox.widget.imagebox"
local battery_widget = require 'battery-widget'
local battery_widget = require "battery-widget"
local my_battery = {}
local mt = {}
@ -26,9 +26,11 @@ local mt = {}
-- @tparam number percentage The percentage of battery remaining.
-- @tparam gears.color|string color The color of the drawing.
-- @treturn cairo.ImageSurface The generated surface for the drawing.
function my_battery.draw_battery (percentage, color)
function my_battery.draw_battery(percentage, color)
local svg_handle = rsvg.Handle.new_from_file(beautiful.icon_battery_outline)
if not svg_handle then return end
if not svg_handle then
return
end
local surface = cairo.ImageSurface.create(cairo.Format.ARGB32, 24, 24)
local cr = cairo.Context(surface)
svg_handle:render_cairo(cr)
@ -50,13 +52,13 @@ end
-- by the signal system on battery update.
-- @tparam my_battery widget The battery widget to update.
-- @tparam UPowerGLib.Device device The UPower device to monitor.
function my_battery.update (widget, device)
function my_battery.update(widget, device)
widget.image = my_battery.draw_battery(device.percentage, widget.color)
end
--- Give the widget template for the battery widget.
-- (It's a basic `wibox.widget.imagebox` for my battery implementation)
function my_battery.widget_template ()
function my_battery.widget_template()
local widget = imagebox()
widget.resize = true
@ -69,31 +71,31 @@ end
-- @tparam string args.device_path The path of the UPower device to monitor.
-- @tparam gears.color|string args.color Color to use to draw the battery.
-- @treturn my_battery The instantiated widget.
function my_battery.new (args)
function my_battery.new(args)
local widget = battery_widget {
screen = args.screen,
device_path = args.device_path,
widget_template = my_battery.widget_template(),
instant_update = true
instant_update = true,
}
widget.color = args.color
widget:connect_signal('upower::update', function (w, device)
widget:connect_signal("upower::update", function(w, device)
my_battery.update(w, device)
end)
widget.tooltip = atooltip {
objects = { widget },
timer_function = function ()
return string.format('%3d', widget.device.percentage) .. '%'
end
timer_function = function()
return string.format("%3d", widget.device.percentage) .. "%"
end,
}
return widget
end
function mt.__call (self, ...)
function mt:__call(...)
return my_battery.new(...)
end

View File

@ -1,6 +1,6 @@
local bar_widgets = {}
bar_widgets.battery = require 'rc.ui.desktop_decoration.bar.widgets.battery'
bar_widgets.prompt = require 'rc.ui.desktop_decoration.bar.widgets.prompt'
bar_widgets.battery = require "rc.ui.desktop_decoration.bar.widgets.battery"
bar_widgets.prompt = require "rc.ui.desktop_decoration.bar.widgets.prompt"
return bar_widgets

View File

@ -1,18 +1,26 @@
local acompletion = require 'awful.completion'
local aspawn = require 'awful.spawn'
local gstring = require 'gears.string'
local gtable = require 'gears.table'
local prompt = require 'awful.widget.prompt'
local acompletion = require "awful.completion"
local aspawn = require "awful.spawn"
local gstring = require "gears.string"
local gtable = require "gears.table"
local prompt = require "awful.widget.prompt"
local string = string
local function completion_cb (self, command_before_comp, cur_pos_before_comp, ncomp)
local function completion_cb(
self,
command_before_comp,
cur_pos_before_comp,
ncomp
)
return acompletion.generic(
command_before_comp, cur_pos_before_comp, ncomp,
self.completion_keywords)
command_before_comp,
cur_pos_before_comp,
ncomp,
self.completion_keywords
)
end
local function exe_cb (self, input)
local function exe_cb(self, input)
-- Exit if the input is empty
if not input or #input == 0 then
return
@ -22,15 +30,15 @@ local function exe_cb (self, input)
input = string.gsub(input, "^%s*(.-)%s*$", "%1")
-- If the input is not a VI command, spawn it
if input:sub(1,1) ~= ':' then
if input:sub(1, 1) ~= ":" then
aspawn(input)
return
end
-- Parse the custom command
local command, parameters = input:gmatch(':([%w-]+)%s*(.*)')()
command = command:sub(1,1)
parameters = gstring.split(parameters, '%s')
local command, parameters = input:gmatch ":([%w-]+)%s*(.*)"()
command = command:sub(1, 1)
parameters = gstring.split(parameters, "%s")
-- Quit if the command doesn't exist
if not self.commands[command] then
@ -43,24 +51,31 @@ end
local my_prompt = { mt = {} }
function my_prompt.new (args)
function my_prompt.new(args)
local prompt_widget = nil
prompt_widget = prompt {
prompt = '<b></b> ', -- needs the 3 spaces
completion_callback = function (...) return completion_cb(prompt_widget, ...) end,
exe_callback = function (...) return exe_cb(prompt_widget, ...) end
prompt = "<b></b> ", -- needs the 3 spaces
completion_callback = function(...)
return completion_cb(prompt_widget, ...)
end,
exe_callback = function(...)
return exe_cb(prompt_widget, ...)
end,
}
prompt_widget.commands = args.commands
prompt_widget.completion_keywords = gtable.join(
-- TODO: find applications list
gtable.find_keys(args.commands, function () return true end, false),
args.completion_keywords or {})
gtable.find_keys(args.commands, function()
return true
end, false),
args.completion_keywords or {}
)
return prompt_widget
end
function my_prompt.mt.__call (self, ...)
function my_prompt.mt:__call(...)
return my_prompt.new(...)
end

View File

@ -1,5 +1,5 @@
local desktop_decoration = {}
desktop_decoration.bar = require 'rc.ui.desktop_decoration.bar'
desktop_decoration.bar = require "rc.ui.desktop_decoration.bar"
return desktop_decoration

View File

@ -1,12 +1,12 @@
local hotkeys_popup = require 'awful.hotkeys_popup'
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'
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

View File

@ -1,7 +1,7 @@
local amenu = require 'awful.menu'
local amenu = require "awful.menu"
local configuration = {
menu = require 'rc.configuration.menu'
menu = require "rc.configuration.menu",
}
local mymainmenu = { _private = {}, mt = {} }
@ -17,9 +17,9 @@ function mymainmenu:instance()
return instance
end
function mymainmenu.new ()
function mymainmenu.new()
local menu = amenu {
items = configuration.menu.mymainmenu
items = configuration.menu.mymainmenu,
}
return menu