Skip to content

Commit

Permalink
better to keep this updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomashighbaugh committed Jan 15, 2024
1 parent 52351d3 commit c88fa58
Show file tree
Hide file tree
Showing 21 changed files with 311 additions and 336 deletions.
6 changes: 0 additions & 6 deletions configuration/layout.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
-- _____ __
-- | |_.---.-.--.--.-----.--.--.| |_
-- | | _ | | | _ | | || _|
-- |_______|___._|___ |_____|_____||____|
-- |_____|
-- +---------------------------------------------------------------+
-- NOTE: need to use regular lua local require calls for the libraries here because this is called earlier than they are
--
Expand Down Expand Up @@ -31,7 +26,6 @@ tag.connect_signal("request::default_layouts", function(s)
deck, -- while similar to cascade, this one has different padding and margin settings that nakes having both useful to a variable degree
center,
thrizen,

horizon,
equalarea,
awful.layout.suit.max,
Expand Down
32 changes: 14 additions & 18 deletions modules/autostart.lua
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
-- _______ __ __ __
-- | _ |.--.--.| |_.-----.-----.| |_.---.-.----.| |_
-- | || | || _| _ |__ --|| _| _ | _|| _|
-- |___|___||_____||____|_____|_____||____|___._|__| |____|
-- -------------------------------------------------------------------------- --
-- autostart module
-- Libraries and Modules
local awful = require("awful")
local sfx = require("modules.sfx")
-- -------------------------------------------------------------------------- --
-- Autostart Applications

local function run_once(cmd)
local findme = cmd
local firstspace = cmd:find(" ")
if firstspace then
findme = cmd:sub(0, firstspace - 1)
end
awful.spawn.easy_async_with_shell(
string.format("pgrep -u $USER -x %s > /dev/null || (%s)", findme, cmd)
)
local findme = cmd
local firstspace = cmd:find(" ")
if firstspace then
findme = cmd:sub(0, firstspace - 1)
end
awful.spawn.with_shell(
string.format("pgrep -u $USER -x %s > /dev/null || (%s)", findme, cmd)
)
end
-- -------------------------------------------------------------------------- --
-- Add apps to autostart here via terminal commands in subshells (meaning ending with &)
autostart_apps = {
"picom -b --experimental-backends &", -- picom for compositing
' eval "$(gnome-keyring-daemon -s --components=pkcs11,secrets,ssh,gpg)" &', -- gnome secrets daemon
"xrdb -merge $HOME/.Xresources &", -- xsettings
"xss-lock lock &", -- screen locking
"picom -b --experimental-backends &", -- picom for compositing
' eval "$(gnome-keyring-daemon -s --components=pkcs11,secrets,ssh,gpg)" &', -- gnome secrets daemon
"xrdb -merge $HOME/.Xresources &", -- xsettings
"xss-lock lock &", -- screen locking
}

-- -------------------------------------------------------------------------- --
for app = 1, #autostart_apps do
run_once(autostart_apps[app])
run_once(autostart_apps[app])
end

sfx.startup()
88 changes: 40 additions & 48 deletions modules/battery.lua
Original file line number Diff line number Diff line change
@@ -1,81 +1,73 @@
---@diagnostic disable: undefined-global
-- ______ __ __
-- | __ \.---.-.| |_| |_.-----.----.--.--.
-- | __ <| _ || _| _| -__| _| | |
-- |______/|___._||____|____|_____|__| |___ |
-- |_____|
-- ------------------------------------------------- --
-- original author: Aire-One (https://github.com/Aire-One)

-- ------------------------------------------------- --
local upower = require("lgi").require("UPowerGlib")

local gtable = require("gears.table")
local gtimer = require("gears.timer")
local wbase = require("wibox.widget.base")

local setmetatable = setmetatable
local screen = screen
-- ------------------------------------------------- --
-- declare namespace

-- Declare namespace
local battery_widget = {}
local mt = {}
-- ------------------------------------------------- --
--- Helper to get the path of all connected power devices.

-- Helper to get the path of all connected power devices.
function battery_widget.list_devices()
local ret = {}
local devices = upower.Client():get_devices()
if devices ~= nil then
for _, d in ipairs(devices) do
table.insert(ret, d:get_object_path())
end
else

if not devices then
awesome.emit_signal("signal::battery:error")
return ret
end

for _, d in ipairs(devices) do
table.insert(ret, d:get_object_path())
end

return ret
end
-- ------------------------------------------------- --
--- Helper function to get a device instance from its path.

-- Helper function to get a device instance from its path.
function battery_widget.get_device(path)
local devices = upower.Client():get_devices()
if devices ~= nil then
for _, d in ipairs(devices) do
if d:get_object_path() == path then
return d
end
end
else

if not devices then
awesome.emit_signal("signal::battery:error")
return nil
end

for _, d in ipairs(devices) do
if d:get_object_path() == path then
return d
end
end

return nil
end
-- ------------------------------------------------- --
--- Helper function to easily get the default BAT0 device path without.

-- Helper function to easily get the default BAT0 device path.
function battery_widget.get_BAT0_device_path()
local bat0_path = "/org/freedesktop/UPower/devices/battery_BAT0"
if bat0_path ~= nil then
return bat0_path
end
return "/org/freedesktop/UPower/devices/battery_BAT0"
end
-- ------------------------------------------------- --
--- Helper function to convert seconds into a human readable clock string.

-- Helper function to convert seconds into a human readable clock string.
function battery_widget.to_clock(seconds)
if seconds <= 0 then
return "00:00"
else
local hours = string.format("%02.f", math.floor(seconds / 3600))
local mins = string.format("%02.f", math.floor(seconds / 60 - hours * 60))
return hours .. ":" .. mins
local mins = string.format("%02.f", math.floor(seconds / 60 % 60))
return string.format("%s:%s", hours, mins)
end
end
-- ------------------------------------------------- --
--- Gives the default widget to use if user didn't specify one.

-- Gives the default widget to use if the user didn't specify one.
local function default_template()
return wbase.empty_widget()
end

-- ------------------------------------------------- --
--- battery_widget constructor.
-- Battery widget constructor.
function battery_widget.new(args)
args = gtable.crush({
widget_template = default_template(),
Expand All @@ -94,13 +86,13 @@ function battery_widget.new(args)
if type(args.create_callback) == "function" then
args.create_callback(widget, widget.device)
end
-- ------------------------------------------------- --
-- Attach signals:

-- Attach signals
widget.device.on_notify = function(d)
widget:emit_signal("upower::update", d)
end
-- ------------------------------------------------- --
-- Call an update cycle if the user asked to instan update the widget.

-- Call an update cycle if the user asked to instantly update the widget.
if args.instant_update then
gtimer.delayed_call(
widget.emit_signal,
Expand All @@ -112,8 +104,8 @@ function battery_widget.new(args)

return widget
end
-- ------------------------------------------------- --
-- complex return statement

-- Complex return statement
function mt.__call(self, ...)
return battery_widget.new(...)
end
Expand Down
6 changes: 1 addition & 5 deletions modules/layouts/center.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
-- ______ __
-- | |.-----.-----.| |_.-----.----.
-- | ---|| -__| || _| -__| _|
-- |______||_____|__|__||____|_____|__|
-- ------------------------------------------------- --

-- NOTE: Adapted from https://github.com/kotbaton/awesomewm-config
--
-- NOTE: The nelow demonstrates the tiling arrangement
Expand Down
11 changes: 1 addition & 10 deletions modules/layouts/equalarea.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
-- _______ __
-- | ___|.-----.--.--.---.-.| |
-- | ___|| _ | | | _ || |
-- |_______||__ |_____|___._||__|
-- |__|
-- _______
-- | _ |.----.-----.---.-.
-- | || _| -__| _ |
-- |___|___||__| |_____|___._|
-- ------------------------------------------------- --
-------- --
-- NOTE: Inspired by bling but without any bloat, commented fully and given a refactor in the process
-- +---------------------------------------------------------------+

Expand Down
38 changes: 38 additions & 0 deletions modules/layouts/paper.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-- Import necessary modules
local awful = require("awful")

-- Define the custom layout
local paper_layout = {}
paper_layout.name = "paper"

function paper_layout.arrange(p)
-- Check if there are any clients
if #p.clients == 0 then
return
end

-- Store the number of clients
local num_clients = #p.clients

-- Check if the workarea width and height are not zero
if p.workarea.width == 0 or p.workarea.height == 0 then
return
end

-- Iterate over each client
for i, c in ipairs(p.clients) do
-- Calculate the new geometry for the client
local new_geometry = {
x = p.workarea.x + (i - 1) * p.workarea.width / num_clients,
y = p.workarea.y,
width = p.workarea.width / num_clients,
height = p.workarea.height,
}

-- Apply the new geometry
c:geometry(new_geometry)
end
end

-- Add the custom layout to the global layouts table
table.insert(awful.layout.layouts, paper_layout)
31 changes: 8 additions & 23 deletions signal/status/battery.lua
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
-- ______ __ __
-- | __ \.---.-.| |_| |_.-----.----.--.--.
-- | __ <| _ || _| _| -__| _| | |
-- |______/|___._||____|____|_____|__| |___ |
-- |_____|
-- _______ __ __
-- | __|__|.-----.-----.---.-.| |
-- |__ | || _ | | _ || |
-- |_______|__||___ |__|__|___._||__|
-- |_____|
-- ------------------------------------------------- --
-- signal::battery
-- percentage
-- state
local upower_widget = require("modules.battery")
local battery_listener = upower_widget({
device_path = "/org/freedesktop/UPower/devices/battery_BAT0",
instant_update = true,
device_path = "/org/freedesktop/UPower/devices/battery_BAT0",
instant_update = true,
})

battery_listener:connect_signal("upower::update", function(_, device)
if device ~= nil then
awesome.emit_signal("signal::battery", device.percentage, device.state)
collectgarbage("collect")
else
awesome.emit_signal("signal::battery:error")
end
if device ~= nil then
awesome.emit_signal("signal::battery", device.percentage, device.state)
collectgarbage("collect")
else
awesome.emit_signal("signal::battery:error")
end
end)
-- ------------------------------------------------- --
6 changes: 1 addition & 5 deletions signal/status/init.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
-- _______ __ __
-- | __| |_.---.-.| |_.--.--.-----.
-- |__ | _| _ || _| | |__ --|
-- |_______|____|___._||____|_____|_____|
-- +---------------------------------------------------------------+

-- Initializes the status polling signals
--
require(... .. ".battery")
Expand Down
2 changes: 1 addition & 1 deletion signal/system/brightness.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local awful = require("awful")

local function emit()
awful.spawn.easy_async_with_shell("brightnessctl -m | awk -F, '{print substr($4, 0, length($4)-1)}'", function(out)
local brightness = math.floor(tonumber(out))
local brightness = tonumber(out) and math.floor(tonumber(out) or 0) or 0
awesome.emit_signal("signal::brightness", brightness)
end)
end
Expand Down
Loading

0 comments on commit c88fa58

Please sign in to comment.