Skip to content

Commit

Permalink
Merge branch 'main' into awesome-git
Browse files Browse the repository at this point in the history
  • Loading branch information
aarondill committed Aug 10, 2023
2 parents 7233e0e + a2005db commit c59389d
Show file tree
Hide file tree
Showing 43 changed files with 166 additions and 234 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/lua-format-check-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check Lint With Stylua
on:
pull_request:
paths:
- "**.lua"
jobs:
format_code:
if: github.repository != github.event.pull_request.base.repo.full_name # if not a local branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: --check .
21 changes: 21 additions & 0 deletions .github/workflows/lua-format-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint With Stylua
on:
push:
paths:
- "**.lua"
workflow_dispatch:
jobs:
format_code:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: .
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: linting with Stylua"
1 change: 1 addition & 0 deletions .styluaignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/widget/brightness/
8 changes: 3 additions & 5 deletions configuration/apps.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local filesystem = require("gears.filesystem")
local concat_command = require("util.concat_command")
local filesystem = require("gears.filesystem")
local spawn = require("util.spawn")

local function rofi_command(...)
Expand Down Expand Up @@ -37,7 +37,7 @@ local default = {
rofi_window = rofi_command("window"),
lock = { "sh", "-c", "pgrep -x xss-lock && exec loginctl lock-session || exec lock" }, -- Run loginctl if xss-lock is running, otherwise just lock
region_screenshot = { "flameshot", "gui", "-p", os.getenv("HOME") .. "/Pictures/Screenshots/", "-c" },
browser = { "google-chrome-stable" },
browser = { "vivaldi" },
editor = { terminal, "-e", "nvim" }, -- gui text editor
-- social = "discord",
-- game = "steam",
Expand Down Expand Up @@ -78,9 +78,7 @@ if not filesystem.file_executable(notification_daemon) then
end

local polkit = "/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1"
if not filesystem.file_executable(polkit) then
polkit = "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1"
end
if not filesystem.file_executable(polkit) then polkit = "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1" end

-- List of apps to start once on start-up - these will (obviosly) only run if available, but no errors will occur if they aren't.
-- These can be tables or strings. They will *not* be run in a shell, so you must invoke it yourself if you so desire.
Expand Down
4 changes: 2 additions & 2 deletions configuration/client/rules.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local awful = require("awful")
local gears = require("gears")
local client_keys = require("configuration.keys.client")
local client_buttons = require("configuration.client.buttons")
local client_keys = require("configuration.keys.client")
local gears = require("gears")
-- Rules
local rules = {
-- All clients will match this rule.
Expand Down
2 changes: 1 addition & 1 deletion configuration/client/titlebar.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local gears = require("gears")
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")

-- Add a titlebar if titlebars_enabled is set to true in the rules.
Expand Down
38 changes: 10 additions & 28 deletions configuration/keys/global.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local awful = require("awful")
local notifs = require("util.notifs")
local gears = require("gears")
local notifs = require("util.notifs")
local hotkeys_popup = require("awful.hotkeys_popup").widget
local spawn = require("util.spawn")

Expand All @@ -17,9 +17,7 @@ local function open_main_menu()
-- The return value will be a string in case of failure
if type(pid_or_err) == "string" then
local s = awful.screen.focused()
if s and s.run_promptbox and type(s.run_promptbox.run) == "function" then
s.run_promptbox:run()
end
if s and s.run_promptbox and type(s.run_promptbox.run) == "function" then s.run_promptbox:run() end
end
end
-- Key bindings
Expand All @@ -41,9 +39,7 @@ local globalKeys = gears.table.join(
awful.key({ modkey }, "p", open_main_menu, { description = "Main Menu", group = "awesome" }),
awful.key({ modkey }, "w", function()
local pid_or_err = spawn(apps.default.rofi_window)
if type(pid_or_err) == "string" then
notifs.critical("Rofi is required to open the window picker.")
end
if type(pid_or_err) == "string" then notifs.critical("Rofi is required to open the window picker.") end
end, { description = "Window Picker", group = "awesome" }),

-- Tag management
Expand Down Expand Up @@ -72,16 +68,12 @@ local globalKeys = gears.table.join(
awful.key({ altkey }, "Tab", function()
--awful.client.focus.history.previous()
awful.client.focus.byidx(1)
if client.focus then
client.focus:raise()
end
if client.focus then client.focus:raise() end
end, { description = "Switch to next window", group = "client" }),
awful.key({ altkey, "Shift" }, "Tab", function()
--awful.client.focus.history.previous()
awful.client.focus.byidx(-1)
if client.focus then
client.focus:raise()
end
if client.focus then client.focus:raise() end
end, { description = "Switch to previous window", group = "client" }),

-- Programs
Expand Down Expand Up @@ -154,9 +146,7 @@ local globalKeys = gears.table.join(
awful.key({ modkey, "Control" }, "n", function()
local c = awful.client.restore()
-- Focus restored client
if c then
c:emit_signal("request::activate", "key.unminimize", { raise = true })
end
if c then c:emit_signal("request::activate", "key.unminimize", { raise = true }) end
end, { description = "Restore minimized", group = "client" }),

-- Brightness
Expand Down Expand Up @@ -240,34 +230,26 @@ for i = 1, 9 do
awful.key({ modkey }, "#" .. i + 9, function()
local screen = awful.screen.focused()
local tag = screen.tags[i]
if tag then
tag:view_only()
end
if tag then tag:view_only() end
end, descr_view),
-- Toggle tag display.
awful.key({ modkey, "Control" }, "#" .. i + 9, function()
local screen = awful.screen.focused()
local tag = screen.tags[i]
if tag then
awful.tag.viewtoggle(tag)
end
if tag then awful.tag.viewtoggle(tag) end
end, descr_toggle),
-- Move client to tag.
awful.key({ modkey, "Shift" }, "#" .. i + 9, function()
if client.focus then
local tag = client.focus.screen.tags[i]
if tag then
client.focus:move_to_tag(tag)
end
if tag then client.focus:move_to_tag(tag) end
end
end, descr_move),
-- Toggle tag on focused client.
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function()
if client.focus then
local tag = client.focus.screen.tags[i]
if tag then
client.focus:toggle_tag(tag)
end
if tag then client.focus:toggle_tag(tag) end
end
end, descr_toggle_focus)
)
Expand Down
8 changes: 4 additions & 4 deletions layout/top-panel.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
local LayoutBox = require("widget.layout-box")
local TagList = require("widget.tag-list")
local TaskList = require("widget.task-list")
local awful = require("awful")
local beautiful = require("beautiful")
local wibox = require("wibox")
local TaskList = require("widget.task-list")
local TagList = require("widget.tag-list")
local LayoutBox = require("widget.layout-box")
local dpi = require("beautiful").xresources.apply_dpi
local mat_clickable_cont = require("widget.material.clickable-container")
local apps = require("configuration.apps")
local launcher = require("widget.launcher")
local mat_clickable_cont = require("widget.material.clickable-container")
local has_brightness, Brightness = pcall(require, "widget.brightness")
local Battery = require("widget.battery")
local CPU = require("widget.cpu")
Expand Down
22 changes: 7 additions & 15 deletions module/auto-start.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
-- Run all the apps listed in configuration/apps.lua as run_on_start_up only once when awesome start
local DEBUG = require("configuration").DEBUG

local awful = require("awful")
local gears = require("gears")
local apps = require("configuration.apps")
local serialize_table = require("util.serialize_table")
local awful = require("awful")
local file_write = require("util.async_file_write")
local gears = require("gears")
local notifs = require("util.notifs")
local serialize_table = require("util.serialize_table")

--- Directory for logging failed(?) application's output
--- This *MUST* end in a slash
Expand All @@ -25,13 +25,9 @@ end
---@param cmd string|string[] the thing to run
---@return integer? pid of the process or nil if error
local function run_once(cmd)
if not cmd then
return nil
end
if not cmd then return nil end
---@type string|string[]
if not type(cmd) == "string" and not type(cmd) == "table" then
error("Startup apps must be string or table")
end
if not type(cmd) == "string" and not type(cmd) == "table" then error("Startup apps must be string or table") end

--- Used in log to ensure that the date matches the *start* date, not the *end* date
local CMD_DATE = os.date() ---@cast CMD_DATE string
Expand All @@ -42,9 +38,7 @@ local function run_once(cmd)
---@param exitreason "exit"|"signal"
---@param exitcode integer
function(stdout, stderr, exitreason, exitcode)
if exitreason == "exit" and exitcode == 0 then
return
end
if exitreason == "exit" and exitcode == 0 then return end
if exitreason == "exit" and exitcode == 127 and not DEBUG then
-- Command not found.
-- I don't want a warning.
Expand Down Expand Up @@ -103,9 +97,7 @@ end

for _, app in ipairs(apps.run_on_start_up) do
local pid = run_once(app)
if pid then
processes[app] = pid
end
if pid then processes[app] = pid end
end
-- Kill them all on exit
awesome.connect_signal("exit", function(_)
Expand Down
10 changes: 3 additions & 7 deletions module/decorate-client.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
local awful = require("awful")
local gears = require("gears")
local beautiful = require("beautiful")
local gears = require("gears")

local function renderClient(client, mode)
if client.skip_decoration or (client.rendering_mode == mode) then
return
end
if client.skip_decoration or (client.rendering_mode == mode) then return end

client.rendering_mode = mode
client.floating = false
Expand Down Expand Up @@ -41,9 +39,7 @@ local function changesOnScreen(currentScreen)
local clientsToManage = {}

for _, client in pairs(currentScreen.clients or {}) do
if not client.skip_decoration and not client.hidden then
table.insert(clientsToManage, client)
end
if not client.skip_decoration and not client.hidden then table.insert(clientsToManage, client) end
end

if tagIsMax or #clientsToManage == 1 then
Expand Down
16 changes: 6 additions & 10 deletions module/exit-screen.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local apps = require("configuration.apps")
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local icons = require("theme.icons")
local clickable_container = require("widget.material.clickable-container")
local apps = require("configuration.apps")
local gears = require("gears")
local icons = require("theme.icons")
local wibox = require("wibox")
local dpi = require("beautiful").xresources.apply_dpi
local handle_error = require("util.handle_error")
local spawn = require("util.spawn")
Expand Down Expand Up @@ -46,9 +46,7 @@ local function buildButton(icon, text, on_release)
layout = wibox.layout.fixed.vertical,
})

if on_release then
clickable:connect_signal("button::release", on_release)
end
if on_release then clickable:connect_signal("button::release", on_release) end

return widget
end
Expand Down Expand Up @@ -114,9 +112,7 @@ local lock = buildButton(icons.lock, "Lock (l)", handle_error(lock_command))

local function exit_screen_show()
exit_screen_grabber = awful.keygrabber.run(handle_error(function(mods, key, event)
if event == "release" or not #mods == 0 then
return false
end
if event == "release" or not #mods == 0 then return false end

if key == "s" then
suspend_command()
Expand Down
8 changes: 3 additions & 5 deletions module/notifications.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local awful = require("awful")
local gears = require("gears")
local naughty = require("naughty")
local notifs = require("util.notifs")
local gears = require("gears")
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi

-- Icon directories have to be hard coded.
Expand Down Expand Up @@ -43,9 +43,7 @@ end
do
local in_error = false
awesome.connect_signal("debug::error", function(err)
if in_error then
return
end
if in_error then return end
in_error = true

notifs.critical(tostring(err) .. "\n" .. debug.traceback(nil, 2), {
Expand Down
16 changes: 4 additions & 12 deletions module/persistent-tag.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
local awful = require("awful")
local filepath = "/tmp/awesomewm-last-selected-tags"
awesome.connect_signal("exit", function(reason_restart)
if not reason_restart then
return
end
if not reason_restart then return end

local file = io.open(filepath, "w+")
--stylua: ignore
Expand All @@ -21,9 +19,7 @@ end)

awesome.connect_signal("startup", function()
local file = io.open(filepath, "r")
if not file then
return
end
if not file then return end

local screen_tags = {}
for line in file:lines("l") do
Expand All @@ -37,14 +33,10 @@ awesome.connect_signal("startup", function()

for s in screen do
local sel_tags = screen_tags[s.index]
if #sel_tags > 0 then
awful.tag.viewnone(s)
end
if #sel_tags > 0 then awful.tag.viewnone(s) end
for _, i in ipairs(sel_tags) do
local scr_tag = s.tags[i]
if scr_tag then
scr_tag.selected = true
end
if scr_tag then scr_tag.selected = true end
end
end

Expand Down
Loading

0 comments on commit c59389d

Please sign in to comment.