diff options
author | Tim Keller <tjk@tjkeller.xyz> | 2024-10-11 20:43:20 -0500 |
---|---|---|
committer | Tim Keller <tjk@tjkeller.xyz> | 2024-10-11 20:43:20 -0500 |
commit | ce020ab718b0ea09224dd15fc9a5796b3acc7904 (patch) | |
tree | 5d1ab3fb93f85d6fbf1b9fe84dfcd3484ce6ef33 /awesome | |
parent | 5e84a09eb67772b07a73102538d2445ecb403613 (diff) | |
download | dotconfig-ce020ab718b0ea09224dd15fc9a5796b3acc7904.tar.xz dotconfig-ce020ab718b0ea09224dd15fc9a5796b3acc7904.zip |
overhaul awesome
Diffstat (limited to 'awesome')
23 files changed, 340 insertions, 324 deletions
diff --git a/awesome/bar.lua b/awesome/bar.lua index 523beec..4adddb3 100644 --- a/awesome/bar.lua +++ b/awesome/bar.lua @@ -1,181 +1,146 @@ -local gears = require("gears") local awful = require("awful") -require("awful.autofocus") --- Widget and layout library local wibox = require("wibox") --- Theme handling library local beautiful = require("beautiful") --- Notification library -local naughty = require("naughty") -local menubar = require("menubar") -local hotkeys_popup = require("awful.hotkeys_popup") --- Enable hotkeys help widget for VIM and other apps --- when client with a matching name is opened: -require("awful.hotkeys_popup.keys") - --- Load widgets -local widget_cpu_usage = require("widgets.cpu") -local widget_ram_usage = require("widgets.ram") +-- load widgets +--local mylauncher = require("widgets.button") +local widget_cpu_usage = require("widgets.cpu") +local widget_ram_usage = require("widgets.ram") local widget_temperature = require("widgets.temperature") -local classiclayoutbox = require("widgets.classiclayoutbox") -local volume_control = require("widgets.pavolctld") +local classiclayoutbox = require("widgets.classiclayouts") +local volume_control = require("widgets.pavolctld") local widget_volume = volume_control.textbox --- Menu --- Create a launcher widget and a main menu -myawesomemenu = { - { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, - { "restart", awesome.restart }, - { "quit", function() awesome.quit() end }, +-- store widgets here +local spacing = 8 +local separator = { widget = wibox.widget.separator, opacity = 0 } + +local widgets = { + spacing = spacing, -- constant + layoutlist = wibox.widget { + layout = wibox.layout.fixed.horizontal, + buttons = layout_buttons, + wibox.container.margin( + classiclayoutbox(s), + spacing, spacing, 0, 0 + ), + }, + taglist = function(s) return awful.widget.taglist { + screen = s, + filter = awful.widget.taglist.filter.noempty, + buttons = taglist_buttons, + } end, + tasklist = function(s) return wibox.widget { + layout = wibox.layout.align.horizontal, + expand = "outside", + separator, + awful.widget.tasklist { + screen = s, + filter = awful.widget.tasklist.filter.focused, + buttons = tasklist_buttons, + widget_template = { + id = "text_role", + widget = wibox.widget.textbox, + align = "center", + }, + }, + separator, + } end, + textclock = wibox.widget.textclock("%A, %B %e, %-I:%M %p"), + cpu = wibox.widget { + layout = wibox.layout.fixed.horizontal, + wibox.widget.textbox "CPU: ", + widget_cpu_usage, + wibox.widget.textbox "% ", + widget_temperature "/sys/class/hwmon/hwmon2/temp1_input", + wibox.widget.textbox "°", + }, + ram = { + layout = wibox.layout.fixed.horizontal, + wibox.widget.textbox "RAM: ", + widget_ram_usage, + wibox.widget.textbox "%", + }, + vol = { + layout = wibox.layout.fixed.horizontal, + buttons = volume_buttons, + wibox.widget.textbox "VOL: ", + widget_volume, + wibox.widget.textbox "%", + }, } -mymainmenu = awful.menu({ - items = { - { "awesome", myawesomemenu, beautiful.awesome_icon }, - { "open terminal", terminal } - } -}) - -mylauncher = awful.widget.launcher({ - image = beautiful.awesome_icon, - menu = mymainmenu -}) - --- Menubar configuration -menubar.utils.terminal = terminal -- Set the terminal for applications that require it - --- Wibar --- Create a textclock widget ---mytextclock = wibox.widget.textclock("%A, %B %e, %-I:%M %p") --- x60 -mytextclock = wibox.widget.textclock("%a, %b %e, %-H:%M") - --- Create a wibox for each screen and add it -local taglist_buttons = gears.table.join( - awful.button({ }, 1, function(t) t:view_only() end), - awful.button({ modkey }, 1, function(t) if client.focus then client.focus:move_to_tag(t) end end), - awful.button({ }, 3, awful.tag.viewtoggle), - awful.button({ modkey }, 3, function(t) if client.focus then client.focus:toggle_tag(t) end end), - awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), - awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end) -) - -local tasklist_buttons = gears.table.join( - awful.button({ }, 1, function (c) c:emit_signal("request::activate", "tasklist", {raise = true}) end), - awful.button({ }, 3, function() awful.menu.client_list({ theme = { width = 250 } }) end), - awful.button({ }, 4, function () awful.client.focus.byidx(1) end), - awful.button({ }, 5, function () awful.client.focus.byidx(-1) end) -) - -local volume_buttons = gears.table.join( - awful.button({ }, 4, function() volume_control.volume_inc(5) end), - awful.button({ }, 5, function() volume_control.volume_dec(5) end) -) - +-- left widget group func +function widgets.left_widgets(s) return wibox.widget { + layout = wibox.layout.fixed.horizontal, + spacing = spacing, + { + layout = wibox.layout.fixed.horizontal, + widgets.layoutlist, + widgets.taglist(s), + }, + widgets.tasklist(s), +} end + +-- miggle widget group func +function widgets.middle_widgets(s) return wibox.widget { + layout = wibox.layout.fixed.horizontal, + widgets.textclock, +} end + +-- right widget group func +function widgets.right_widgets(s) return wibox.widget { + layout = wibox.layout.fixed.horizontal, + { + layout = wibox.layout.fixed.horizontal, + spacing = spacing, + widgets.cpu, + widgets.ram, + widgets.vol, + }, + { + widget = wibox.widget.separator, + opacity = 0, + forced_width = spacing + }, + --mylauncher, +} end + +-- create a wibox for each screen and add it awful.screen.connect_for_each_screen(function (s) awful.tag({"1", "2", "3", "4", "5", "6", "7", "8", "9"}, s, awful.layout.layouts[1]) s.mypromptbox = awful.widget.prompt() - --s.mylayoutbox = awful.widget.layoutbox { - -- screen = s, - -- buttons = { - -- awful.button({ }, 1, function () awful.layout.inc( 1) end), - -- awful.button({ }, 3, function () awful.layout.inc(-1) end), - -- awful.button({ }, 4, function () awful.layout.inc(-1) end), - -- awful.button({ }, 5, function () awful.layout.inc( 1) end), - -- } - --} - - - -- Create the wibox + -- create the wibox s.mywibox = awful.wibar({ position = "top", screen = s }) - -- Add widgets to the wibox + -- add widgets to the wibox s.mywibox:setup { layout = wibox.layout.align.horizontal, expand = "none", - spacing = 8, - -- Left widgets - { - layout = wibox.layout.fixed.horizontal, - spacing = 8, - { - layout = wibox.layout.fixed.horizontal, - --awful.widget.layoutbox(s), - classiclayoutbox(s), - awful.widget.taglist { - screen = s, - filter = awful.widget.taglist.filter.noempty, - buttons = taglist_buttons, - }, - }, - { - layout = wibox.layout.align.horizontal, - expand = "outside", - wibox.widget { widget = wibox.widget.separator, opacity = 0 }, - awful.widget.tasklist { - screen = s, - filter = awful.widget.tasklist.filter.focused, - buttons = tasklist_buttons, - widget_template = { - id = "text_role", - widget = wibox.widget.textbox, - align = "center", - }, - }, - wibox.widget { widget = wibox.widget.separator, opacity = 0 }, - }, - }, - -- Middle widget - { - layout = wibox.layout.fixed.horizontal, - mytextclock, - }, - -- Right widgets - { - layout = wibox.layout.fixed.horizontal, - spacing = 8, - { - layout = wibox.layout.fixed.horizontal, - wibox.widget.textbox "CPU: ", - widget_cpu_usage, - wibox.widget.textbox "% ", - widget_temperature "/sys/class/hwmon/hwmon2/temp1_input", - wibox.widget.textbox "°", - }, - { - layout = wibox.layout.fixed.horizontal, - wibox.widget.textbox "RAM: ", - widget_ram_usage, - wibox.widget.textbox "%", - }, - { - layout = wibox.layout.fixed.horizontal, - buttons = volume_buttons, - wibox.widget.textbox "VOL: ", - widget_volume, - wibox.widget.textbox "%", - }, - mylauncher, - }, + spacing = spacing, + widgets.left_widgets(s), + widgets.middle_widgets(s), + widgets.right_widgets(s), } - - ---- Signal for changing tasklist filter based on layout - ---- DOESNT WORK TODO - --s:connect_signal("property::layout", function() - -- naughty.notify({ - -- title = "Hello, AwesomeWM!", - -- text = "This is a notification.", - -- timeout = 5, -- Timeout in seconds - -- position = "top_right" -- Position on the screen - -- }) - -- if awful.layout.get(s) == awful.layout.suit.max then - -- s.mytasklist.filter = awful.widget.tasklist.filter.currenttags - -- else - -- s.mytasklist.filter = awful.widget.tasklist.filter.focused - -- end - --end - --) - end) + +---- signal for changing tasklist filter based on layout +---- DOESNT WORK TODO +--local naughty = require("naughty") +--s:connect_signal("property::layout", function() +-- naughty.notify({ +-- title = "Hello, AwesomeWM!", +-- text = "This is a notification.", +-- timeout = 5, -- Timeout in seconds +-- position = "top_right" -- Position on the screen +-- }) +-- if awful.layout.get(s) == awful.layout.suit.max then +-- s.mytasklist.filter = awful.widget.tasklist.filter.currenttags +-- else +-- s.mytasklist.filter = awful.widget.tasklist.filter.focused +-- end +--end +--) + +return widgets diff --git a/awesome/noborders.lua b/awesome/func/noborders.lua index fe67024..fe67024 100644 --- a/awesome/noborders.lua +++ b/awesome/func/noborders.lua diff --git a/awesome/sloppyfocus.lua b/awesome/func/sloppyfocus.lua index e6b7e4e..be9cd9c 100644 --- a/awesome/sloppyfocus.lua +++ b/awesome/func/sloppyfocus.lua @@ -1,5 +1,3 @@ -local beautiful = require("beautiful") - -- Enable sloppy focus, so that focus follows mouse. client.connect_signal("mouse::enter", function(c) c:emit_signal("request::activate", "mouse_enter", { raise = false }) diff --git a/awesome/tagnames.lua b/awesome/func/tagnames.lua index fcd01a4..fcd01a4 100644 --- a/awesome/tagnames.lua +++ b/awesome/func/tagnames.lua diff --git a/awesome/warpcursor.lua b/awesome/func/warpcursor.lua index f1a46bd..f1a46bd 100644 --- a/awesome/warpcursor.lua +++ b/awesome/func/warpcursor.lua diff --git a/awesome/hosts/libreX60.lua b/awesome/hosts/libreX60.lua new file mode 100644 index 0000000..3ce5619 --- /dev/null +++ b/awesome/hosts/libreX60.lua @@ -0,0 +1,4 @@ +local wibox = require("wibox") +local bar_widgets = require("bar") + +bar_widgets.textclock.format = "%a, %b %e, %-H:%M" diff --git a/awesome/layouts.lua b/awesome/layouts.lua index 7b78c02..67fd31d 100644 --- a/awesome/layouts.lua +++ b/awesome/layouts.lua @@ -1,5 +1,4 @@ local awful = require("awful") ---local tile = require("tile") -- Table of layouts to cover with awful.layout.inc, order matters. awful.layout.layouts = { @@ -7,4 +6,22 @@ awful.layout.layouts = { awful.layout.suit.tile.bottom, awful.layout.suit.max, awful.layout.suit.floating, + + +-- awful.layout.suit.floating, +-- awful.layout.suit.tile, +-- awful.layout.suit.tile.left, +-- awful.layout.suit.tile.bottom, +-- awful.layout.suit.tile.top, +-- awful.layout.suit.fair, +-- awful.layout.suit.fair.horizontal, +-- awful.layout.suit.spiral, +-- awful.layout.suit.spiral.dwindle, +-- awful.layout.suit.max, +-- awful.layout.suit.max.fullscreen, +-- awful.layout.suit.magnifier, +-- awful.layout.suit.corner.nw, +-- awful.layout.suit.corner.ne, +-- awful.layout.suit.corner.sw, +-- awful.layout.suit.corner.se, } diff --git a/awesome/errors.lua b/awesome/lib/errors.lua index 2079c0e..2079c0e 100644 --- a/awesome/errors.lua +++ b/awesome/lib/errors.lua diff --git a/awesome/manage.lua b/awesome/lib/manage.lua index 5b1bd40..5b1bd40 100644 --- a/awesome/manage.lua +++ b/awesome/lib/manage.lua diff --git a/awesome/screen.lua b/awesome/lib/screen.lua index dc01e2c..dc01e2c 100644 --- a/awesome/screen.lua +++ b/awesome/lib/screen.lua diff --git a/awesome/mouse.lua b/awesome/mouse.lua index f3d0bc1..13165db 100644 --- a/awesome/mouse.lua +++ b/awesome/mouse.lua @@ -1,22 +1,47 @@ local awful = require("awful") local gears = require("gears") +local volume_control = require("widgets.pavolctld") local super = "Mod4" local alt = "Mod1" local shift = "Shift" local ctrl = "Control" +-- window buttons clientbuttons = gears.table.join( awful.button({ }, 1, function (c) c:emit_signal("request::activate", "mouse_click", {raise = true}) end), awful.button({ super }, 1, function (c) c:emit_signal("request::activate", "mouse_click", {raise = true}) awful.mouse.client.move(c) end), awful.button({ super }, 3, function (c) c:emit_signal("request::activate", "mouse_click", {raise = true}) awful.mouse.client.resize(c) end) ) --- {{{ Mouse bindings -root.buttons(gears.table.join( - awful.button({ }, 3, function () mymainmenu:toggle() end), - awful.button({ }, 4, awful.tag.viewnext), - awful.button({ }, 5, awful.tag.viewprev) -)) --- }}} +--root.buttons(gears.table.join( +-- awful.button({ }, 3, function () mymainmenu:toggle() end), +-- awful.button({ }, 4, awful.tag.viewnext), +-- awful.button({ }, 5, awful.tag.viewprev) +--)) +-- wibar widgets +layout_buttons = gears.table.join( + awful.button({ }, 1, function() awful.layout.inc(1, awful.screen.focused().tags[0]) end) +) + +taglist_buttons = gears.table.join( + awful.button({ }, 1, function(t) t:view_only() end), + awful.button({ modkey }, 1, function(t) if client.focus then client.focus:move_to_tag(t) end end), + awful.button({ }, 3, awful.tag.viewtoggle), + awful.button({ modkey }, 3, function(t) if client.focus then client.focus:toggle_tag(t) end end), + awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), + awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end) +) + +tasklist_buttons = gears.table.join( + awful.button({ }, 1, function (c) c:emit_signal("request::activate", "tasklist", {raise = true}) end), + --awful.button({ }, 3, function() awful.menu.client_list({ theme = { width = 250 } }) end), + awful.button({ }, 4, function () awful.client.focus.byidx(1) end), + awful.button({ }, 5, function () awful.client.focus.byidx(-1) end) +) + +volume_buttons = gears.table.join( + awful.button({ }, 4, function() volume_control.volume_inc(5) end), + awful.button({ }, 5, function() volume_control.volume_dec(5) end) +) diff --git a/awesome/rc.lua b/awesome/rc.lua index 1bcbaa8..50d85d7 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -1,20 +1,30 @@ --- Global variable definitions +-- global variable definitions terminal = os.getenv("TERMINAL") or "xterm" -editor = os.getenv("EDITOR") or "vi" +editor = os.getenv("EDITOR") or "vi" --- Import modules -require("errors") +-- get results from uname +local uname = io.popen("uname -sn") +local uname_i = uname:read("*a"):gmatch("%g+") +uname:close() + +osname = uname_i() +hostname = uname_i() + +-- import modules +require("lib.errors") +require("lib.manage") +require("lib.screen") require("layouts") -require("theme") -- Load before bar +require("theme") -- load before bar +require("mouse") -- load before bar & rules require("bar") -require("screen") -require("mouse") require("keybindings") require("rules") -require("manage") -require("noborders") -require("warpcursor") -require("sloppyfocus") ---require("tagnames") - +require("func.noborders") +require("func.sloppyfocus") +require("func.warpcursor") +--require("func.tagnames") --require("widgets.audio") + +-- call override module if exists +pcall(function() require("hosts." .. hostname) end) diff --git a/awesome/rules.lua b/awesome/rules.lua index 3f57080..8655541 100644 --- a/awesome/rules.lua +++ b/awesome/rules.lua @@ -1,10 +1,11 @@ local awful = require("awful") local beautiful = require("beautiful") --- Rules to apply to new clients (through the "manage" signal). +-- Rules to apply to new clients (through the "manage" signal) awful.rules.rules = { - -- All clients will match this rule. - { rule = { }, + -- All clients will match this rule + { + rule = { }, properties = { border_width = beautiful.border_width, border_color = beautiful.border_normal, @@ -17,18 +18,21 @@ awful.rules.rules = { prevent_kill = false, } }, - -- warp cursor - { rule_any = { class = { - "Chromium-browser", - "Firefox", - "Firefox-esr", - "Gimp", - "KeePassXC", - "Pcmanfm", + -- Warp cursor + { + rule_any = { class = { + "Chromium-browser", + "Firefox", + "Firefox-esr", + "Gimp", + "KeePassXC", + "Pcmanfm", }}, properties = { warp_cursor = true, } }, - { rule = { class = "KeePassXC" }, + -- KeePassXC rules + { + rule = { class = "KeePassXC" }, -- except = { name = "Unlock Database - KeePassXC" }, -- Not needed properties = { new_tag = { @@ -39,7 +43,8 @@ awful.rules.rules = { -- callback = function(c) c.first_tag.icon = c.icon end } }, - { rule_any = { name = { "Unlock Database - KeePassXC", "KeePassXC - Browser Access Request" } }, + { + rule_any = { name = { "Unlock Database - KeePassXC", "KeePassXC - Browser Access Request" } }, properties = { screen = awful.screen.focused(), floating = true, diff --git a/awesome/theme.lua b/awesome/theme.lua index e48c1ce..98f0ee8 100644 --- a/awesome/theme.lua +++ b/awesome/theme.lua @@ -1,19 +1,39 @@ --- Theme handling library +-- theme handling library local beautiful = require("beautiful") local gears = require("gears") --- Themes define colours, icons, font and wallpapers. +-- colors +local darkgray = "#222222" +local white = "#ffffff" +local lightgray = "#aaaaaa" + +-- themes define colours, icons, font and wallpapers beautiful.init(gears.filesystem.get_themes_dir() .. "gtk/theme.lua") + +-- gaps beautiful.useless_gap = 0 beautiful.gap_single_client = false + +-- overrides +beautiful.tasklist_font_focus = beautiful.font -- prevent bold +beautiful.wibar_height = "18" +beautiful.wibar_bg = darkgray --beautiful.layoutlist_font = "Monospace 8" --beautiful.font = "Tamzen 10" --beautiful.taglist_font = "Tamzen 10" --beautiful.tasklist_font = beautiful.font -beautiful.tasklist_font_focus = beautiful.font -- prevent bold -beautiful.tasklist_align = "center" -- does nothing? -beautiful.wibar_height = "18" +--beautiful.tasklist_align = "center" -- does nothing? + +-- hotkeys menu +beautiful.hotkeys_font = beautiful.font -- TODO make bold +beautiful.hotkeys_description_font = beautiful.font +beautiful.hotkeys_border_color = beautiful.border_focus +beautiful.hotkeys_bg = darkgray +beautiful.hotkeys_fg = white +beautiful.hotkeys_label_fg = white +beautiful.hotkeys_modifiers_fg = lightgray +beautiful.hotkeys_label_bg = darkgray -- ??? --- Set border on clients +-- set border on clients client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) diff --git a/awesome/todo b/awesome/todo index 346ddd8..08ab7dd 100644 --- a/awesome/todo +++ b/awesome/todo @@ -20,3 +20,5 @@ other layouts floating support tabbing support cleanup + +move pvolctld logic to sep util file with diff callbacks diff --git a/awesome/util/dbus_example.lua b/awesome/util/dbus_example.lua deleted file mode 100644 index 1e4d756..0000000 --- a/awesome/util/dbus_example.lua +++ /dev/null @@ -1,59 +0,0 @@ -local lgi = require("lgi") -local Gio = lgi.require("Gio") -local GLib = lgi.require("GLib") - --- Workaround for https://github.com/pavouk/lgi/issues/142 -local function bus_get_async(type) - Gio.bus_get(type, nil, coroutine.running()) - local a, b = coroutine.yield() - return Gio.bus_get_finish(b) -end - -local function inhibit(bus, what, who, why, mode) - local name = "org.freedesktop.login1" - local object = "/org/freedesktop/login1" - local interface = "org.freedesktop.login1.Manager" - local message = Gio.DBusMessage.new_method_call(name, object, interface, "Inhibit") - message:set_body(GLib.Variant("(ssss)", - { what, who, why, mode })) - - local timeout = -1 -- Just use the default - local result, err = bus:async_send_message_with_reply(message, Gio.DBusSendMessageFlags.NONE, - timeout, nil) - - if err then - print("error: " .. tostring(err)) - return - end - - if result:get_message_type() == "ERROR" then - local _, err = result:to_gerror() - print("error: " .. tostring(err)) - return - end - - local fd_list = result:get_unix_fd_list() - local fd, err = fd_list:get(0) - if err then - print("error: " .. tostring(err)) - return - end - - -- Now... somehow turn this fd into something we can close - return Gio.UnixInputStream.new(fd, true) -end - -Gio.Async.call(function() - local bus = bus_get_async(Gio.BusType.SYSTEM) - local a = inhibit(bus, "shutdown:sleep", "hi, it's me!", "Just because", "delay") - print("got lock") - io.popen("sleep 10"):read("*a") - a:async_close() - -- Speed up deletion of the GDBusMessage that still references the FD - collectgarbage("collect") - collectgarbage("collect") - - print("released lock") - io.popen("sleep 10"):read("*a") -end)() - diff --git a/awesome/widgets/button.lua b/awesome/widgets/button.lua new file mode 100644 index 0000000..cd1da1e --- /dev/null +++ b/awesome/widgets/button.lua @@ -0,0 +1,33 @@ +local awful = require("awful") +local beautiful = require("beautiful") +local menubar = require("menubar") + +local hotkeys_popup = require("awful.hotkeys_popup") +-- Enable hotkeys help widget for VIM and other apps +-- when client with a matching name is opened: +require("awful.hotkeys_popup.keys") + +-- Menu +-- Create a launcher widget and a main menu +myawesomemenu = { + { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, + { "restart", awesome.restart }, + { "quit", function() awesome.quit() end }, +} + +mymainmenu = awful.menu({ + items = { + { "awesome", myawesomemenu, beautiful.awesome_icon }, + { "open terminal", terminal } + } +}) + +mylauncher = awful.widget.launcher({ + image = beautiful.awesome_icon, + menu = mymainmenu +}) + +-- Menubar configuration +menubar.utils.terminal = terminal -- Set the terminal for applications that require it + +return mylauncher diff --git a/awesome/widgets/classiclayoutbox.lua b/awesome/widgets/classiclayoutbox.lua index 818dc0f..412cb77 100644 --- a/awesome/widgets/classiclayoutbox.lua +++ b/awesome/widgets/classiclayoutbox.lua @@ -19,7 +19,7 @@ local layout_icons = { cornersw = "", cornerse = "", fairh = "", - fairv = "", + fairv = "EEH", max = "[M]", floating = "><>", magnifier = "[M]", diff --git a/awesome/widgets/classiclayouts.lua b/awesome/widgets/classiclayouts.lua index 917ca00..3b4fd64 100644 --- a/awesome/widgets/classiclayouts.lua +++ b/awesome/widgets/classiclayouts.lua @@ -1,27 +1,64 @@ -local awful = require("awful") +local wibox = require("wibox") +local layout = require("awful.layout") -local layoutbox = {} +local screen_widgets = {} -- need one widget per screen local layout_icons = { - cornernw = "", - cornerne = "", - cornersw = "", - cornerse = "", - fairh = "", - fairv = "", - max = "[M]", - floating = "><>", - magnifier = "[M]", - fullscreen = "", - spiral = "", - dwindle = "", - tile = "[]=", - tiletop = "TTT", - tilebottom = "TTT", - tileleft = "=[]", + cornernw = "TT=", + cornerne = "=TT", + cornersw = "LL=", + cornerse = "=LL", + fairh = "#_#", + fairv = "##H", + max = "[M]", + floating = "><>", + magnifier = "=O=", + fullscreen = "[*]", + spiral = "[]@", + dwindle = "[]\\", + tile = "[]=", + tiletop = "LLL", + tilebottom = "TTT", + tileleft = "=[]", } -function(s) - s = screen[s or 1] +function update(screen_index) + local s = screen[screen_index or 1] + local w = screen_widgets[s] + local l = layout.get(s) + -- create widget if not existing + if w == nil then + screen_widgets[s] = { widget = wibox.widget.textbox(), layout = l } + w = screen_widgets[s] + --w._layoutbox_tooltip = tooltip {objects = {w}, delay_show = 1} + + -- skip if no change + elseif w.layout == l then + return + end + + -- set widget + local name = layout.getname(l) + --w._layoutbox_tooltip:set_text(name) + w.widget:set_text(layout_icons[name]) -- TODO handle nil + return w.widget +end + +function update_screens() + for s, w in pairs(boxes) do + if s.valid then + update(s) + end + end end + +function update_current_tag(t) + update(t.screen) +end + +tag.connect_signal("property::selected", update_current_tag) +tag.connect_signal("property::layout", update_current_tag) +tag.connect_signal("property::screen", update_screens) + +return update diff --git a/awesome/widgets/cpu.lua b/awesome/widgets/cpu.lua index cbd5916..d92bce8 100644 --- a/awesome/widgets/cpu.lua +++ b/awesome/widgets/cpu.lua @@ -1,7 +1,5 @@ local wibox = require("wibox") local widgets = require("util.widgets") -local osname = require("util.osname") - -- this is directly adapted from slstatus's cpu.c module local cpu_time = { 0,0,0,0,0,0,0 } -- user, nice, system, idle, iowait, irq, softirq @@ -32,7 +30,6 @@ function linux_cpu_usage(widget) widget:set_text(math.floor(usage)) end - -- return correct widget for os if osname == "Linux" then return widgets.watchfn(linux_cpu_usage, 5) diff --git a/awesome/widgets/pipewire.lua b/awesome/widgets/pipewire.lua deleted file mode 100644 index 3195ee7..0000000 --- a/awesome/widgets/pipewire.lua +++ /dev/null @@ -1,34 +0,0 @@ -local awful = require("awful") -local wibox = require("wibox") - ---local get_volume_cmd = "wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed 's/Volume: //;s/0*\\.//'" ---local set_volume_cmd = "wpctl set-volume @DEFAULT_AUDIO_SINK@ %d%%%s" -- will be formatted -local get_volume_cmd = "wpctl get-volume @DEFAULT_AUDIO_SINK@" - -local widget = { - textbox = wibox.widget.textbox() -} - -local updating = false -function update_volume() - if updating then - return - end - awful.spawn.easy_async(get_volume_cmd, function(vol) - updating = true - vol = vol:sub(8) * 100 -- skip `Volume: ` whos len is 8 - widget.textbox:set_text(math.floor(vol)) - updating = false - end) -end - --- NOTE pulseaudio-utils (pactl) is still required due to the dependence on the --- `pactl subscribe` command. in the future it would be advantageous to replace --- this. currently it is (probably) only really possible with dbus. -awful.spawn.with_line_callback("pactl subscribe", { stdout = function(stdout) - --update_volume() -end }) - -update_volume() - -return widget.textbox diff --git a/awesome/widgets/ram.lua b/awesome/widgets/ram.lua index 2347ca4..44ab314 100644 --- a/awesome/widgets/ram.lua +++ b/awesome/widgets/ram.lua @@ -1,6 +1,5 @@ local wibox = require("wibox") local widgets = require("util.widgets") -local osname = require("util.osname") function linux_ram_usage(widget) @@ -27,7 +26,6 @@ function linux_ram_usage(widget) widget:set_text(math.floor(used)) end - -- return correct widget for os if osname == "Linux" then return widgets.watchfn(linux_ram_usage, 5) diff --git a/awesome/widgets/temperature.lua b/awesome/widgets/temperature.lua index 985291d..a30e1ed 100644 --- a/awesome/widgets/temperature.lua +++ b/awesome/widgets/temperature.lua @@ -1,6 +1,5 @@ local wibox = require("wibox") local widgets = require("util.widgets") -local osname = require("util.osname") local linux = { file = nil } @@ -16,7 +15,6 @@ function linux.temperature(widget) end end - -- return correct widget for os if osname == "Linux" then return function(file) |