From 5babd2e2bc82530752c79d19479113c6f99a8fee Mon Sep 17 00:00:00 2001 From: Noella <49508517+ItsNoellaHere@users.noreply.github.com> Date: Mon, 4 Mar 2024 22:32:18 -0700 Subject: [PATCH] Added Deco Module --- deco/layoutbox.lua | 30 +++++++++++++++++++++++++++++ deco/statusbar.lua | 41 ++++++++++++++++++++++++++++++++++++++++ deco/taglist.lua | 41 ++++++++++++++++++++++++++++++++++++++++ deco/tasklist.lua | 36 +++++++++++++++++++++++++++++++++++ deco/titlebar.lua | 43 ++++++++++++++++++++++++++++++++++++++++++ deco/wallpaper.lua | 21 +++++++++++++++++++++ main/signals.lua | 46 --------------------------------------------- rc.lua | 8 +++----- theme/wallpaper.lua | 1 + 9 files changed, 216 insertions(+), 51 deletions(-) create mode 100644 deco/layoutbox.lua create mode 100644 deco/statusbar.lua create mode 100644 deco/taglist.lua create mode 100644 deco/tasklist.lua create mode 100644 deco/titlebar.lua create mode 100644 deco/wallpaper.lua create mode 100644 theme/wallpaper.lua diff --git a/deco/layoutbox.lua b/deco/layoutbox.lua new file mode 100644 index 0000000..fe857cd --- /dev/null +++ b/deco/layoutbox.lua @@ -0,0 +1,30 @@ +local awful = require("awful") +local gears = require("gears") + +local _M = {} + +function _M.get(s) + local layoutbox = awful.widget.layoutbox(s) + layoutbox:buttons(gears.table.join( + 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) + )) + + return layoutbox +end + +return setmetatable({}, { + __call = function(_, ...) + return _M.get(...) + end, +}) diff --git a/deco/statusbar.lua b/deco/statusbar.lua new file mode 100644 index 0000000..8d39f36 --- /dev/null +++ b/deco/statusbar.lua @@ -0,0 +1,41 @@ +local gears = require("gears") +local awful = require("awful") +local wibox = require("wibox") + +local wallpaper = require("deco.wallpaper") +local taglist = require("deco.taglist") +local tasklist = require("deco.tasklist") +local layoutbox = require("deco.layoutbox") + +awful.screen.connect_for_each_screen(function(s) + wallpaper(s) + + -- Create a promptbox for each screen + s.promptbox = awful.widget.prompt() + + s.layoutbox = layoutbox(s) + + s.taglist = taglist(s) + + s.tasklist = tasklist(s) + + -- Create the wibox + s.wibox = awful.wibar({ position = "bottom", screen = s }) + + -- Add widgets to the wibox + s.wibox:setup({ + layout = wibox.layout.align.horizontal, + { -- Left widgets + layout = wibox.layout.fixed.horizontal, + s.taglist, + s.promptbox, + }, + s.tasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + wibox.widget.systray(), + mytextclock, + s.layoutbox, + }, + }) +end) diff --git a/deco/taglist.lua b/deco/taglist.lua new file mode 100644 index 0000000..09514a3 --- /dev/null +++ b/deco/taglist.lua @@ -0,0 +1,41 @@ +local awful = require("awful") +local gears = require("gears") + +local _M = {} + +function _M.get(s) + local taglist_buttons = gears.table.join( + awful.button({}, 1, function(t) + t:view_only() + end), + awful.button({ RC.vars.modkey }, 1, function(t) + if client.focus then + client.focus:move_to_tag(t) + end + end), + awful.button({}, 3, awful.tag.viewtoggle), + awful.button({ RC.vars.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) + ) + + return awful.widget.taglist({ + screen = s, + filter = awful.widget.taglist.filter.all, + buttons = taglist_buttons, + }) +end + +return setmetatable({}, { + __call = function(_, ...) + return _M.get(...) + end, +}) diff --git a/deco/tasklist.lua b/deco/tasklist.lua new file mode 100644 index 0000000..9d5ccad --- /dev/null +++ b/deco/tasklist.lua @@ -0,0 +1,36 @@ +local awful = require("awful") +local gears = require("gears") + +local _M = {} + +function _M.get(s) + local tasklist_buttons = gears.table.join( + awful.button({}, 1, function(c) + if c == client.focus then + c.minimized = true + else + c:emit_signal("request::activate", "tasklist", { raise = true }) + end + 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) + ) + return awful.widget.tasklist({ + screen = s, + filter = awful.widget.tasklist.filter.currenttags, + buttons = tasklist_buttons, + }) +end + +return setmetatable({}, { + __call = function(_, ...) + return _M.get(...) + end, +}) diff --git a/deco/titlebar.lua b/deco/titlebar.lua new file mode 100644 index 0000000..e531568 --- /dev/null +++ b/deco/titlebar.lua @@ -0,0 +1,43 @@ +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. +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) diff --git a/deco/wallpaper.lua b/deco/wallpaper.lua new file mode 100644 index 0000000..f28642c --- /dev/null +++ b/deco/wallpaper.lua @@ -0,0 +1,21 @@ +local awful = require("awful") +local gears = require("gears") + +local _W = {} + +function _W.set_wallpaper(s) + local wallpaper = require("theme.wallpaper") + + if type(wallpaper) == "function" then + wallpaper = wallpaper(s) + end + gears.wallpaper.maximized(wallpaper, s, true) +end + +screen.connect_signal("property::geometry", _W.set_wallpaper) + +return setmetatable({}, { + __call = function(_, ...) + return _W.set_wallpaper(...) + end, +}) diff --git a/main/signals.lua b/main/signals.lua index 5e2f6a0..e2e4fb3 100644 --- a/main/signals.lua +++ b/main/signals.lua @@ -1,60 +1,14 @@ -local gears = require("gears") local awful = require("awful") -local wibox = require("wibox") local beautiful = require("beautiful") -- 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) - client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) diff --git a/rc.lua b/rc.lua index 834a04d..cede023 100644 --- a/rc.lua +++ b/rc.lua @@ -10,8 +10,10 @@ require("awful.autofocus") local main = require("main") local bindings = require("bindings") +local theme = require("theme") +local deco = require("deco") -beautiful.init(require("theme")) +beautiful.init(theme) RC = {} RC.vars = main.user_vars() @@ -20,12 +22,8 @@ RC.tags = main.tags() awful.spawn.with_shell("picom -b") --- Table of layouts to cover with awful.layout.inc, order matters. awful.layout.layouts = RC.layouts --- Keyboard map indicator and switcher --- mykeyboardlayout = awful.widget.keyboardlayout() - -- {{{ Wibar -- Create a textclock widget mytextclock = wibox.widget.textclock() diff --git a/theme/wallpaper.lua b/theme/wallpaper.lua new file mode 100644 index 0000000..c8a5542 --- /dev/null +++ b/theme/wallpaper.lua @@ -0,0 +1 @@ +return require("gears.filesystem").get_themes_dir() .. "background.png"