From 36b45cb895303f4b8bdd99a737259740129e1fb9 Mon Sep 17 00:00:00 2001 From: Timmy Keller Date: Tue, 17 Sep 2024 19:17:49 -0500 Subject: add current awesome configs --- .gitignore | 4 +- awesome/bar.lua | 184 +++++++++++++++++++++++++++++++++++ awesome/errors.lua | 35 +++++++ awesome/keybindings.lua | 174 +++++++++++++++++++++++++++++++++ awesome/layouts.lua | 10 ++ awesome/mouse.lua | 22 +++++ awesome/rc.lua | 16 +++ awesome/rules.lua | 40 ++++++++ awesome/signals.lua | 66 +++++++++++++ awesome/tagnames.lua | 51 ++++++++++ awesome/theme.lua | 15 +++ awesome/todo | 17 ++++ awesome/util/osname.lua | 5 + awesome/util/seasonalwallpaper.lua | 9 ++ awesome/util/widgets.lua | 19 ++++ awesome/widgets/audio.lua | 22 +++++ awesome/widgets/classiclayoutbox.lua | 113 +++++++++++++++++++++ awesome/widgets/classiclayouts.lua | 27 +++++ awesome/widgets/cpu.lua | 41 ++++++++ awesome/widgets/ram.lua | 36 +++++++ awesome/widgets/temperature.lua | 25 +++++ 21 files changed, 929 insertions(+), 2 deletions(-) create mode 100644 awesome/bar.lua create mode 100644 awesome/errors.lua create mode 100644 awesome/keybindings.lua create mode 100644 awesome/layouts.lua create mode 100644 awesome/mouse.lua create mode 100644 awesome/rc.lua create mode 100644 awesome/rules.lua create mode 100644 awesome/signals.lua create mode 100644 awesome/tagnames.lua create mode 100644 awesome/theme.lua create mode 100644 awesome/todo create mode 100644 awesome/util/osname.lua create mode 100644 awesome/util/seasonalwallpaper.lua create mode 100644 awesome/util/widgets.lua create mode 100644 awesome/widgets/audio.lua create mode 100644 awesome/widgets/classiclayoutbox.lua create mode 100644 awesome/widgets/classiclayouts.lua create mode 100644 awesome/widgets/cpu.lua create mode 100644 awesome/widgets/ram.lua create mode 100644 awesome/widgets/temperature.lua diff --git a/.gitignore b/.gitignore index 1330c79..1368c8f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,9 @@ !.gitignore !alacritty !ansible +!awesome !dunst +!fontconfig !git !gtk-2.0 !gtk-3.0 @@ -14,9 +16,7 @@ !redshift !x11 !zsh -!fontconfig nvim/lazy-lock.json nvim/.netrwhist zsh/.zcompdump -htop diff --git a/awesome/bar.lua b/awesome/bar.lua new file mode 100644 index 0000000..e9465d3 --- /dev/null +++ b/awesome/bar.lua @@ -0,0 +1,184 @@ +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") +local widget_temperature = require("widgets.temperature") +local classiclayoutbox = require("widgets.classiclayoutbox") + +-- 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 + +-- 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 function set_wallpaper(s) +-- -- Wallpaper +-- if beautiful.wallpaper then +-- local wallpaper = beautiful.wallpaper +-- -- If wallpaper is a function, call it with the screen +-- if type(wallpaper) == "function" then +-- wallpaper = wallpaper(s) +-- end +-- gears.wallpaper.maximized(wallpaper, s, true) +-- end +--end + +-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution) +--screen.connect_signal("property::geometry", set_wallpaper) + +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 + s.mywibox = awful.wibar({ position = "top", screen = s }) + + -- 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 "%", + }, + mylauncher, + }, + } + + ---- 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) diff --git a/awesome/errors.lua b/awesome/errors.lua new file mode 100644 index 0000000..2079c0e --- /dev/null +++ b/awesome/errors.lua @@ -0,0 +1,35 @@ +local awful = require("awful") +-- require("awful.autofocus") +-- Widget and layout library +-- Notification library +local naughty = require("naughty") + +-- {{{ Error handling +-- Check if awesome encountered an error during startup and fell back to +-- another config (This code will only ever execute for the fallback config) +if awesome.startup_errors then + naughty.notify({ + preset = naughty.config.presets.critical, + title = "Oops, there were errors during startup!", + text = awesome.startup_errors + }) +end + +-- Handle runtime errors after startup +do + local in_error = false + awesome.connect_signal("debug::error", function (err) + -- Make sure we don't go into an endless error loop + if in_error then + return + end + in_error = true + + naughty.notify({ + preset = naughty.config.presets.critical, + title = "Oops, an error happened!", + text = tostring(err) + }) + in_error = false + end) +end diff --git a/awesome/keybindings.lua b/awesome/keybindings.lua new file mode 100644 index 0000000..ec5475a --- /dev/null +++ b/awesome/keybindings.lua @@ -0,0 +1,174 @@ +local awful = require("awful") +local gears = require("gears") +local hotkeys_popup = require("awful.hotkeys_popup") +local menubar = require("menubar") +-- Enable hotkeys help widget for VIM and other apps +-- when client with a matching name is opened: +-- require("awful.hotkeys_popup.keys") + +local super = "Mod4" +local alt = "Mod1" +local shift = "Shift" +local ctrl = "ctrl" + +local key = awful.key +local a = { alt } +local as = { alt, shift } +local w = { super } +local s = { shift } +local c = { ctrl } +local wc = { super, ctrl } +local ws = { super, shift } +local wa = { super, alt } + + +-- Functions +function focus_previous() + awful.client.focus.history.previous() + if client.focus then + client.focus:raise() + end +end + +-- Key bindings +globalkeys = gears.table.join( + -- Applications + key(a , "Return", function () awful.spawn(terminal) end, { group = "launcher", description = "open a terminal" }), + key(a , "f", function () awful.spawn("pcmanfm") end, { group = "launcher", description = "launch pcmanfm" }), + key(a , "b", function () awful.spawn("launch firefox") end, { group = "launcher", description = "launch firefox" }), + key(a , "c", function () awful.spawn("launch chrome") end, { group = "launcher", description = "launch firefox (alt profile)" }), + -- Wallpaper + key(w , "w", function () awful.spawn("seasonalwallpaper") end, { group = "launcher", description = "change wallpaper" }), + -- Awesome + key(w , "F1", hotkeys_popup.show_help , { group = "awesome" , description = "show help" }), + key(w , "F10", awesome.restart , { group = "awesome" , description = "reload awesome" }), + key(ws, "F10", awesome.quit , { group = "awesome" , description = "quit awesome" }), + key(w , "Tab", awful.tag.history.restore , { group = "tag" , description = "go back" }), + -- + key(w , "j", function () awful.client.focus.byidx( 1) end, { group = "client" , description = "focus next by index" }), + key(w , "k", function () awful.client.focus.byidx(-1) end, { group = "client" , description = "focus previous by index" }), + key(ws, "j", function () awful.client.swap.byidx( 1) end, { group = "client" , description = "swap with next client by index" }), + key(ws, "k", function () awful.client.swap.byidx( -1) end, { group = "client" , description = "swap with previous client by index" }), + key(w , ",", function () awful.screen.focus_relative(-1) end, { group = "screen" , description = "focus the previous screen" }), + key(w , ".", function () awful.screen.focus_relative( 1) end, { group = "screen" , description = "focus the next screen" }), + key(w , "u", awful.client.urgent.jumpto , { group = "client" , description = "jump to urgent client" }), + key(a , "Tab", focus_previous , { group = "client" , description = "focus previous client" }), + key(w , "l", function () awful.tag.incmwfact( 0.05) end, { group = "layout" , description = "increase master width factor" }), + key(w , "h", function () awful.tag.incmwfact(-0.05) end, { group = "layout" , description = "decrease master width factor" }), + key(ws, "h", function () awful.tag.incnmaster( 1, nil, true) end, { group = "layout" , description = "increase the number of master clients" }), + key(ws, "l", function () awful.tag.incnmaster(-1, nil, true) end, { group = "layout" , description = "decrease the number of master clients" }), + key(wc, "h", function () awful.tag.incncol( 1, nil, true) end, { group = "layout" , description = "increase the number of columns" }), + key(wc, "l", function () awful.tag.incncol(-1, nil, true) end, { group = "layout" , description = "decrease the number of columns" }), + key(w , "m", function () awful.layout.set(awful.layout.suit.max) end, { group = "layout" , description = "change to max layout" }), + key(w , "t", function () awful.layout.set(awful.layout.suit.tile) end, { group = "layout" , description = "change to tile layout" }), + key(w , "r", function () awful.screen.focused().mypromptbox:run() end, { group = "launcher", description = "run prompt" }), + key(w , "p", function () menubar.show() end, { group = "launcher", description = "show the menubar" }), + -- PC Controls + key(w , "Escape", function () awful.spawn("shutdownprompt") end, { group = "system" , description = "show shutdown prompt" }), + key(w , "Escape", function () awful.spawn("shutdownprompt") end, { group = "system" , description = "show shutdown prompt" }), + key(w , "F9", function () awful.spawn("shutdownprompt Restart") end, { group = "system" , description = "restart system" }), + key(w , "F11", function () awful.spawn("shutdownprompt Suspend") end, { group = "system" , description = "suspend system" }), + key(w , "F12", function () awful.spawn("shutdownprompt Shutdown") end, { group = "system" , description = "shutdown system" }), + key(a , "m", function () awful.spawn("mounter -m") end, { group = "system" , description = "mount drive prompt" }), + key(as, "m", function () awful.spawn("mounter -u") end, { group = "system" , description = "unmount drive prompt" }), + key(w , "F5", function () awful.spawn("bl set 0") end, { group = "system" , description = "set brightness to 0%" }), + key(w , "F6", function () awful.spawn("bl set 25") end, { group = "system" , description = "set brightness to 25%" }), + key(w , "F7", function () awful.spawn("bl set 50") end, { group = "system" , description = "set brightness to 50%" }), + key(w , "F8", function () awful.spawn("bl set 100") end, { group = "system" , description = "set brightness to 100%" }), + -- Screenshots + key({}, "Print", function () awful.spawn("screenshot -x") end, { group = "misc" , description = "screenshot, copy to clipboard" }), + key(a , "Print", function () awful.spawn("screenshot -xc") end, { group = "misc" , description = "screenshot, crop, copy to clipboard" }), + key(w , "Print", function () awful.spawn("screenshot") end, { group = "misc" , description = "screenshot, save to screenshots dir" }), + key(wa, "Print", function () awful.spawn("screenshot -c") end, { group = "misc" , description = "screenshot, crop, save to screenshots dir" }) +) +--Audio Raise Volume Increase volume +--Audio Lower Volume Decrease volume +--Audio Mute Toggle mute +--Backlight Controls: +--Mon Brightness Up Increase brightness +--Mon Brightness Down Decrease brightness +--Alt + Mon Brightness Up Increase brightness by half-step +--Alt + Mon Brightness Down Decrease brightness by half-step + + +-- Client protection +local beautiful = require("beautiful") +local function protectClient(c) + c.prevent_kill = true + c.border_width = beautiful.border_width * 3 +end +local function unProtectClient(c) + c.prevent_kill = false + c.border_width = beautiful.border_width +end +local function killClient(c) + if c.prevent_kill == nil or not c.prevent_kill then + c:kill() + end +end + +-- Client keys +clientkeys = gears.table.join( + key(w , "q", killClient , { description = "close", group = "client" }), + key(w , "x", protectClient , { description = "close", group = "client" }), + key(ws, "x", unProtectClient , { description = "close", group = "client" }), + key(wc, "space", awful.client.floating.toggle , { description = "toggle floating", group = "client" }), + key(w , "Return", function (c) c:swap(awful.client.getmaster()) end, { description = "move to master", group = "client" }), + key(ws, ",", function (c) c:move_to_screen(c.screen.index - 1) end, { description = "move to previous screen", group = "client" }), + key(ws, ",", function (c) c:move_to_screen(c.screen.index + 1) end, { description = "move to next screen", group = "client" }) +) + +-- Bind all key numbers to tags. +-- Be careful: we use keycodes to make it work on any keyboard layout. +-- This should map on the top row of your keyboard, usually 1 to 9. +-- Functions + +for i = 1, 9 do + globalkeys = gears.table.join(globalkeys, + -- View tag only. + awful.key({ super }, "#" .. i + 9, + function () + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + tag:view_only() + end + end, + {description = "view tag #"..i, group = "tag"}), + -- Toggle tag display. + awful.key({ super, "Control" }, "#" .. i + 9, + function () + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) + end + end, + {description = "toggle tag #" .. i, group = "tag"}), + -- Move client to tag. + awful.key({ super, "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 + end + end, + {description = "move focused client to tag #"..i, group = "tag"}), + -- Toggle tag on focused client. + awful.key({ super, "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 + end + end, + {description = "toggle focused client on tag #" .. i, group = "tag"}) + ) +end + +-- Set keys +root.keys(globalkeys) diff --git a/awesome/layouts.lua b/awesome/layouts.lua new file mode 100644 index 0000000..0e65017 --- /dev/null +++ b/awesome/layouts.lua @@ -0,0 +1,10 @@ +local awful = require("awful") +--local tile = require("tile") + +-- Table of layouts to cover with awful.layout.inc, order matters. +awful.layout.layouts = { + -- awful.layout.suit.tile.right, + awful.layout.suit.tile, + awful.layout.suit.max, + awful.layout.suit.floating, +} diff --git a/awesome/mouse.lua b/awesome/mouse.lua new file mode 100644 index 0000000..f3d0bc1 --- /dev/null +++ b/awesome/mouse.lua @@ -0,0 +1,22 @@ +local awful = require("awful") +local gears = require("gears") + +local super = "Mod4" +local alt = "Mod1" +local shift = "Shift" +local ctrl = "Control" + +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) +)) +-- }}} + + diff --git a/awesome/rc.lua b/awesome/rc.lua new file mode 100644 index 0000000..849ecb2 --- /dev/null +++ b/awesome/rc.lua @@ -0,0 +1,16 @@ +-- Global variable definitions +terminal = os.getenv("TERMINAL") or "xterm" +editor = os.getenv("EDITOR") or "vi" + +-- Import modules +require("errors") +require("layouts") +require("theme") -- Load before bar +require("bar") +require("mouse") +require("keybindings") +require("rules") +require("signals") +require("tagnames") + +--require("widgets.audio") diff --git a/awesome/rules.lua b/awesome/rules.lua new file mode 100644 index 0000000..16ac074 --- /dev/null +++ b/awesome/rules.lua @@ -0,0 +1,40 @@ +local awful = require("awful") +local beautiful = require("beautiful") + +-- Rules to apply to new clients (through the "manage" signal). +awful.rules.rules = { + -- All clients will match this rule. + { rule = { }, + properties = { + border_width = beautiful.border_width, + border_color = beautiful.border_normal, + focus = awful.client.focus.filter, + raise = true, + keys = clientkeys, + buttons = clientbuttons, + screen = awful.screen.preferred, + placement = awful.placement.no_overlap+awful.placement.no_offscreen, + prevent_kill = false + } + }, + { rule = { class = "KeePassXC" }, + -- except = { name = "Unlock Database - KeePassXC" }, -- Not needed + properties = { + new_tag = { + name = "KeePassXC", + layout = awful.layout.suit.max, + volatile = true, + }, + -- callback = function(c) c.first_tag.icon = c.icon end + } + }, + { rule_any = { name = { "Unlock Database - KeePassXC", "KeePassXC - Browser Access Request" } }, + properties = { + screen = awful.screen.focused(), + floating = true, + placement = awful.placement.centered, + -- tags = awful.screen.focused().selected_tags, -- For some reason, this doesn't work + callback = function(c) c:tags(awful.screen.focused().selected_tags) end -- But this does + } + }, +} diff --git a/awesome/signals.lua b/awesome/signals.lua new file mode 100644 index 0000000..f0d0149 --- /dev/null +++ b/awesome/signals.lua @@ -0,0 +1,66 @@ +local awful = require("awful") +local beautiful = require("beautiful") + +-- {{{ Signals +-- Signal function to execute when a new client appears. +client.connect_signal("manage", function (c) + -- Set the windows at the slave, + -- i.e. put it at the end of others instead of setting it master. + if not awesome.startup then awful.client.setslave(c) end + + if awesome.startup + and not c.size_hints.user_position + and not c.size_hints.program_position then + -- Prevent clients from being unreachable after screen count changes. + awful.placement.no_offscreen(c) + end +end) + +---- Add a titlebar if titlebars_enabled is set to true in the rules. +--client.connect_signal("request::titlebars", function(c) +-- -- buttons for the titlebar +-- local buttons = gears.table.join( +-- awful.button({ }, 1, function() +-- c:emit_signal("request::activate", "titlebar", {raise = true}) +-- awful.mouse.client.move(c) +-- end), +-- awful.button({ }, 3, function() +-- c:emit_signal("request::activate", "titlebar", {raise = true}) +-- awful.mouse.client.resize(c) +-- end) +-- ) +-- +-- awful.titlebar(c) : setup { +-- { -- Left +-- awful.titlebar.widget.iconwidget(c), +-- buttons = buttons, +-- layout = wibox.layout.fixed.horizontal +-- }, +-- { -- Middle +-- { -- Title +-- align = "center", +-- widget = awful.titlebar.widget.titlewidget(c) +-- }, +-- buttons = buttons, +-- layout = wibox.layout.flex.horizontal +-- }, +-- { -- Right +-- awful.titlebar.widget.floatingbutton (c), +-- awful.titlebar.widget.maximizedbutton(c), +-- awful.titlebar.widget.stickybutton (c), +-- awful.titlebar.widget.ontopbutton (c), +-- awful.titlebar.widget.closebutton (c), +-- layout = wibox.layout.fixed.horizontal() +-- }, +-- layout = wibox.layout.align.horizontal +-- } +--end) + +-- Enable sloppy focus, so that focus follows mouse. +client.connect_signal("mouse::enter", function(c) + c:emit_signal("request::activate", "mouse_enter", {raise = false}) +end) + +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/tagnames.lua b/awesome/tagnames.lua new file mode 100644 index 0000000..fcd01a4 --- /dev/null +++ b/awesome/tagnames.lua @@ -0,0 +1,51 @@ +--TODO find out why it doesnt work at start +--local awful = require("awful") + +function nametags(s) + local tags = s.tags + for _, tag in ipairs(tags) do + -- set tag basename + if tag.basename == nil then + tag.basename = tag.name + end + + -- check if tag has any clients. if not, use basename + if next(tag:clients()) == nil then + tag.name = tag.basename + else + -- loop over all screen clients (ordered top to bottom) + local hastag = nil + for _, c in ipairs(s.clients) do + -- test if client in on the tag + for _, ctag in ipairs(c:tags()) do + if ctag == tag then + hastag = c + break + end + end + -- if it does, this will be the tag name. so break + if hastag ~= nil then + break + end + end + -- set tag name + -- there should always be a tag since we checked above so if there isnt then there is clearly a problem + --TODO remove this if statement + if hastag then + tag.name = tag.basename .. ": " .. hastag.class + end + end + end +end + +function nametagsc(c) + nametags(c.screen) +end + +client.connect_signal("manage", nametagsc) +client.connect_signal("swapped", nametagsc) +client.connect_signal("tagged", nametagsc) +client.connect_signal("unmanage", nametagsc) +client.connect_signal("untagged", nametagsc) + +--awful.screen.connect_for_each_screen(nametags) diff --git a/awesome/theme.lua b/awesome/theme.lua new file mode 100644 index 0000000..cdf6f2e --- /dev/null +++ b/awesome/theme.lua @@ -0,0 +1,15 @@ +-- Theme handling library +local beautiful = require("beautiful") +local gears = require("gears") + +-- Themes define colours, icons, font and wallpapers. +-- beautiful.init(gears.filesystem.get_themes_dir() .. "default/theme.lua") +beautiful.init(gears.filesystem.get_themes_dir() .. "gtk/theme.lua") +beautiful.useless_gap = 0 +--beautiful.layoutlist_font = "Monospace 8" +beautiful.font = "Tamzen 10" +beautiful.taglist_font = "Tamzen 10" +beautiful.tasklist_font = "Tamzen 10" +beautiful.tasklist_font_focus = "Tamzen 10" +beautiful.tasklist_align = "center" -- does nothing? +beautiful.wibar_height = "18" diff --git a/awesome/todo b/awesome/todo new file mode 100644 index 0000000..f20b248 --- /dev/null +++ b/awesome/todo @@ -0,0 +1,17 @@ +seasonalwallpaper +mouse warping window rule +singular borders / no border on screen edges +gaps +layout shown in bar +mouse ctrl layout sizes +client mfact/fact +hostname configs +volume widget & dropdown menu +battery widget +bar styling / powerline for certain confs +net widget + + +#general +other layouts +cleanup diff --git a/awesome/util/osname.lua b/awesome/util/osname.lua new file mode 100644 index 0000000..9501581 --- /dev/null +++ b/awesome/util/osname.lua @@ -0,0 +1,5 @@ +local handle = io.popen("uname") +local result = handle:read("*a") +handle:close() + +return result:match("^%s*(.-)%s*$") or "Unknown OS" diff --git a/awesome/util/seasonalwallpaper.lua b/awesome/util/seasonalwallpaper.lua new file mode 100644 index 0000000..230986a --- /dev/null +++ b/awesome/util/seasonalwallpaper.lua @@ -0,0 +1,9 @@ +local gears = require("gears") + +local wallpapers_directory = gears.get_xdg_data_home() .. "wallpaper" +local spring = wallpapers_directory .. "/spring" +local summer = wallpapers_directory .. "/summer" +local fall = wallpapers_directory .. "/fall" +local winter = wallpapers_directory .. "/winter" + + diff --git a/awesome/util/widgets.lua b/awesome/util/widgets.lua new file mode 100644 index 0000000..301f25b --- /dev/null +++ b/awesome/util/widgets.lua @@ -0,0 +1,19 @@ +local wibox = require("wibox") +local gears = require("gears") + +local widgets = {} + +function widgets.watchfn(callback, timeout, base_widget) + local widget = (base_widget or wibox.widget.textbox)() + gears.timer({ + timeout = timeout or 5, + call_now = true, + autostart = true, + callback = function() + callback(widget) + end + }) + return widget +end + +return widgets diff --git a/awesome/widgets/audio.lua b/awesome/widgets/audio.lua new file mode 100644 index 0000000..fa5c747 --- /dev/null +++ b/awesome/widgets/audio.lua @@ -0,0 +1,22 @@ +local awful = require("awful") +local wibox = require("wibox") +local gears = require("gears") + +local audio_dropdown = awful.popup { + widget = { + margins = 10, + widget = wibox.container.margin, + { + layout = wibox.layout.fixed.horizontal, + wibox.widget.textbox "AUDIO", + }, + }, + ontop = true, + placement = awful.placement.centered, + --shape = gears.shape.infobubble, + border_width = 1, + border_color = "#ff0000", + visible = true, +} + +return audio_dropdown diff --git a/awesome/widgets/classiclayoutbox.lua b/awesome/widgets/classiclayoutbox.lua new file mode 100644 index 0000000..ac08671 --- /dev/null +++ b/awesome/widgets/classiclayoutbox.lua @@ -0,0 +1,113 @@ +--------------------------------------------------------------------------- +--- Layoutbox widget. +-- +-- @author Julien Danjou <julien@danjou.info> +-- @copyright 2009 Julien Danjou +-- @classmod awful.widget.layoutbox +--------------------------------------------------------------------------- + +local setmetatable = setmetatable +local capi = { screen = screen, tag = tag } +local layout = require("awful.layout") +local tooltip = require("awful.tooltip") +local wibox = require("wibox") +local surface = require("gears.surface") + +local layout_icons = { + cornernw = "", + cornerne = "", + cornersw = "", + cornerse = "", + fairh = "", + fairv = "", + max = "[M]", + floating = "><>", + magnifier = "[M]", + fullscreen = "", + spiral = "", + dwindle = "", + tile = "[]=", + tiletop = "TTT", + tilebottom = "TTT", + tileleft = "=[]", +} + +local function get_screen(s) +return s and capi.screen[s] +end + +local layoutbox = { mt = {} } + +local boxes = nil + +local function update(w, screen) +screen = get_screen(screen) +local name = layout.getname(layout.get(screen)) +w._layoutbox_tooltip:set_text(name or "[no name]") + + if name == "max" and #screen.clients > 0 then + w.textbox.text = "[" .. #screen.clients .. "]" + return + end + + w.textbox.text = layout_icons[name] +end + +local function update_from_tag(t) +local screen = get_screen(t.screen) +local w = boxes[screen] +if w then + update(w, screen) +end +end + +--- Create a layoutbox widget. It draws a picture with the current layout +-- symbol of the current tag. +-- @param screen The screen number that the layout will be represented for. +-- @return An imagebox widget configured as a layoutbox. +function layoutbox.new(screen) +screen = get_screen(screen or 1) + +-- Do we already have the update callbacks registered? +if boxes == nil then + boxes = setmetatable({}, { __mode = "kv" }) + capi.tag.connect_signal("property::selected", update_from_tag) + capi.tag.connect_signal("property::layout", update_from_tag) + capi.tag.connect_signal("property::screen", function() + for s, w in pairs(boxes) do + if s.valid then + update(w, s) + end + end + end) + layoutbox.boxes = boxes +end + +-- Do we already have a layoutbox for this screen? +local w = boxes[screen] +if not w then + w = wibox.widget { + { + id = "textbox", + widget = wibox.widget.textbox + }, + layout = wibox.layout.fixed.horizontal + } + + w._layoutbox_tooltip = tooltip {objects = {w}, delay_show = 1} + + update(w, screen) + boxes[screen] = w +end + +return w +end + +function layoutbox.mt:__call(...) +return layoutbox.new(...) +end + +return setmetatable(layoutbox, layoutbox.mt) + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 + diff --git a/awesome/widgets/classiclayouts.lua b/awesome/widgets/classiclayouts.lua new file mode 100644 index 0000000..917ca00 --- /dev/null +++ b/awesome/widgets/classiclayouts.lua @@ -0,0 +1,27 @@ +local awful = require("awful") + +local layoutbox = {} + +local layout_icons = { + cornernw = "", + cornerne = "", + cornersw = "", + cornerse = "", + fairh = "", + fairv = "", + max = "[M]", + floating = "><>", + magnifier = "[M]", + fullscreen = "", + spiral = "", + dwindle = "", + tile = "[]=", + tiletop = "TTT", + tilebottom = "TTT", + tileleft = "=[]", +} + +function(s) + s = screen[s or 1] + +end diff --git a/awesome/widgets/cpu.lua b/awesome/widgets/cpu.lua new file mode 100644 index 0000000..cbd5916 --- /dev/null +++ b/awesome/widgets/cpu.lua @@ -0,0 +1,41 @@ +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 + +function linux_cpu_usage(widget) + -- read stat + local statf = io.open("/proc/stat") + local stat_iter = statf:read():gmatch("%d+") + statf:close() + + -- calc + local sum = 0 + local a, b = cpu_time, {} -- set cpu_time as a for smaller code + table.move(a, 1, 7, 1, b) -- copy first 7 to b + + for i = 1, 7 do + a[i] = stat_iter() + sum = sum + b[i] - a[i] + end + + if sum == 0 then + return + end + + local usage = ((b[1] + b[2] + b[3] + b[6] + b[7]) - + (a[1] + a[2] + a[3] + a[6] + a[7])) * 100 / sum + + widget:set_text(math.floor(usage)) +end + + +-- return correct widget for os +if osname == "Linux" then + return widgets.watchfn(linux_cpu_usage, 5) +end + +return wibox.widget.textbox("unsupported os") diff --git a/awesome/widgets/ram.lua b/awesome/widgets/ram.lua new file mode 100644 index 0000000..2347ca4 --- /dev/null +++ b/awesome/widgets/ram.lua @@ -0,0 +1,36 @@ +local wibox = require("wibox") +local widgets = require("util.widgets") +local osname = require("util.osname") + + +function linux_ram_usage(widget) + -- read meminfo + local meminfof = io.open("/proc/meminfo") + + local total = meminfof:read():match("%d+") + local free = meminfof:read():match("%d+") + + meminfof:read() -- memavailable not used + + local buffers = meminfof:read():match("%d+") + local cached = meminfof:read():match("%d+") + + meminfof:close() + + -- calc + if total == nil then + return + end + + local used = (total - free - buffers - cached) * 100 / total + + widget:set_text(math.floor(used)) +end + + +-- return correct widget for os +if osname == "Linux" then + return widgets.watchfn(linux_ram_usage, 5) +end + +return wibox.widget.textbox("unsupported os") diff --git a/awesome/widgets/temperature.lua b/awesome/widgets/temperature.lua new file mode 100644 index 0000000..8cf1aa9 --- /dev/null +++ b/awesome/widgets/temperature.lua @@ -0,0 +1,25 @@ +local wibox = require("wibox") +local widgets = require("util.widgets") +local osname = require("util.osname") + + +local linux = { file = nil } +function linux.temperature(widget) + -- read meminfo + local tempf = io.open(linux.file) + local temp = tempf:read() / 1000 + tempf:close() + + widget:set_text(math.floor(temp)) +end + + +-- return correct widget for os +if osname == "Linux" then + return function(file) + linux.file = file + return widgets.watchfn(linux.temperature, 5) + end +end + +return wibox.widget.textbox("unsupported os") -- cgit v1.2.3