From 57724c340d44f7f2e9575b14af4f34cb57a224f4 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Mon, 4 Oct 2021 20:32:34 +0200 Subject: [PATCH 1/8] add(debug) lld debugger with Xephyr --- .vscode/launch.json | 21 +++++++++++++++++++++ init.lua | 4 ++++ start-xephyr.sh | 21 +++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 .vscode/launch.json create mode 100755 start-xephyr.sh diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..35e23f8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "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", + ] + } + ] +} \ No newline at end of file diff --git a/init.lua b/init.lua index 8ade968..26a3366 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,9 @@ -- 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') diff --git a/start-xephyr.sh b/start-xephyr.sh new file mode 100755 index 0000000..e01f15b --- /dev/null +++ b/start-xephyr.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env sh + +xephyr=$1 +awesome=$2 +rc_file=$3 + +# Check for the first free $DISPLAY +for ((i=1;;i++)); 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 \ No newline at end of file -- 2.40.1 From a9620e890429e37a457b7b6bdf4cad18b5606a1b Mon Sep 17 00:00:00 2001 From: Aire-One Date: Mon, 4 Oct 2021 20:43:59 +0200 Subject: [PATCH 2/8] =?UTF-8?q?add:=20editorconfig=20=F0=9F=90=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c1e2c64 --- /dev/null +++ b/.editorconfig @@ -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 -- 2.40.1 From 87973384a07ef22c9a709e95cfd1ae517951d2f0 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Wed, 6 Oct 2021 00:24:05 +0200 Subject: [PATCH 3/8] add: luaformatter --- .lua-format | 30 ++++++++++++++++++++++++++++++ .vscode/settings.json | 9 +++++++++ 2 files changed, 39 insertions(+) create mode 100644 .lua-format create mode 100644 .vscode/settings.json diff --git a/.lua-format b/.lua-format new file mode 100644 index 0000000..566050b --- /dev/null +++ b/.lua-format @@ -0,0 +1,30 @@ +column_limit: 80 +indent_width: 4 +use_tab: false +continuation_indent_width: 4 +spaces_before_call: 1 +keep_simple_control_block_one_line: false +keep_simple_function_one_line: false +align_args: true +break_after_functioncall_lp: false +break_before_functioncall_rp: false +spaces_inside_functioncall_parens: false +spaces_inside_functiondef_parens: false +align_parameter: true +chop_down_parameter: true +break_after_functiondef_lp: false +break_before_functiondef_rp: false +align_table_field: true +break_after_table_lb: true +break_before_table_rb: true +chop_down_table: true +chop_down_kv_table: true +table_sep: "," +column_table_limit: 80 +extra_sep_at_table_end: true +spaces_inside_table_braces: true +break_after_operator: true +double_quote_to_single_quote: false +single_quote_to_double_quote: true +spaces_around_equals_in_field: true +line_breaks_after_function_body: 1 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ea79314 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "editor.formatOnSave": true, + "editor.formatOnPaste": true, + "[markdown]": { + "editor.wordWrap": "on", + "editor.renderWhitespace": "all", + "editor.acceptSuggestionOnEnter": "off" + } +} -- 2.40.1 From 2b904ebc548e115af126a063cdaa18d35c205865 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Wed, 6 Oct 2021 00:24:22 +0200 Subject: [PATCH 4/8] add: luacheck --- .luacheckrc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .luacheckrc diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..553e807 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,38 @@ +-- 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 -- 2.40.1 From a267fc99abe591140d0752d7382f844963a142f7 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Mon, 29 Nov 2021 18:53:23 +0100 Subject: [PATCH 5/8] fix: stylua formatting --- .luacheckrc | 7 +- configuration/applications.lua | 21 +- configuration/client_keybindings.lua | 101 ++++----- configuration/client_mousebindings.lua | 22 +- configuration/global_keybindings.lua | 208 +++++++++--------- configuration/global_mousebindings.lua | 12 +- configuration/init.lua | 22 +- configuration/menu/init.lua | 4 +- configuration/menu/myawesomemenu.lua | 21 +- configuration/menu/mymainmenu.lua | 10 +- configuration/prompt_commands.lua | 34 +-- configuration/rules/client/firefox.lua | 6 +- configuration/rules/client/floating.lua | 31 ++- configuration/rules/client/global.lua | 12 +- configuration/rules/client/init.lua | 6 +- configuration/rules/client/titlebars.lua | 6 +- configuration/rules/init.lua | 4 +- configuration/rules/notification/global.lua | 4 +- configuration/rules/notification/init.lua | 2 +- configuration/tag_layouts.lua | 4 +- init.lua | 120 +++++----- slots/init.lua | 82 +++---- stylua.toml | 6 + theme/init.lua | 28 +-- ui/desktop_decoration/bar/init.lua | 187 ++++++++-------- ui/desktop_decoration/bar/widgets/battery.lua | 36 +-- ui/desktop_decoration/bar/widgets/init.lua | 4 +- ui/desktop_decoration/bar/widgets/prompt.lua | 55 +++-- ui/desktop_decoration/init.lua | 2 +- ui/hotkeys_popup/init.lua | 12 +- ui/menu/mymainmenu.lua | 8 +- 31 files changed, 558 insertions(+), 519 deletions(-) create mode 100644 stylua.toml diff --git a/.luacheckrc b/.luacheckrc index 553e807..8094e43 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -27,12 +27,7 @@ read_globals = { -- local tags = mouse.screen.tags -- tags[7].index = 4 -- client may not be read-only due to client.focus. -globals = { - "screen", - "mouse", - "root", - "client" -} +globals = { "screen", "mouse", "root", "client" } -- Enable cache (uses .luacheckcache relative to this rc file). cache = true diff --git a/configuration/applications.lua b/configuration/applications.lua index c3320a8..bf4cc29 100644 --- a/configuration/applications.lua +++ b/configuration/applications.lua @@ -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 diff --git a/configuration/client_keybindings.lua b/configuration/client_keybindings.lua index 58c7353..4d6761b 100644 --- a/configuration/client_keybindings.lua +++ b/configuration/client_keybindings.lua @@ -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 diff --git a/configuration/client_mousebindings.lua b/configuration/client_mousebindings.lua index 8e3d020..6373bbe 100644 --- a/configuration/client_mousebindings.lua +++ b/configuration/client_mousebindings.lua @@ -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 diff --git a/configuration/global_keybindings.lua b/configuration/global_keybindings.lua index 7db283b..b053782 100644 --- a/configuration/global_keybindings.lua +++ b/configuration/global_keybindings.lua @@ -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 diff --git a/configuration/global_mousebindings.lua b/configuration/global_mousebindings.lua index bab33f3..952eccc 100644 --- a/configuration/global_mousebindings.lua +++ b/configuration/global_mousebindings.lua @@ -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 diff --git a/configuration/init.lua b/configuration/init.lua index b40f2e0..6406563 100644 --- a/configuration/init.lua +++ b/configuration/init.lua @@ -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 diff --git a/configuration/menu/init.lua b/configuration/menu/init.lua index 8a30c2b..ee9131a 100644 --- a/configuration/menu/init.lua +++ b/configuration/menu/init.lua @@ -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 diff --git a/configuration/menu/myawesomemenu.lua b/configuration/menu/myawesomemenu.lua index cf2f845..efc6da3 100644 --- a/configuration/menu/myawesomemenu.lua +++ b/configuration/menu/myawesomemenu.lua @@ -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 diff --git a/configuration/menu/mymainmenu.lua b/configuration/menu/mymainmenu.lua index 7e67e2d..5062750 100644 --- a/configuration/menu/mymainmenu.lua +++ b/configuration/menu/mymainmenu.lua @@ -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 diff --git a/configuration/prompt_commands.lua b/configuration/prompt_commands.lua index 40ca2d8..0bd7a15 100644 --- a/configuration/prompt_commands.lua +++ b/configuration/prompt_commands.lua @@ -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 diff --git a/configuration/rules/client/firefox.lua b/configuration/rules/client/firefox.lua index c0e0673..35df7a3 100644 --- a/configuration/rules/client/firefox.lua +++ b/configuration/rules/client/firefox.lua @@ -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 diff --git a/configuration/rules/client/floating.lua b/configuration/rules/client/floating.lua index cb4fe28..239820e 100644 --- a/configuration/rules/client/floating.lua +++ b/configuration/rules/client/floating.lua @@ -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 diff --git a/configuration/rules/client/global.lua b/configuration/rules/client/global.lua index 1a3a1f0..5d812c4 100644 --- a/configuration/rules/client/global.lua +++ b/configuration/rules/client/global.lua @@ -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 diff --git a/configuration/rules/client/init.lua b/configuration/rules/client/init.lua index 94a581c..f0bb4d7 100644 --- a/configuration/rules/client/init.lua +++ b/configuration/rules/client/init.lua @@ -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 diff --git a/configuration/rules/client/titlebars.lua b/configuration/rules/client/titlebars.lua index 6007168..99e4d1b 100644 --- a/configuration/rules/client/titlebars.lua +++ b/configuration/rules/client/titlebars.lua @@ -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 diff --git a/configuration/rules/init.lua b/configuration/rules/init.lua index 1732a34..02d2a8f 100644 --- a/configuration/rules/init.lua +++ b/configuration/rules/init.lua @@ -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 diff --git a/configuration/rules/notification/global.lua b/configuration/rules/notification/global.lua index 1ee034e..21f2c6f 100644 --- a/configuration/rules/notification/global.lua +++ b/configuration/rules/notification/global.lua @@ -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 diff --git a/configuration/rules/notification/init.lua b/configuration/rules/notification/init.lua index 552eaa8..36f35c1 100644 --- a/configuration/rules/notification/init.lua +++ b/configuration/rules/notification/init.lua @@ -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 diff --git a/configuration/tag_layouts.lua b/configuration/tag_layouts.lua index f31fa52..5fbbea2 100644 --- a/configuration/tag_layouts.lua +++ b/configuration/tag_layouts.lua @@ -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 diff --git a/init.lua b/init.lua index 26a3366..4dd7187 100644 --- a/init.lua +++ b/init.lua @@ -1,153 +1,153 @@ -- awesome_mode: api-level=4:screen=on -if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then +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!", } diff --git a/slots/init.lua b/slots/init.lua index 5d7439d..5c4989d 100644 --- a/slots/init.lua +++ b/slots/init.lua @@ -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 diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..976e686 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,6 @@ +column_width = 80 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 4 +quote_style = "AutoPreferDouble" +no_call_parentheses = true diff --git a/theme/init.lua b/theme/init.lua index daa0adf..3fa3f2d 100644 --- a/theme/init.lua +++ b/theme/init.lua @@ -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 diff --git a/ui/desktop_decoration/bar/init.lua b/ui/desktop_decoration/bar/init.lua index c307571..7b8d8be 100644 --- a/ui/desktop_decoration/bar/init.lua +++ b/ui/desktop_decoration/bar/init.lua @@ -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 diff --git a/ui/desktop_decoration/bar/widgets/battery.lua b/ui/desktop_decoration/bar/widgets/battery.lua index 547a665..0c1aee9 100644 --- a/ui/desktop_decoration/bar/widgets/battery.lua +++ b/ui/desktop_decoration/bar/widgets/battery.lua @@ -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 diff --git a/ui/desktop_decoration/bar/widgets/init.lua b/ui/desktop_decoration/bar/widgets/init.lua index ada7bc4..e5ae9df 100644 --- a/ui/desktop_decoration/bar/widgets/init.lua +++ b/ui/desktop_decoration/bar/widgets/init.lua @@ -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 diff --git a/ui/desktop_decoration/bar/widgets/prompt.lua b/ui/desktop_decoration/bar/widgets/prompt.lua index 69017e1..ad7ebb9 100644 --- a/ui/desktop_decoration/bar/widgets/prompt.lua +++ b/ui/desktop_decoration/bar/widgets/prompt.lua @@ -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 = ' ', -- needs the 3 spaces - completion_callback = function (...) return completion_cb(prompt_widget, ...) end, - exe_callback = function (...) return exe_cb(prompt_widget, ...) end + prompt = " ", -- 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 diff --git a/ui/desktop_decoration/init.lua b/ui/desktop_decoration/init.lua index aa745b0..d603578 100644 --- a/ui/desktop_decoration/init.lua +++ b/ui/desktop_decoration/init.lua @@ -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 diff --git a/ui/hotkeys_popup/init.lua b/ui/hotkeys_popup/init.lua index ec6ad36..6a93272 100644 --- a/ui/hotkeys_popup/init.lua +++ b/ui/hotkeys_popup/init.lua @@ -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 diff --git a/ui/menu/mymainmenu.lua b/ui/menu/mymainmenu.lua index b0a66e3..78fb9aa 100644 --- a/ui/menu/mymainmenu.lua +++ b/ui/menu/mymainmenu.lua @@ -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 -- 2.40.1 From acd4f3e9243534840ec22d6b10460ce057bed3c1 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Mon, 29 Nov 2021 18:56:22 +0100 Subject: [PATCH 6/8] add(debug) vscode debug config --- .vscode/launch.json | 10 ++++------ .vscode/tasks.json | 19 +++++++++++++++++++ start-xephyr.sh | 22 +++++++++++++++++----- 3 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json index 35e23f8..f8145a4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,7 +1,4 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { @@ -14,8 +11,9 @@ "args": [ "/usr/bin/Xephyr", "/usr/bin/awesome", - "${workspaceFolder}/init.lua", - ] + "${workspaceFolder}/init.lua" + ], + "postDebugTask": "Terminate All Tasks" } ] -} \ No newline at end of file +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..dd690d8 --- /dev/null +++ b/.vscode/tasks.json @@ -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" + } + ] +} diff --git a/start-xephyr.sh b/start-xephyr.sh index e01f15b..bd14829 100755 --- a/start-xephyr.sh +++ b/start-xephyr.sh @@ -1,21 +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=1;;i++)); do - if [[ ! -f "/tmp/.X${i}-lock" ]]; then +# 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 & +$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 \ No newline at end of file + --config "$rc_file" + -- 2.40.1 From 24e6a2736374862b1a6f36c39e4d2328279f625b Mon Sep 17 00:00:00 2001 From: Aire-One Date: Mon, 29 Nov 2021 18:59:37 +0100 Subject: [PATCH 7/8] add(lua-format) remove config file --- .lua-format | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .lua-format diff --git a/.lua-format b/.lua-format deleted file mode 100644 index 566050b..0000000 --- a/.lua-format +++ /dev/null @@ -1,30 +0,0 @@ -column_limit: 80 -indent_width: 4 -use_tab: false -continuation_indent_width: 4 -spaces_before_call: 1 -keep_simple_control_block_one_line: false -keep_simple_function_one_line: false -align_args: true -break_after_functioncall_lp: false -break_before_functioncall_rp: false -spaces_inside_functioncall_parens: false -spaces_inside_functiondef_parens: false -align_parameter: true -chop_down_parameter: true -break_after_functiondef_lp: false -break_before_functiondef_rp: false -align_table_field: true -break_after_table_lb: true -break_before_table_rb: true -chop_down_table: true -chop_down_kv_table: true -table_sep: "," -column_table_limit: 80 -extra_sep_at_table_end: true -spaces_inside_table_braces: true -break_after_operator: true -double_quote_to_single_quote: false -single_quote_to_double_quote: true -spaces_around_equals_in_field: true -line_breaks_after_function_body: 1 -- 2.40.1 From 1e31cc35a64c4108c2d766d0b377ea1d6e23e579 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Mon, 29 Nov 2021 19:28:55 +0100 Subject: [PATCH 8/8] add(vscode) extensions recommendations --- .vscode/extensions.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..28a1bfe --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + "recommendations": [ + "editorconfig.editorconfig", + "tomblind.local-lua-debugger-vscode", + "sumneko.lua", + "johnnymorganz.stylua", + "dwenegar.vscode-luacheck" + ] +} -- 2.40.1