From f0a0ff285569e121ea3b791521014c7c08b8353c Mon Sep 17 00:00:00 2001 From: Mutzi Date: Sat, 21 Jan 2023 16:25:32 +0100 Subject: [PATCH] Added luarocks config and handled warnings --- awesome/.luacheckrc | 56 +++++++++++++++++++++++++++++++++++++++++++++ awesome/rc.lua | 21 ++++++++++------- awesome/theme.lua | 34 ++++++++++++--------------- 3 files changed, 83 insertions(+), 28 deletions(-) create mode 100644 awesome/.luacheckrc diff --git a/awesome/.luacheckrc b/awesome/.luacheckrc new file mode 100644 index 0000000..a9622a6 --- /dev/null +++ b/awesome/.luacheckrc @@ -0,0 +1,56 @@ +-- Only allow symbols available in all Lua versions +std = "min" + +-- Get rid of "unused argument self"-warnings +self = false + +-- The unit tests can use busted +files["spec"].std = "+busted" + +-- The default config may set global variables +files["awesomerc.lua"].allow_defined_top = true +files["rc.lua"].allow_defined_top = true + +-- This file itself +files[".luacheckrc"].ignore = {"111", "112", "131"} + +-- Theme files, ignore max line length +files["themes/*"].ignore = {"631"} + +-- 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 + +-- Do not enable colors to make the CI output more readable. +color = false + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/awesome/rc.lua b/awesome/rc.lua index c95110d..6ce91ac 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -78,7 +78,8 @@ awful.spawn.with_shell( 'if (xrdb -query | grep -q "^awesome\\.started:\\s*true$"); then exit; fi;' .. 'xrdb -merge <<< "awesome.started:true";' .. -- list each of your autostart commands, followed by ; inside single quotes, followed by .. - 'dex --environment Awesome --autostart --search-paths "$XDG_CONFIG_DIRS/autostart:$XDG_CONFIG_HOME/autostart"' -- https://github.com/jceb/dex + 'dex --environment Awesome + --autostart --search-paths "$XDG_CONFIG_DIRS/autostart:$XDG_CONFIG_HOME/autostart"' -- https://github.com/jceb/dex ) --]] @@ -89,9 +90,9 @@ local modkey = "Mod4" local altkey = "Mod1" local terminal = "kitty" local vi_focus = false -- vi-like client focus https://github.com/lcpz/awesome-copycats/issues/275 -local cycle_prev = true -- cycle with only the previously focused client or all https://github.com/lcpz/awesome-copycats/issues/274 -local editor = os.getenv("EDITOR") or "nvim" -local browser = "firefox" +-- cycle with only the previously focused client or all https://github.com/lcpz/awesome-copycats/issues/274 +local cycle_prev = true +local editor = "nvim" awful.util.terminal = terminal awful.util.tagnames = { "1", "2", "3", "4", "5" } @@ -255,8 +256,10 @@ globalkeys = mytable.join( {description = "take a screenshot", group = "hotkeys"}), -- X screen locker - awful.key({ modkey, altkey, "Control" }, "l", function () os.execute(os.getenv("HOME") .. "/.config/awesome/scripts/lock.sh") end, - {description = "lock screen", group = "hotkeys"}), + awful.key({ modkey, altkey, "Control" }, "l", function () + os.execute(os.getenv("HOME") .. "/.config/awesome/scripts/lock.sh") + end, + {description = "lock screen", group = "hotkeys"}), -- Show help awful.key({ modkey, }, "s", hotkeys_popup.show_help, @@ -418,7 +421,7 @@ globalkeys = mytable.join( awful.key({ altkey, }, "w", function () if beautiful.weather then beautiful.weather.show(7) end end, {description = "show weather", group = "widgets"}), ]]-- - + -- Screen brightness --awful.key({ }, "XF86MonBrightnessUp", function () os.execute("xbacklight -inc 10") end, -- {description = "+10%", group = "hotkeys"}), @@ -441,7 +444,9 @@ globalkeys = mytable.join( {description = "volume down", group = "hotkeys"}), awful.key({ altkey }, "m", function () - os.execute(string.format("amixer -q set %s toggle", beautiful.volume.togglechannel or beautiful.volume.channel)) + os.execute(string.format("amixer -q set %s toggle", + beautiful.volume.togglechannel or beautiful.volume.channel) + ) beautiful.volume.update() end, {description = "toggle mute", group = "hotkeys"}), diff --git a/awesome/theme.lua b/awesome/theme.lua index 8bbc5a7..6cb17ba 100644 --- a/awesome/theme.lua +++ b/awesome/theme.lua @@ -96,7 +96,9 @@ local markup = lain.util.markup -- Textclock os.setlocale(os.getenv("LANG")) -- to localize the clock local clockicon = wibox.widget.imagebox(theme.widget_clock) -local mytextclock = wibox.widget.textclock(markup("#7788af", "%A %d %B ") .. markup("#ab7367", ">") .. markup("#de5e1e", " %H:%M ")) +local mytextclock = wibox.widget.textclock( + markup("#7788af", "%A %d %B ") .. markup("#ab7367", ">") .. markup("#de5e1e", " %H:%M ") +) mytextclock.font = theme.font -- Calendar @@ -114,7 +116,10 @@ local fsicon = wibox.widget.imagebox(theme.widget_fs) theme.fs = lain.widget.fs({ notification_preset = { font = "Monospace 10", fg = theme.fg_normal }, settings = function() - widget:set_markup(markup.fontfg(theme.font, "#80d9d8", fs_now["/"].percentage .. "% (" .. string.format("%.3f", fs_now["/"].free) .. " " .. fs_now["/"].units .. " left)")) + -- luacheck: max line length 150, globals widget fs_now + widget:set_markup(markup.fontfg(theme.font, "#80d9d8", + fs_now["/"].percentage .. "% (" .. string.format("%.3f", fs_now["/"].free) .. " " .. fs_now["/"].units .. " left)") + ) end }) theme.fs.widget:buttons(gears.table.join( @@ -127,6 +132,7 @@ theme.fs.widget:buttons(gears.table.join( local cpuicon = wibox.widget.imagebox(theme.widget_cpu) local cpu = lain.widget.cpu({ settings = function() + -- luacheck: globals widget cpu_now widget:set_markup(markup.fontfg(theme.font, "#e33a6e", cpu_now.usage .. "% ")) end }) @@ -157,6 +163,7 @@ local bat = lain.widget.bat({ local volicon = wibox.widget.imagebox(theme.widget_vol) theme.volume = lain.widget.alsa({ settings = function() + -- luacheck: globals widget volume_now if volume_now.status == "off" then volume_now.level = volume_now.level .. "M" end @@ -181,6 +188,7 @@ local netdowninfo = wibox.widget.textbox() local netupicon = wibox.widget.imagebox(theme.widget_netup) local netupinfo = lain.widget.net({ settings = function() + -- luacheck: globals widget net_now widget:set_markup(markup.fontfg(theme.font, "#e54c62", net_now.sent .. " ")) netdowninfo:set_markup(markup.fontfg(theme.font, "#87af5f", net_now.received .. " ")) end @@ -190,6 +198,7 @@ local netupinfo = lain.widget.net({ local memicon = wibox.widget.imagebox(theme.widget_mem) local memory = lain.widget.mem({ settings = function() + -- luacheck: globals widget mem_now widget:set_markup(markup.fontfg(theme.font, "#e0da37", mem_now.used .. "M ")) end }) @@ -256,7 +265,9 @@ function theme.at_screen_connect(s) s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, awful.util.tasklist_buttons) -- Create the wibox - s.mywibox = awful.wibar({ position = "top", screen = s, height = dpi(19), bg = theme.bg_normal, fg = theme.fg_normal }) + s.mywibox = awful.wibar( + { position = "top", screen = s, height = dpi(19), bg = theme.bg_normal, fg = theme.fg_normal } + ) -- Add widgets to the wibox s.mywibox:setup { @@ -298,23 +309,6 @@ function theme.at_screen_connect(s) mytextclock, }, } ---[[ - -- Create the bottom wibox - s.mybottomwibox = awful.wibar({ position = "bottom", screen = s, border_width = 0, height = dpi(20), bg = theme.bg_normal, fg = theme.fg_normal }) - - -- Add widgets to the bottom wibox - s.mybottomwibox:setup { - layout = wibox.layout.align.horizontal, - { -- Left widgets - layout = wibox.layout.fixed.horizontal, - }, - s.mytasklist, -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - s.mylayoutbox, - }, - } -]]-- end return theme