diff --git a/modules/autostart.lua b/modules/autostart.lua index d1db193..e5d71c2 100644 --- a/modules/autostart.lua +++ b/modules/autostart.lua @@ -1,10 +1,13 @@ -- autostart module + -- Libraries and Modules local awful = require("awful") local sfx = require("modules.sfx") + -- -------------------------------------------------------------------------- -- -- Autostart Applications +-- Function to run a command once local function run_once(cmd) local findme = cmd local firstspace = cmd:find(" ") @@ -15,6 +18,7 @@ local function run_once(cmd) 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 = { @@ -25,6 +29,7 @@ autostart_apps = { } -- -------------------------------------------------------------------------- -- +-- Run the autostart applications for app = 1, #autostart_apps do run_once(autostart_apps[app]) end diff --git a/modules/battery.lua b/modules/battery.lua index ce8498c..6e8cbbe 100644 --- a/modules/battery.lua +++ b/modules/battery.lua @@ -1,4 +1,26 @@ -- original author: Aire-One (https://github.com/Aire-One) + +-- This module provides a battery widget for the Awesome Window Manager. +-- It uses the UPowerGlib library to interact with the system's power devices. +-- The widget displays information about the battery, such as its charge level and remaining time. + +-- The battery_widget module exports the following functions: +-- - list_devices(): Returns a table containing the paths of all connected power devices. +-- - get_device(path): Returns the device instance corresponding to the given path. +-- - get_BAT0_device_path(): Returns the default path for the BAT0 device. +-- - to_clock(seconds): Converts the given number of seconds into a human-readable clock string. +-- - new(args): Constructs a new battery widget with the specified arguments. + +-- Example usage: +-- local battery_widget = require("battery_widget") +-- local widget = battery_widget.new({ device_path = "/org/freedesktop/UPower/devices/battery_BAT0" }) + +-- The battery widget emits the following signals: +-- - upower::update(device): Triggered when the device's state is updated. + +-- Note: This code is based on the original work by Aire-One (https://github.com/Aire-One). +-- It has been modified and adapted for use in the Awesome Window Manager. +-- 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") diff --git a/modules/dropdown.lua b/modules/dropdown.lua index 8ab3178..4854872 100644 --- a/modules/dropdown.lua +++ b/modules/dropdown.lua @@ -1,9 +1,3 @@ --- _____ __ --- | \.----.-----.-----.--| |.-----.--.--.--.-----. --- | -- | _| _ | _ | _ || _ | | | | | --- |_____/|__| |_____| __|_____||_____|________|__|__| --- |__| --- +---------------------------------------------------------------+ -- Drop-down applications manager for the awesome window manager -- Parameters: -- prog - Program to run @@ -15,8 +9,9 @@ -- screen - Screen (optional) -- based largely off of attachdrop, just streamlined to my use case -- https://github.com/tumurzakov/attachdrop --- +---------------------------------------------------------------+ --- Grab environment +-- This module provides functionality for creating drop-down windows in the Awesome Window Manager. +-- It allows attaching a window under the cursor to a specific program and toggling between hidden and visible states. + local pairs = pairs local awful = require("awful") local setmetatable = setmetatable @@ -27,22 +22,34 @@ local capi = { } local dropdown = {} --- +---------------------------------------------------------------+ --- Attach window under cursor to prog --- + +-- Attaches a window under the cursor to the specified program. +-- @param prog The program to attach the window to. function dropdown.attach(prog) + -- Create a table for the program if it doesn't exist if not dropdown[prog] then dropdown[prog] = {} end - screen = capi.mouse.screen - c = awful.mouse.client_under_pointer() + -- Get the current screen and client under the cursor + local screen = capi.mouse.screen + local c = awful.mouse.client_under_pointer() + + -- Store the client under the program and screen dropdown[prog][screen] = c end --- +---------------------------------------------------------------+ --- Create a new window for the drop-down application when it doesn't --- exist, or toggle between hidden and visible states when it does + +-- Creates a new window for the drop-down application when it doesn't exist, +-- or toggles between hidden and visible states when it does. +-- @param prog The program to create the window for or toggle. +-- @param vert (optional) The vertical position of the window ("top", "center", "bottom"). +-- @param horiz (optional) The horizontal position of the window ("left", "center", "right"). +-- @param width (optional) The width of the window (percentage of the screen width or absolute value). +-- @param height (optional) The height of the window (percentage of the screen height or absolute value). +-- @param sticky (optional) Whether the window should be sticky (always visible). +-- @param screen (optional) The screen to create the window on. function dropdown.toggle(prog, vert, horiz, width, height, sticky, screen) + -- Set default values if not provided vert = vert or "top" horiz = horiz or "center" width = width or 1 @@ -50,16 +57,15 @@ function dropdown.toggle(prog, vert, horiz, width, height, sticky, screen) sticky = sticky or false screen = screen or capi.mouse.screen - -- Determine signal usage in this version of awesome + -- Determine signal usage in this version of Awesome local attach_signal = capi.client.connect_signal or capi.client.add_signal - local detach_signal = capi.client.disconnect_signal - or capi.client.remove_signal + local detach_signal = capi.client.disconnect_signal or capi.client.remove_signal + -- Create a table for the program if it doesn't exist if not dropdown[prog] then dropdown[prog] = {} - -- +---------------------------------------------------------------+ - -- Add unmanage signal for scratchdrop programs + -- Add an "unmanage" signal to remove the client from the table when it is unmanaged attach_signal("unmanage", function(c) for scr, cl in pairs(dropdown[prog]) do if cl == c then @@ -69,18 +75,15 @@ function dropdown.toggle(prog, vert, horiz, width, height, sticky, screen) end) end + -- If the window doesn't exist, create it if not dropdown[prog][screen] then - spawnw = function(c) + local spawnw = function(c) dropdown[prog][screen] = c - -- +---------------------------------------------------------------+ - -- Scratchdrop clients are floaters - -- + -- Set the client as a floater awful.client.floating.set(c, true) - -- +---------------------------------------------------------------+ - -- Client geometry and placement - -- + -- Calculate the window geometry and placement local screengeom = capi.screen[screen].workarea if width <= 1 then @@ -90,6 +93,7 @@ function dropdown.toggle(prog, vert, horiz, width, height, sticky, screen) height = math.ceil(screengeom.height * height) end + local x, y if horiz == "left" then x = screengeom.x elseif horiz == "right" then @@ -105,9 +109,8 @@ function dropdown.toggle(prog, vert, horiz, width, height, sticky, screen) else y = screengeom.y end - -- +---------------------------------------------------------------+ - -- Client properties + -- Set the client's geometry and properties c:geometry({ x = x, y = y, width = width, height = height }) c.ontop = true c.above = true @@ -116,36 +119,29 @@ function dropdown.toggle(prog, vert, horiz, width, height, sticky, screen) capi.client.focus = c detach_signal("manage", spawnw) end - -- ------------------------------------------------- -- - -- ------------------------------------------------- -- - -- ------------------------------------------------- -- - -- Add manage signal and spawn the program + -- Add a "manage" signal to create the window and spawn the program attach_signal("manage", spawnw) - awful.util.spawn_with_shell(prog, false) -- original without '_with_shell' + awful.util.spawn_with_shell(prog, false) else - -- Get a running client + -- Get the running client + local c = dropdown[prog][screen] - c = dropdown[prog][screen] - - status, err = pcall(awful.client.movetotag, awful.tag.selected(screen), c) + -- Move the client to the current workspace + local status, err = pcall(awful.client.movetotag, awful.tag.selected(screen), c) if err then dropdown[prog][screen] = false return end - -- +---------------------------------------------------------------+ - -- Switch the client to the current workspace - if c:isvisible() == false then + -- Switch the client to the current workspace if it's hidden + if not c:isvisible() then c.hidden = true awful.client.movetotag(awful.tag.selected(screen), c) end - -- +---------------------------------------------------------------+ - -- Focus and raise if hidden + -- Focus and raise the client if it's hidden if c.hidden then - -- Make sure it is centered - if vert == "center" then awful.placement.center_vertical(c) end @@ -156,8 +152,7 @@ function dropdown.toggle(prog, vert, horiz, width, height, sticky, screen) c:raise() capi.client.focus = c else - -- Hide and detach tags if not - + -- Hide and detach tags if the client is not hidden c.hidden = true local ctags = c:tags() for i, t in pairs(ctags) do diff --git a/modules/icon_theme.lua b/modules/icon_theme.lua index bd46fcb..e5abbce 100644 --- a/modules/icon_theme.lua +++ b/modules/icon_theme.lua @@ -1,14 +1,6 @@ --- _______ --- |_ _|.----.-----.-----. --- _| |_ | __| _ | | --- |_______||____|_____|__|__| --- _______ __ --- |_ _| |--.-----.--------.-----. --- | | | | -__| | -__| --- |___| |__|__|_____|__|__|__|_____| --- -------------------------------------------------------------------------- -- --- shamelessly stolen from the bling library, awesome work they did with this --- +-- This module provides functionality for retrieving icons based on various criteria such as process ID, icon name, and class. +-- It utilizes the lgi library to interact with the Gtk.IconTheme and Gio.AppInfo modules. + local lgi = require("lgi") local Gio = lgi.Gio local Gtk = lgi.require("Gtk", "3.0") @@ -23,6 +15,7 @@ local name_lookup = { ["jetbrains-studio"] = "android-studio", } +-- Retrieves the icon path based on the process ID of the client. local function get_icon_by_pid_command(self, client, apps) local pid = client.pid if pid ~= nil then @@ -39,6 +32,7 @@ local function get_icon_by_pid_command(self, client, apps) end end +-- Retrieves the icon path based on the icon name of the client. local function get_icon_by_icon_name(self, client, apps) local icon_name = client.icon_name and client.icon_name:lower() or nil if icon_name ~= nil then @@ -51,6 +45,7 @@ local function get_icon_by_icon_name(self, client, apps) end end +-- Retrieves the icon path based on the class of the client. local function get_icon_by_class(self, client, apps) if client.class ~= nil then local class = name_lookup[client.class] or client.class:lower() @@ -78,6 +73,7 @@ local function get_icon_by_class(self, client, apps) end end +-- Retrieves the icon path for the client based on various criteria. function icon_theme:get_client_icon_path(client) local apps = Gio.AppInfo.get_all() @@ -93,6 +89,7 @@ function icon_theme:get_client_icon_path(client) }) end +-- Chooses an icon from the provided list of icon names. function icon_theme:choose_icon(icons_names) local icon_info = self.gtk_theme:choose_icon(icons_names, self.icon_size, 0) if icon_info then @@ -105,6 +102,7 @@ function icon_theme:choose_icon(icons_names) return "" end +-- Retrieves the icon path for the given GIcon object. function icon_theme:get_gicon_path(gicon) if gicon == nil then return "" @@ -121,6 +119,7 @@ function icon_theme:get_gicon_path(gicon) return "" end +-- Retrieves the icon path for the given icon name. function icon_theme:get_icon_path(icon_name) local icon_info = self.gtk_theme:lookup_icon(icon_name, self.icon_size, 0) if icon_info then @@ -133,6 +132,7 @@ function icon_theme:get_icon_path(icon_name) return "" end +-- Creates a new instance of the icon_theme module. local function new(theme_name, icon_size) local ret = gobject({}) gtable.crush(ret, icon_theme, true) @@ -150,6 +150,7 @@ local function new(theme_name, icon_size) return ret end +-- Allows creating a new instance of the icon_theme module using the syntax `icon_theme()`. function icon_theme.mt:__call(...) return new(...) end diff --git a/modules/layouts/paper.lua b/modules/layouts/paper.lua deleted file mode 100644 index 4806844..0000000 --- a/modules/layouts/paper.lua +++ /dev/null @@ -1,38 +0,0 @@ --- 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) diff --git a/modules/screenshot.lua b/modules/screenshot.lua index 87636a0..07ece5e 100755 --- a/modules/screenshot.lua +++ b/modules/screenshot.lua @@ -1,7 +1,3 @@ --- _______ __ __ --- | __|.----.----.-----.-----.-----.-----.| |--.-----.| |_ --- |__ || __| _| -__| -__| |__ --|| | _ || _| --- |_______||____|__| |_____|_____|__|__|_____||__|__|_____||____| -- -------------------------------------------------------------------------- -- ---@diagnostic disable: undefined-global -- provides a means of taking and automatically handling the naming and saving of a screenshot] diff --git a/modules/sfx.lua b/modules/sfx.lua index f045482..2052c3b 100644 --- a/modules/sfx.lua +++ b/modules/sfx.lua @@ -10,7 +10,7 @@ function M.play() awful.spawn( "pacat --property=media.role=event " .. gfs.get_configuration_dir() - .. "themes/assets/sounds/confirm1.wav" + .. "themes/assets/sounds/notify2.wav" ) end diff --git a/modules/snap_edge.lua b/modules/snap_edge.lua index b4e4cc3..67fffdf 100644 --- a/modules/snap_edge.lua +++ b/modules/snap_edge.lua @@ -1,88 +1,82 @@ --- _______ _______ __ --- | __|.-----.---.-.-----. | ___|.--| |.-----.-----. --- |__ || | _ | _ | | ___|| _ || _ | -__| --- |_______||__|__|___._| __| |_______||_____||___ |_____| --- |__| |_____| --- +---------------------------------------------------------------+ -- NOTE: originally from https://www.reddit.com/r/awesomewm/comments/kw1kr7/awesomewm_question_snap_to_leftright/ -- +---------------------------------------------------------------+ -- where can be 'left' 'right' 'top' 'bottom' 'center' 'topleft' 'topright' 'bottomleft' 'bottomright' nil -- return function(c, where, geom) - local sg = screen[c.screen].geometry --screen geometry - local sw = screen[c.screen].workarea --screen workarea - local workarea = { - x_min = sw.x, - x_max = sw.x + sw.width, - y_min = sw.y, - y_max = sw.y + sw.height, - } - local cg = geom or c:geometry() - local border = c.border_width - local cs = c:struts() - cs["left"] = 0 - cs["top"] = 0 - cs["bottom"] = 0 - cs["right"] = 0 - if where ~= nil then - c:struts(cs) -- cancel struts when snapping to edge - end - if where == "right" then - cg.width = sw.width / 2 - 2 * border - cg.height = sw.height - cg.x = workarea.x_max - cg.width - cg.y = workarea.y_min - elseif where == "left" then - cg.width = sw.width / 2 - 2 * border - cg.height = sw.height - cg.x = workarea.x_min - cg.y = workarea.y_min - elseif where == "bottom" then - cg.width = sw.width - cg.height = sw.height / 2 - 2 * border - cg.x = workarea.x_min - cg.y = workarea.y_max - cg.height - awful.placement.center_horizontal(c) - elseif where == "top" then - cg.width = sw.width - cg.height = sw.height / 2 - 2 * border - cg.x = workarea.x_min - cg.y = workarea.y_min - awful.placement.center_horizontal(c) - elseif where == "topright" then - cg.width = sw.width / 2 - 2 * border - cg.height = sw.height / 2 - 2 * border - cg.x = workarea.x_max - cg.width - cg.y = workarea.y_min - elseif where == "topleft" then - cg.width = sw.width / 2 - 2 * border - cg.height = sw.height / 2 - 2 * border - cg.x = workarea.x_min - cg.y = workarea.y_min - elseif where == "bottomright" then - cg.width = sw.width / 2 - 2 * border - cg.height = sw.height / 2 - 2 * border - cg.x = workarea.x_max - cg.width - cg.y = workarea.y_max - cg.height - elseif where == "bottomleft" then - cg.width = sw.width / 2 - 2 * border - cg.height = sw.height / 2 - 2 * border - cg.x = workarea.x_min - cg.y = workarea.y_max - cg.height - elseif where == "center" then - awful.placement.centered(c) - return - elseif where == nil then - c:struts(cs) - c:geometry(cg) - return - end - c.floating = true - if c.maximized then - c.maximized = false - end + local sg = screen[c.screen].geometry --screen geometry + local sw = screen[c.screen].workarea --screen workarea + local workarea = { + x_min = sw.x, + x_max = sw.x + sw.width, + y_min = sw.y, + y_max = sw.y + sw.height, + } + local cg = geom or c:geometry() + local border = c.border_width + local cs = c:struts() + cs["left"] = 0 + cs["top"] = 0 + cs["bottom"] = 0 + cs["right"] = 0 + if where ~= nil then + c:struts(cs) -- cancel struts when snapping to edge + end + if where == "right" then + cg.width = sw.width / 2 - 2 * border + cg.height = sw.height + cg.x = workarea.x_max - cg.width + cg.y = workarea.y_min + elseif where == "left" then + cg.width = sw.width / 2 - 2 * border + cg.height = sw.height + cg.x = workarea.x_min + cg.y = workarea.y_min + elseif where == "bottom" then + cg.width = sw.width + cg.height = sw.height / 2 - 2 * border + cg.x = workarea.x_min + cg.y = workarea.y_max - cg.height + awful.placement.center_horizontal(c) + elseif where == "top" then + cg.width = sw.width + cg.height = sw.height / 2 - 2 * border + cg.x = workarea.x_min + cg.y = workarea.y_min + awful.placement.center_horizontal(c) + elseif where == "topright" then + cg.width = sw.width / 2 - 2 * border + cg.height = sw.height / 2 - 2 * border + cg.x = workarea.x_max - cg.width + cg.y = workarea.y_min + elseif where == "topleft" then + cg.width = sw.width / 2 - 2 * border + cg.height = sw.height / 2 - 2 * border + cg.x = workarea.x_min + cg.y = workarea.y_min + elseif where == "bottomright" then + cg.width = sw.width / 2 - 2 * border + cg.height = sw.height / 2 - 2 * border + cg.x = workarea.x_max - cg.width + cg.y = workarea.y_max - cg.height + elseif where == "bottomleft" then + cg.width = sw.width / 2 - 2 * border + cg.height = sw.height / 2 - 2 * border + cg.x = workarea.x_min + cg.y = workarea.y_max - cg.height + elseif where == "center" then + awful.placement.centered(c) + return + elseif where == nil then + c:struts(cs) c:geometry(cg) - awful.placement.no_offscreen(c) return + end + c.floating = true + if c.maximized then + c.maximized = false + end + c:geometry(cg) + awful.placement.no_offscreen(c) + return end diff --git a/modules/tabbar.lua b/modules/tabbar.lua index 0f2bc63..6da26ad 100644 --- a/modules/tabbar.lua +++ b/modules/tabbar.lua @@ -1,69 +1,68 @@ --- _______ __ ______ --- |_ _|.---.-.| |--. | __ \.---.-.----. --- | | | _ || _ | | __ <| _ | _| --- |___| |___._||_____| |______/|___._|__| --- +---------------------------------------------------------------+ --- NOTE: Thanks again to our friends at bling, this is a stripped down version of the pure theme for the tab bar from that widget library which I also took the liberty of commenting out more thoroughly and adapting to my specific needs, which is also explained in comments +-- NOTE: Thanks again to our friends at bling, this is a stripped down, +-- documented version of the pure theme for the tab bar from that widget +-- library which I also took the liberty of commenting out more thoroughly +-- and adapting to my specific needs, which is also explained in comments + --- +---------------------------------------------------------------+ -- Define variables for colors and styles -local bg_normal = beautiful.titlebar_back -local fg_normal = beautiful.lesswhite -local bg_focus = beautiful.titlebar_back_focus -local fg_focus = beautiful.fg_focus -local bg_focus_inactive = beautiful.tabbar_bg_focus_inactive or bg_focus -local fg_focus_inactive = beautiful.tabbar_fg_focus_inactive or fg_focus -local bg_normal_inactive = beautiful.tabbar_bg_normal_inactive or bg_normal -local fg_normal_inactive = beautiful.tabbar_fg_normal_inactive or fg_normal -local font = beautiful.font -local size = dpi(28) -local position = beautiful.tabbar_position or "top" +local bg_normal = beautiful.titlebar_back -- Set the normal background color +local fg_normal = beautiful.lesswhite -- Set the normal foreground color +local bg_focus = beautiful.titlebar_back_focus -- Set the focused background color +local fg_focus = beautiful.fg_focus -- Set the focused foreground color +local bg_focus_inactive = beautiful.tabbar_bg_focus_inactive or bg_focus -- Set the focused inactive background color +local fg_focus_inactive = beautiful.tabbar_fg_focus_inactive or fg_focus -- Set the focused inactive foreground color +local bg_normal_inactive = beautiful.tabbar_bg_normal_inactive or bg_normal -- Set the normal inactive background color +local fg_normal_inactive = beautiful.tabbar_fg_normal_inactive or fg_normal -- Set the normal inactive foreground color +local font = beautiful.font -- Set the font +local size = dpi(28) -- Set the size +local position = beautiful.tabbar_position or "top" -- Set the position to default to "top" if not specified + --- +---------------------------------------------------------------+ -- Create the tabbar widget for a given client -- NOTE: the tabbar is essentially just a second titlebar and thus is arranged the same way ultimately. local function create(c, focused_bool, buttons) local bg_temp, fg_temp - if focused_bool then - bg_temp = bg_focus - fg_temp = fg_focus + if focused_bool then -- Check if the client is focused + bg_temp = bg_focus -- Set the background color to focused color + fg_temp = fg_focus -- Set the foreground color to focused color else - bg_temp = bg_normal - fg_temp = fg_normal + bg_temp = bg_normal -- Set the background color to normal color + fg_temp = fg_normal -- Set the foreground color to normal color end + -- Create the tabbar widget local wid_temp = wibox.widget({ { { -- Left - wibox.widget.base.make_widget(awful.titlebar.widget.iconwidget(c)), - buttons = buttons, - layout = wibox.layout.fixed.horizontal, + wibox.widget.base.make_widget(awful.titlebar.widget.iconwidget(c)), -- Create the icon widget + buttons = buttons, -- Set the buttons + layout = wibox.layout.fixed.horizontal, -- Set the layout to fixed horizontal }, { -- Title - wibox.widget.base.make_widget(awful.titlebar.widget.titlewidget(c)), - buttons = buttons, - widget = wibox.container.place, + wibox.widget.base.make_widget(awful.titlebar.widget.titlewidget(c)), -- Create the title widget + buttons = buttons, -- Set the buttons + widget = wibox.container.place, -- Set the widget to container place }, { -- Right nil, -- I have no need for buttons I have already on the titlebar here, so nil to keep the layout in order - layout = wibox.layout.fixed.horizontal, + layout = wibox.layout.fixed.horizontal, -- Set the layout to fixed horizontal }, - layout = wibox.layout.align.horizontal, + layout = wibox.layout.align.horizontal, -- Set the layout to align horizontally }, - bg = bg_temp, - fg = fg_temp, - widget = wibox.container.background, + bg = bg_temp, -- Set the background color + fg = fg_temp, -- Set the foreground color + widget = wibox.container.background, -- Set the widget to container background }) - return wid_temp + return wid_temp -- Return the created tabbar widget end -- Return the configuration table return { - layout = wibox.layout.flex.horizontal, - create = create, - position = position, - size = size, - bg_normal = bg_normal, - bg_focus = bg_focus, + layout = wibox.layout.flex.horizontal, -- Set the layout to flex horizontal + create = create, -- Set the create function + position = position, -- Set the position + size = size, -- Set the size + bg_normal = bg_normal, -- Set the normal background color + bg_focus = bg_focus, -- Set the focused background color } diff --git a/rc.lua b/rc.lua index 8b8b893..e78e4a4 100644 --- a/rc.lua +++ b/rc.lua @@ -1,15 +1,16 @@ --- +---------------------------------------------------------------+ --- .---.-.--.--.--.-----.-----.-----.--------.-----. --- | _ | | | | -__|__ --| _ | | -__| --- |___._|________|_____|_____|_____|__|__|__|_____| --- +---------------------------------------------------------------+ +-- ┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ +-- ╏ ╏ +-- ╏ AwesomeWM configuration file ╏ +-- ╏ ╏ +-- ┗╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┛ -- central point from top to bottom, order matters. nice and clean just like I prefer --- +---------------------------------------------------------------+ +-- NOTE: See sub-directory README files for more info on their contents + +-- ───────────────────────────────────────────────────────────────── -- if luarocks exists load it, if not don't trip pcall(require, "luarocks.loader") --- +---------------------------------------------------------------+ --- NOTE: See sub-directory README files for more info on their contents --- +---------------------------------------------------------------+ + +-- ───────────────────────────────────────────────────────────────── -- The theme files and variables bound to the `beautiful.` namespace require("themes") -- Helper functions at the `utilities.` namespace @@ -17,7 +18,7 @@ require("utilities") -- Locally-derived back-end functionality require("modules") -- Settings of various builtin options -require("configuration") -- NOTE: this is where the globally scoped variables are derived +require("configuration") -- NOTE: this is where the globally scoped variables are derived from -- Event watching functionality require("signal") -- UI elements (widgets) that the user interacts with diff --git a/signal/client/init.lua b/signal/client/init.lua index b2936cc..5be3571 100644 --- a/signal/client/init.lua +++ b/signal/client/init.lua @@ -1,17 +1,16 @@ require("awful.autofocus") client.connect_signal("request::manage", function(c) - if c.floating then - awful.placement.centered(c, { - honor_workarea = true, - honor_padding = true, - margins = beautiful.useless_gap * 2, - shape = utilities.widgets.mkroundedrect(), - }) - end + if c.floating then + awful.placement.centered(c, { + honor_workarea = true, + honor_padding = true, + margins = beautiful.useless_gap * 2, + shape = utilities.graphics.mkroundedrect(), + }) + end end) client.connect_signal("mouse::enter", function(c) c:emit_signal("request::activate", "mouse_enter", { raise = false }) end) - diff --git a/themes/theme.lua b/themes/theme.lua index 684c25d..1aab534 100755 --- a/themes/theme.lua +++ b/themes/theme.lua @@ -137,7 +137,7 @@ theme.taglist_bg_focus = theme.widget_back_focus_tag theme.taglist_bg_occupied = theme.widget_back theme.taglist_font = "awesomewm-font Regular 13" -theme.taglist_shape = require("utilities.widgets.mkroundedrect")() +theme.taglist_shape = require("utilities.graphics.mkroundedrect")() theme.taglist_spacing = dpi(5) theme.taglist_shape_border_color = theme.grey .. "cc" theme.taglist_shape_border_width = dpi(1) diff --git a/ui/bar/init.lua b/ui/bar/init.lua index 30f69a1..fc660ed 100644 --- a/ui/bar/init.lua +++ b/ui/bar/init.lua @@ -17,458 +17,456 @@ require("ui.popups.notification_center") -- -------------------------------------------------------------------------- -- -- assign to each screen screen.connect_signal("request::desktop_decoration", function(s) - -- -------------------------------------------------------------------------- -- - -- tags -- - -- -------------------------------------------------------------------------- -- - -- - awful.tag({ "A", "W", "E", "S", "O", "M", "E" }, s, awful.layout.layouts[1]) - local get_tags = require("ui.bar.widgets.tags") - local taglist = get_tags.new({ - screen = s, - taglist = { - buttons = { - 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), - }, + -- -------------------------------------------------------------------------- -- + -- tags -- + -- -------------------------------------------------------------------------- -- + -- + awful.tag({ "A", "W", "E", "S", "O", "M", "E" }, s, awful.layout.layouts[1]) + local get_tags = require("ui.bar.widgets.tags") + local taglist = get_tags.new({ + screen = s, + taglist = { + buttons = { + 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), + }, + }, + tasklist = { + buttons = { + + awful.button({}, 1, function(c) + if c ~= nil then + if not c:isvisible() and c.first_tag then + c.first_tag:view_only() + end + c:emit_signal("request::activate") + c:raise() + c.minimized = false + end + end), + awful.button({}, 3, function(c) + c:activate({ context = "titlebar", action = "mouse_resize" }) + end), + }, + }, + }) + + -- -------------------------------------------------------------------------- -- + -- launcher -- + -- -------------------------------------------------------------------------- -- + -- + local launcher = utilities.interaction.mkbtn({ + image = icons.home, + screen = s, + forced_height = dpi(28), + forced_width = dpi(28), + bg = beautiful.widget_back, + halign = "center", + valign = "center", + widget = wibox.widget.imagebox, + }, beautiful.widget_back, beautiful.widget_back_focus) + + local launcher_tooltip = utilities.interaction.make_popup_tooltip( + "Left Click to Search Applications; Right Click for Notifications", + function(d) + return awful.placement.bottom_left(d, { + margins = { + bottom = beautiful.bar_height + beautiful.useless_gap * 2, + left = beautiful.useless_gap * 2, }, - tasklist = { - buttons = { - - awful.button({}, 1, function(c) - if c ~= nil then - if not c:isvisible() and c.first_tag then - c.first_tag:view_only() - end - c:emit_signal("request::activate") - c:raise() - c.minimized = false - end - end), - awful.button({}, 3, function(c) - c:activate({ context = "titlebar", action = "mouse_resize" }) - end), - }, + }) + end + ) + + launcher_tooltip.attach_to_object(launcher) + + launcher:add_button(awful.button({}, 1, function() + launcher_tooltip.hide() + awesome.emit_signal("toggle::launcher") + end)) + launcher:add_button(awful.button({}, 3, function() + launcher_tooltip.hide() + no_toggle(s) + end)) + + -- -------------------------------------------------------------------------- -- + -- systray -- + -- -------------------------------------------------------------------------- -- + -- + local tray_dispatcher = wibox.widget({ + image = icons.arrow_up, + forced_height = dpi(15), + forced_width = dpi(15), + valign = "center", + halign = "center", + widget = wibox.widget.imagebox, + }) + + local tray_dispatcher_tooltip = utilities.interaction.make_popup_tooltip( + "Press to toggle the systray panel", + function(d) + return awful.placement.bottom_right(d, { + margins = { + bottom = beautiful.bar_height + beautiful.useless_gap * 2, + right = beautiful.useless_gap * 33, }, - }) + }) + end + ) - -- -------------------------------------------------------------------------- -- - -- launcher -- - -- -------------------------------------------------------------------------- -- - -- - local launcher = utilities.widgets.mkbtn({ - image = icons.home, - screen = s, - forced_height = dpi(28), - forced_width = dpi(28), - bg = beautiful.widget_back, - halign = "center", - valign = "center", - widget = wibox.widget.imagebox, - }, beautiful.widget_back, beautiful.widget_back_focus) - - local launcher_tooltip = utilities.widgets.make_popup_tooltip( - "Left Click to Search Applications; Right Click for Notifications", - function(d) - return awful.placement.bottom_left(d, { - margins = { - bottom = beautiful.bar_height + beautiful.useless_gap * 2, - left = beautiful.useless_gap * 2, - }, - }) - end - ) - - launcher_tooltip.attach_to_object(launcher) - - launcher:add_button(awful.button({}, 1, function() - launcher_tooltip.hide() - awesome.emit_signal("toggle::launcher") - end)) - launcher:add_button(awful.button({}, 3, function() - launcher_tooltip.hide() - no_toggle(s) - end)) - - -- -------------------------------------------------------------------------- -- - -- systray -- - -- -------------------------------------------------------------------------- -- - -- - local tray_dispatcher = wibox.widget({ - image = icons.arrow_up, - forced_height = dpi(15), - forced_width = dpi(15), - valign = "center", - halign = "center", - widget = wibox.widget.imagebox, - }) + tray_dispatcher:add_button(awful.button({}, 1, function() + awesome.emit_signal("tray::toggle") + tray_dispatcher_tooltip.hide() - local tray_dispatcher_tooltip = utilities.widgets.make_popup_tooltip( - "Press to toggle the systray panel", - function(d) - return awful.placement.bottom_right(d, { - margins = { - bottom = beautiful.bar_height + beautiful.useless_gap * 2, - right = beautiful.useless_gap * 33, - }, - }) - end - ) - - tray_dispatcher:add_button(awful.button({}, 1, function() - awesome.emit_signal("tray::toggle") - tray_dispatcher_tooltip.hide() - - if s.tray.popup.visible then - tray_dispatcher.image = icons.arrow_down - else - tray_dispatcher.image = icons.arrow_up - end - end)) - - tray_dispatcher_tooltip.attach_to_object(tray_dispatcher) - -- -------------------------------------------------------------------------- -- - -- action buttons -- - -- -------------------------------------------------------------------------- -- - -- make screenshot action icon global to edit it in anothers contexts. - s.myscreenshot_action_icon = get_screenshot_icon(s) - local actions_icons_container = utilities.widgets.mkbtn({ - { - network, - volume, - s.myscreenshot_action_icon, - spacing = dpi(4), - layout = wibox.layout.fixed.horizontal, - }, - left = dpi(5), - right = dpi(5), + if s.tray.popup.visible then + tray_dispatcher.image = icons.arrow_down + else + tray_dispatcher.image = icons.arrow_up + end + end)) + + tray_dispatcher_tooltip.attach_to_object(tray_dispatcher) + -- -------------------------------------------------------------------------- -- + -- action buttons -- + -- -------------------------------------------------------------------------- -- + -- make screenshot action icon global to edit it in anothers contexts. + s.myscreenshot_action_icon = get_screenshot_icon(s) + local actions_icons_container = utilities.interaction.mkbtn({ + { + network, + volume, + s.myscreenshot_action_icon, + spacing = dpi(4), + layout = wibox.layout.fixed.horizontal, + }, + left = dpi(5), + right = dpi(5), + widget = wibox.container.margin, + }, beautiful.widget_back, beautiful.widget_back_focus) + + -- -------------------------------------------------------------------------- -- + -- clock -- + -- -------------------------------------------------------------------------- -- + local clock_formats = { hour = "%H:%M", day = "%d/%m/%Y" } + + local clock = wibox.widget({ + format = clock_formats.hour, + font = beautiful.title_font, + widget = wibox.widget.textclock, + }) + + local date = wibox.widget({ + { + { widget = wibox.container.margin, - }, beautiful.widget_back, beautiful.widget_back_focus) - - -- -------------------------------------------------------------------------- -- - -- clock -- - -- -------------------------------------------------------------------------- -- - local clock_formats = { hour = "%H:%M", day = "%d/%m/%Y" } - - local clock = wibox.widget({ - format = clock_formats.hour, - font = beautiful.title_font, - widget = wibox.widget.textclock, - }) - - local date = wibox.widget({ - { - { - widget = wibox.container.margin, - left = dpi(15), - right = dpi(15), - clock, - }, - fg = beautiful.fg_normal, - bg = beautiful.widget_back, - border_width = 0.75, - border_color = beautiful.grey, - widget = wibox.container.background, - shape = utilities.widgets.mkroundedrect(), + left = dpi(15), + right = dpi(15), + clock, + }, + fg = beautiful.fg_normal, + bg = beautiful.widget_back, + border_width = 0.75, + border_color = beautiful.grey, + widget = wibox.container.background, + shape = utilities.graphics.mkroundedrect(), + }, + left = dpi(3), + right = dpi(3), + widget = wibox.container.margin, + }) + + date:connect_signal("mouse::enter", function() + awesome.emit_signal("calendar::visibility", true) + end) + + date:connect_signal("mouse::leave", function() + awesome.emit_signal("calendar::visibility", false) + end) + + date:add_button(awful.button({}, 1, function() + clock.format = clock.format == clock_formats.hour and clock_formats.day + or clock_formats.hour + end)) + -- -------------------------------------------------------------------------- -- + -- layout box -- + -- -------------------------------------------------------------------------- -- + -- + local base_layoutbox = awful.widget.layoutbox({ + screen = s, + halign = "center", + valign = "center", + }) + + -- remove built-in tooltip. + base_layoutbox._layoutbox_tooltip:remove_from_object(base_layoutbox) + + -- create button container + local layoutbox = utilities.interaction.mkbtn({ + widget = wibox.container.margin, + left = dpi(5), + right = dpi(5), + base_layoutbox, + }, beautiful.widget_back, beautiful.widget_back_focus) + + -- capitalize the layout name for consistency + local function layoutname() + return "Layout: " .. utilities.textual.capitalize(awful.layout.get(s).name) + end + + -- make custom tooltip for the whole button + local layoutbox_tooltip = utilities.interaction.make_popup_tooltip( + layoutname(), + function(d) + return awful.placement.bottom_right(d, { + margins = { + bottom = beautiful.bar_height + beautiful.useless_gap * 2, + right = beautiful.useless_gap * 2, }, - left = dpi(3), - right = dpi(3), - widget = wibox.container.margin, - }) - - date:connect_signal("mouse::enter", function() - awesome.emit_signal("calendar::visibility", true) - end) - - date:connect_signal("mouse::leave", function() - awesome.emit_signal("calendar::visibility", false) - end) - - date:add_button(awful.button({}, 1, function() - clock.format = clock.format == clock_formats.hour and clock_formats.day - or clock_formats.hour - end)) - -- -------------------------------------------------------------------------- -- - -- layout box -- - -- -------------------------------------------------------------------------- -- - -- - local base_layoutbox = awful.widget.layoutbox({ - screen = s, - halign = "center", - valign = "center", - }) - - -- remove built-in tooltip. - base_layoutbox._layoutbox_tooltip:remove_from_object(base_layoutbox) - - -- create button container - local layoutbox = utilities.widgets.mkbtn({ - widget = wibox.container.margin, - left = dpi(5), - right = dpi(5), - base_layoutbox, - }, beautiful.widget_back, beautiful.widget_back_focus) - - -- capitalize the layout name for consistency - local function layoutname() - return "Layout: " - .. utilities.textual.capitalize(awful.layout.get(s).name) + }) end - - -- make custom tooltip for the whole button - local layoutbox_tooltip = utilities.widgets.make_popup_tooltip( - layoutname(), - function(d) - return awful.placement.bottom_right(d, { - margins = { - bottom = beautiful.bar_height + beautiful.useless_gap * 2, - right = beautiful.useless_gap * 2, - }, - }) - end - ) - - layoutbox_tooltip.attach_to_object(layoutbox) - - -- updates tooltip content - local update_content = function() - index = tag.index - old_index = 0 - if index ~= old_index then - layoutbox_tooltip.widget.text = layoutname() - naughty.notification({ - title = "Layout Changed", - text = "The current tag has had the client layout changed to the " - .. awful.layout.get(s).name - .. " layout.", - image = gfs.get_configuration_dir() - .. "themes/icons/svg/awesome.png", - }) - end - old_index = tag.index + ) + + layoutbox_tooltip.attach_to_object(layoutbox) + + -- updates tooltip content + local update_content = function() + index = tag.index + old_index = 0 + if index ~= old_index then + layoutbox_tooltip.widget.text = layoutname() + naughty.notification({ + title = "Layout Changed", + text = "The current tag has had the client layout changed to the " + .. awful.layout.get(s).name + .. " layout.", + image = gfs.get_configuration_dir() .. "themes/icons/svg/awesome.png", + }) end - tag.connect_signal("property::layout", update_content) - -- tag.connect_signal("property::selected", update_content) - - -- layoutbox buttons - utilities.widgets.add_buttons(layoutbox, { - awful.button({}, 1, function() - awesome.emit_signal("layout::changed:next") - end), - awful.button({}, 3, function() - awesome.emit_signal("layout::changed:prev") - end), + old_index = tag.index + end + tag.connect_signal("property::layout", update_content) + -- tag.connect_signal("property::selected", update_content) + + -- layoutbox buttons + utilities.interaction.add_buttons(layoutbox, { + awful.button({}, 1, function() + awesome.emit_signal("layout::changed:next") + end), + awful.button({}, 3, function() + awesome.emit_signal("layout::changed:prev") + end), + }) + + -- -------------------------------------------------------------------------- -- + -- widget templates -- + -- -------------------------------------------------------------------------- -- + -- + local function mkcontainer(template) + return wibox.widget({ + template, + left = dpi(8), + right = dpi(8), + top = dpi(6), + bottom = dpi(6), + widget = wibox.container.margin, }) + end + + s.mywibox = awful.wibar({ + honor_workarea = false, + honor_padding = false, + type = "dock", + position = "bottom", + stretch = false, + visible = false, + ontop = true, + opacity = 0.9, + screen = s, + bg = beautiful.bg_darkest .. "cc", + width = s.geometry.width, + height = beautiful.bar_height, + shape = gears.shape.rectangle, + }) + -- -------------------------------------------------------------------------- -- + -- setup -- + + s.mywibox:setup({ + { + layout = wibox.layout.align.horizontal, + { + { + mkcontainer({ + launcher, - -- -------------------------------------------------------------------------- -- - -- widget templates -- - -- -------------------------------------------------------------------------- -- - -- - local function mkcontainer(template) - return wibox.widget({ - template, - left = dpi(8), + spacing = dpi(12), + layout = wibox.layout.fixed.horizontal, + }), + widget = wibox.container.margin, + }, + layout = wibox.layout.fixed.horizontal, + }, + nil, + { + mkcontainer({ + { + tray_dispatcher, right = dpi(8), - top = dpi(6), - bottom = dpi(6), widget = wibox.container.margin, - }) - end - - s.mywibox = awful.wibar({ - honor_workarea = false, - honor_padding = false, - type = "dock", - position = "bottom", - stretch = false, - visible = false, - ontop = true, - opacity = 0.9, - screen = s, - bg = beautiful.bg_darkest .. "cc", - width = s.geometry.width, - height = beautiful.bar_height, - shape = gears.shape.rectangle, - }) - -- -------------------------------------------------------------------------- -- - -- setup -- - - s.mywibox:setup({ - { - layout = wibox.layout.align.horizontal, - { - { - mkcontainer({ - launcher, - - spacing = dpi(12), - layout = wibox.layout.fixed.horizontal, - }), - widget = wibox.container.margin, - }, - layout = wibox.layout.fixed.horizontal, - }, - nil, - { - mkcontainer({ - { - tray_dispatcher, - right = dpi(8), - widget = wibox.container.margin, - }, - battery_widget, - actions_icons_container, - date, - layoutbox, - spacing = dpi(8), - layout = wibox.layout.fixed.horizontal, - }), - layout = wibox.layout.fixed.horizontal, - }, - }, - { - mkcontainer({ taglist, layout = wibox.layout.fixed.horizontal }), - halign = "center", - widget = wibox.widget.margin, - layout = wibox.container.place, - }, - layout = wibox.layout.stack, - }) - s.mywibox:struts({ left = 0, right = 0, bottom = 0, top = 0 }) - - -- -------------------------------------------------------------------------- -- - -- - -- NOTE toggle function to make it disappear - -- - function bar_toggle() - if s.mywibox.visible == false then - awful.screen.connect_for_each_screen(function() - s.mywibox.visible = true - s.mywibox.status = true - s.activation_zone.visible = false - end) - elseif s.mywibox.visible == true then - awful.screen.connect_for_each_screen(function() - s.mywibox.visible = false - s.mywibox.status = false - s.activation_zone.visible = true - end) - end - end - - local hidden_y = awful.screen.focused().geometry.height - -- ------------------------------------------------- -- - -- NOTE setting its height - -- - local visible_y = awful.screen.focused().geometry.height - s.mywibox.height - -- ------------------------------------------------- -- - - -- NOTE defining the anotation - local animation = effects.instance.timed({ - pos = visible_y, - rate = 60, - intro = 0.14, - duration = 0.33, - subscribed = function(pos) - s.mywibox.y = pos - end, - }) - - -- ------------------------------------------------- -- - -- ------------ auto hide functionality ------------ -- - -- NOTE timer to close the bar - -- - s.detect = gears.timer({ - timeout = 2, - single_shot = true, - - callback = function() - animation.target = hidden_y - s.disable_wibar:start() - awesome.emit_signal("bar:false") - end, - }) - - s.disable_wibar = gears.timer({ - autostart = true, - timeout = 0.3, - callback = function() - s.mywibox.visible = false - s.mywibox.status = false - s.activation_zone.visible = true - s.detect:stop() - s.disable_wibar:stop() - end, - }) - - -- ------------------------------------------------- -- - -- NOTE shows the bar open - -- - s.enable_wibox = function() + }, + battery_widget, + actions_icons_container, + date, + layoutbox, + spacing = dpi(8), + layout = wibox.layout.fixed.horizontal, + }), + layout = wibox.layout.fixed.horizontal, + }, + }, + { + mkcontainer({ taglist, layout = wibox.layout.fixed.horizontal }), + halign = "center", + widget = wibox.widget.margin, + layout = wibox.container.place, + }, + layout = wibox.layout.stack, + }) + s.mywibox:struts({ left = 0, right = 0, bottom = 0, top = 0 }) + + -- -------------------------------------------------------------------------- -- + -- + -- NOTE toggle function to make it disappear + -- + function bar_toggle() + if s.mywibox.visible == false then + awful.screen.connect_for_each_screen(function() s.mywibox.visible = true + s.mywibox.status = true s.activation_zone.visible = false - animation.target = visible_y - awesome.emit_signal("bar:true") - s.detect:start() + end) + elseif s.mywibox.visible == true then + awful.screen.connect_for_each_screen(function() + s.mywibox.visible = false + s.mywibox.status = false + s.activation_zone.visible = true + end) end - -- ------------------------------------------------- -- - -- NOTE if the bar is not present, this is - -- - s.activation_zone = awful.wibar({ - x = s.mywibox.x, - y = s.geometry.height - dpi(1), - position = "bottom", - opacity = 0.0, - width = s.mywibox.width, - height = dpi(1), - screen = s, - input_passthrough = false, - visible = true, - ontop = true, - type = "dock", - }) - s.activation_zone:struts({ left = 0, right = 0, bottom = 0, top = 0 }) - - -- ------------------------------------------------- -- - -- NOTE when mouse moves to this bar, the other opens - -- - s.activation_zone:connect_signal("mouse::enter", function() - s.enable_wibox() - end) - -- ------------------------------------------------- -- - -- NOTE this keeps the bar open so long is the mouse is within its boundaries so the other can be hidden - -- - s.mywibox:connect_signal("mouse::enter", function() - s.detect:stop() - end) - -- ------------------------------------------------- -- - -- NOTE this keeps the bar open so long is the mouse is within its boundaries so the other can be hidden - -- - s.mywibox:connect_signal("button::press", function() - s.enable_wibox() - s.detect:stop() - end) - -- ------------------------------------------------- -- - -- NOTE this keeps the bar open so long is the mouse is within its boundaries so the other can be hidden - -- - s.mywibox:connect_signal("button::release", function() - s.enable_wibox() - s.detect:stop() - end) - -- ------------------------------------------------- -- - -- NOTE signals to begin timer when mouse leaves - -- - s.mywibox:connect_signal("mouse::leave", function() - s.detect:start() - end) - awesome.connect_signal("bar::toggle", function() - bar_toggle() - s.enable_wibox() - end) + end + + local hidden_y = awful.screen.focused().geometry.height + -- ------------------------------------------------- -- + -- NOTE setting its height + -- + local visible_y = awful.screen.focused().geometry.height - s.mywibox.height + -- ------------------------------------------------- -- + + -- NOTE defining the anotation + local animation = effects.instance.timed({ + pos = visible_y, + rate = 60, + intro = 0.14, + duration = 0.33, + subscribed = function(pos) + s.mywibox.y = pos + end, + }) + + -- ------------------------------------------------- -- + -- ------------ auto hide functionality ------------ -- + -- NOTE timer to close the bar + -- + s.detect = gears.timer({ + timeout = 2, + single_shot = true, + + callback = function() + animation.target = hidden_y + s.disable_wibar:start() + awesome.emit_signal("bar:false") + end, + }) + + s.disable_wibar = gears.timer({ + autostart = true, + timeout = 0.3, + callback = function() + s.mywibox.visible = false + s.mywibox.status = false + s.activation_zone.visible = true + s.detect:stop() + s.disable_wibar:stop() + end, + }) + + -- ------------------------------------------------- -- + -- NOTE shows the bar open + -- + s.enable_wibox = function() + s.mywibox.visible = true + s.activation_zone.visible = false + animation.target = visible_y + awesome.emit_signal("bar:true") + s.detect:start() + end + -- ------------------------------------------------- -- + -- NOTE if the bar is not present, this is + -- + s.activation_zone = awful.wibar({ + x = s.mywibox.x, + y = s.geometry.height - dpi(1), + position = "bottom", + opacity = 0.0, + width = s.mywibox.width, + height = dpi(1), + screen = s, + input_passthrough = false, + visible = true, + ontop = true, + type = "dock", + }) + s.activation_zone:struts({ left = 0, right = 0, bottom = 0, top = 0 }) + + -- ------------------------------------------------- -- + -- NOTE when mouse moves to this bar, the other opens + -- + s.activation_zone:connect_signal("mouse::enter", function() + s.enable_wibox() + end) + -- ------------------------------------------------- -- + -- NOTE this keeps the bar open so long is the mouse is within its boundaries so the other can be hidden + -- + s.mywibox:connect_signal("mouse::enter", function() + s.detect:stop() + end) + -- ------------------------------------------------- -- + -- NOTE this keeps the bar open so long is the mouse is within its boundaries so the other can be hidden + -- + s.mywibox:connect_signal("button::press", function() + s.enable_wibox() + s.detect:stop() + end) + -- ------------------------------------------------- -- + -- NOTE this keeps the bar open so long is the mouse is within its boundaries so the other can be hidden + -- + s.mywibox:connect_signal("button::release", function() + s.enable_wibox() + s.detect:stop() + end) + -- ------------------------------------------------- -- + -- NOTE signals to begin timer when mouse leaves + -- + s.mywibox:connect_signal("mouse::leave", function() + s.detect:start() + end) + awesome.connect_signal("bar::toggle", function() + bar_toggle() + s.enable_wibox() + end) end) diff --git a/ui/bar/widgets/actions-icons/network.lua b/ui/bar/widgets/actions-icons/network.lua index 6440879..3790777 100644 --- a/ui/bar/widgets/actions-icons/network.lua +++ b/ui/bar/widgets/actions-icons/network.lua @@ -7,36 +7,36 @@ local awful = require("awful") require("signal.system.network") local network = wibox.widget({ - widget = wibox.widget.imagebox, - image = icons.wifi_3, - align = "center", + widget = wibox.widget.imagebox, + image = icons.wifi_3, + align = "center", }) -local tooltip = utilities.widgets.make_popup_tooltip( - "Press to toggle network", - function(d) - return awful.placement.bottom_right(d, { - margins = { - bottom = beautiful.bar_height + beautiful.useless_gap * 2, - right = beautiful.useless_gap * 2 + 85, - }, - }) - end +local tooltip = utilities.interaction.make_popup_tooltip( + "Press to toggle network", + function(d) + return awful.placement.bottom_right(d, { + margins = { + bottom = beautiful.bar_height + beautiful.useless_gap * 2, + right = beautiful.useless_gap * 2 + 85, + }, + }) + end ) tooltip.attach_to_object(network) network:add_button(awful.button({}, 1, function() - nc_toggle() - awesome.emit_signal("network::networks:refreshPanel") + nc_toggle() + awesome.emit_signal("network::networks:refreshPanel") end)) awesome.connect_signal("network::connected", function() - network.image = icons.wifi_3 + network.image = icons.wifi_3 end) awesome.connect_signal("network::disconnected", function() - network.image = icons.wifi_off + network.image = icons.wifi_off end) return network diff --git a/ui/bar/widgets/actions-icons/screenshot.lua b/ui/bar/widgets/actions-icons/screenshot.lua index b6018cc..2fc30f6 100644 --- a/ui/bar/widgets/actions-icons/screenshot.lua +++ b/ui/bar/widgets/actions-icons/screenshot.lua @@ -17,7 +17,7 @@ require("ui.bar.widgets.actions-icons.widgets.screenshot-select") local function get_icon(s) local CAMERA_ICON = - gears.color.recolor_image(icons.camera, beautiful.fg_normal) + gears.color.recolor_image(icons.camera, beautiful.fg_normal) local icon = wibox.widget({ id = "screenshot_action_icon", @@ -26,13 +26,12 @@ local function get_icon(s) widget = wibox.widget.imagebox, }) - local tooltip = utilities.widgets.make_popup_tooltip( + local tooltip = utilities.interaction.make_popup_tooltip( "Press to take a screenshot", function(d) return awful.placement.bottom_right(d, { margins = { - bottom = beautiful.bar_height - + beautiful.useless_gap * 1.25, + bottom = beautiful.bar_height + beautiful.useless_gap * 1.25, right = beautiful.useless_gap * 2 + 85, }, }) @@ -46,10 +45,8 @@ local function get_icon(s) tooltip.toggle() if s.screenshot_selecter.popup.visible then - icon.image = gears.color.recolor_image( - icons.camera, - beautiful.bg_normal .. "66" - ) + icon.image = + gears.color.recolor_image(icons.camera, beautiful.bg_normal .. "66") awesome.emit_signal("screenshot::show") icon:emit_signal("widget::redraw_needed") else @@ -62,7 +59,7 @@ local function get_icon(s) awesome.connect_signal("screenshot::show", function() icon.image = - gears.color.recolor_image(icons.camera, beautiful.bg_normal .. "66") + gears.color.recolor_image(icons.camera, beautiful.bg_normal .. "66") s.screenshot_selecter.popup.visible = true end) diff --git a/ui/bar/widgets/actions-icons/volume.lua b/ui/bar/widgets/actions-icons/volume.lua index 9653eb9..a731c3a 100644 --- a/ui/bar/widgets/actions-icons/volume.lua +++ b/ui/bar/widgets/actions-icons/volume.lua @@ -13,7 +13,7 @@ local volume = wibox.widget({ valign = "bottom", }) -local tooltip = utilities.widgets.make_popup_tooltip( +local tooltip = utilities.interaction.make_popup_tooltip( "Press to mute/unmute", function(d) return awful.placement.bottom_right(d, { diff --git a/ui/bar/widgets/actions-icons/widgets/record.lua b/ui/bar/widgets/actions-icons/widgets/record.lua index 38a594a..ca8495f 100644 --- a/ui/bar/widgets/actions-icons/widgets/record.lua +++ b/ui/bar/widgets/actions-icons/widgets/record.lua @@ -51,7 +51,7 @@ local createButton = function(icon, name, fn, col) }, bg = beautiful.widget_back, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), widget = wibox.container.background, border_color = beautiful.grey, border_width = dpi(1), @@ -59,14 +59,14 @@ local createButton = function(icon, name, fn, col) fn() end), }) - utilities.widgets.add_hover( + utilities.interaction.add_hover( button, beautiful.widget_back, beautiful.widget_back_focus_tag ) local tooltip = - utilities.widgets.make_popup_tooltip(name, awful.placement.centered()) + utilities.interaction.make_popup_tooltip(name, awful.placement.centered()) tooltip.attach_to_object(button) return button end @@ -75,7 +75,7 @@ awful.screen.connect_for_each_screen(function(s) local recorder = wibox({ width = dpi(220), height = dpi(100), - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), bg = beautiful.bg_normal .. "66", border_width = dpi(1), border_color = beautiful.grey .. "cc", diff --git a/ui/bar/widgets/actions-icons/widgets/screenshot-select.lua b/ui/bar/widgets/actions-icons/widgets/screenshot-select.lua index 0d39ef3..63513d9 100644 --- a/ui/bar/widgets/actions-icons/widgets/screenshot-select.lua +++ b/ui/bar/widgets/actions-icons/widgets/screenshot-select.lua @@ -28,7 +28,7 @@ awful.screen.connect_for_each_screen(function(s) widget = wibox.container.margin, }, bg = beautiful.widget_back, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), widget = wibox.container.background, border_color = beautiful.grey, border_width = dpi(1), @@ -36,13 +36,13 @@ awful.screen.connect_for_each_screen(function(s) -- -------------------------------------------------------------------------- -- -- add hover effects, onclick listener and tooltips -- - utilities.widgets.add_hover( + utilities.interaction.add_hover( button, beautiful.widget_back, beautiful.widget_back_focus_tag ) - local tooltip = utilities.widgets.make_popup_tooltip( + local tooltip = utilities.interaction.make_popup_tooltip( tooltip_opts.txt, tooltip_opts.placement ) @@ -172,7 +172,7 @@ awful.screen.connect_for_each_screen(function(s) margins = dpi(7), widget = wibox.container.margin, }, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), widget = wibox.container.background, }) -- -------------------------------------------------------------------------- -- @@ -194,7 +194,7 @@ awful.screen.connect_for_each_screen(function(s) border_color = beautiful.grey .. "88", border_width = dpi(1), type = "combo", - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), visible = false, screen = s, maximum_width = dpi(240), diff --git a/ui/bar/widgets/battery.lua b/ui/bar/widgets/battery.lua index fe96f12..11d2dbe 100755 --- a/ui/bar/widgets/battery.lua +++ b/ui/bar/widgets/battery.lua @@ -113,7 +113,7 @@ gears.timer({ }) -- return widget -local battery_button = utilities.widgets.mkbtn({ +local battery_button = utilities.interaction.mkbtn({ { wibox.widget({ baticon, @@ -141,7 +141,7 @@ local battery_button = utilities.widgets.mkbtn({ border_width = dpi(1.25), widget = wibox.container.background, bg = beautiful.widget_back, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), }, left = dpi(3), right = dpi(2), @@ -159,9 +159,9 @@ local battery_tooltip = awful.tooltip({ align = "right", margin_leftright = dpi(18), margin_topbottom = dpi(18), - shape = utilities.widgets.mkroundedrect(), - bg = beautiful.bg_normal .. '88', - border_color= beautiful.lesswhite .. '88', + shape = utilities.graphics.mkroundedrect(), + bg = beautiful.bg_normal .. "88", + border_color = beautiful.lesswhite .. "88", border_width = dpi(2), preferred_positions = { "right", "left", "top", "bottom" }, }) diff --git a/ui/bar/widgets/calendar.lua b/ui/bar/widgets/calendar.lua index 79100b6..7672b88 100644 --- a/ui/bar/widgets/calendar.lua +++ b/ui/bar/widgets/calendar.lua @@ -61,7 +61,7 @@ awful.screen.connect_for_each_screen(function(s) border_color = flag == "focus" and beautiful.lessgrey .. "cc" or beautiful.bg_normal .. "00", widget = wibox.container.background, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), }) end, }) @@ -81,7 +81,7 @@ awful.screen.connect_for_each_screen(function(s) }, }) end, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), screen = s, widget = s.calendar.calendar, }) diff --git a/ui/bar/widgets/tray.lua b/ui/bar/widgets/tray.lua index 7a0289e..18901f3 100644 --- a/ui/bar/widgets/tray.lua +++ b/ui/bar/widgets/tray.lua @@ -2,85 +2,85 @@ -- listens for requests to open/hide the systray popup in the focused screen ofc. local function get_tray() - return awful.screen.focused().tray + return awful.screen.focused().tray end awesome.connect_signal("tray::toggle", function() - get_tray().toggle() + get_tray().toggle() end) awesome.connect_signal("tray::visibility", function(v) - if v then - get_tray().show() - else - get_tray().hide() - end + if v then + get_tray().show() + else + get_tray().hide() + end end) awful.screen.connect_for_each_screen(function(s) - s.tray = {} + s.tray = {} - s.tray.widget = wibox.widget({ + s.tray.widget = wibox.widget({ + { + { { - { - { - { - widget = wibox.widget.systray, - horizontal = false, - screen = s, - base_size = 16, - }, - layout = wibox.layout.fixed.horizontal, - }, - margins = dpi(12), - widget = wibox.container.margin, - }, - bg = beautiful.bg_normal .. "55", - border_color = beautiful.grey .. "cc", - border_width = dpi(1), - fg = beautiful.fg_normal, - widget = wibox.container.background, - shape = utilities.widgets.mkroundedrect(), + { + widget = wibox.widget.systray, + horizontal = false, + screen = s, + base_size = 16, + }, + layout = wibox.layout.fixed.horizontal, }, + margins = dpi(12), widget = wibox.container.margin, - margins = dpi(3), - }) + }, + bg = beautiful.bg_normal .. "55", + border_color = beautiful.grey .. "cc", + border_width = dpi(1), + fg = beautiful.fg_normal, + widget = wibox.container.background, + shape = utilities.graphics.mkroundedrect(), + }, + widget = wibox.container.margin, + margins = dpi(3), + }) - s.tray.popup = awful.popup({ - widget = s.tray.widget, - screen = s, - visible = false, - ontop = true, - bg = beautiful.bg_normal .. "00", - fg = beautiful.fg_normal, - minimum_width = dpi(200), - minimum_height = dpi(120), - shape = utilities.widgets.mkroundedrect(), - placement = function(d) - return awful.placement.bottom_right(d, { - margins = { - right = beautiful.useless_gap * 37, - bottom = beautiful.bar_height + beautiful.useless_gap * 2, - }, - }) - end, - }) + s.tray.popup = awful.popup({ + widget = s.tray.widget, + screen = s, + visible = false, + ontop = true, + bg = beautiful.bg_normal .. "00", + fg = beautiful.fg_normal, + minimum_width = dpi(200), + minimum_height = dpi(120), + shape = utilities.graphics.mkroundedrect(), + placement = function(d) + return awful.placement.bottom_right(d, { + margins = { + right = beautiful.useless_gap * 37, + bottom = beautiful.bar_height + beautiful.useless_gap * 2, + }, + }) + end, + }) - local self, tray = s.tray.popup, s.tray + local self, tray = s.tray.popup, s.tray - function tray.toggle() - if self.visible then - tray.hide() - else - tray.show() - end + function tray.toggle() + if self.visible then + tray.hide() + else + tray.show() end + end - function tray.show() - self.visible = true - end + function tray.show() + self.visible = true + end - function tray.hide() - self.visible = false - end + function tray.hide() + self.visible = false + end end) diff --git a/ui/launcher/charts.lua b/ui/launcher/charts.lua index 4be8b0c..7b3cd21 100644 --- a/ui/launcher/charts.lua +++ b/ui/launcher/charts.lua @@ -24,7 +24,7 @@ local function mkcard(label, widget) margins = dpi(5), widget = wibox.container.margin, }, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), bg = beautiful.bg_contrast .. "00", -- border_color = beautiful.grey, -- border_width = dpi(0.75), @@ -46,19 +46,19 @@ local function base_chart(icon) direction = "south", widget = wibox.container.rotate, }, - margins = dpi(2), + margins = dpi(8), widget = wibox.container.margin, }, id = "chart", value = 0, max_value = 1, min_value = 0, - forced_height = dpi(48), - forced_width = dpi(48), + forced_height = dpi(64), + forced_width = dpi(64), widget = wibox.container.arcchart, color = beautiful.chart_arc, border_width = dpi(0), - thickness = dpi(3), + thickness = dpi(6), bg = beautiful.dark_grey .. "cc", }, direction = "south", diff --git a/ui/launcher/init.lua b/ui/launcher/init.lua index 87ed0d0..820edd4 100644 --- a/ui/launcher/init.lua +++ b/ui/launcher/init.lua @@ -7,7 +7,7 @@ local dpi = beautiful.xresources.apply_dpi awful.screen.connect_for_each_screen(function(s) local launcherdisplay = wibox({ width = dpi(440), - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), height = dpi(720), bg = beautiful.bg_normal .. "66", border_color = beautiful.grey .. "cc", @@ -55,7 +55,7 @@ awful.screen.connect_for_each_screen(function(s) border_width = dpi(2), border_color = beautiful.grey .. "cc", forced_height = dpi(50), - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), }, widget = wibox.container.margin, layout = wibox.layout.fixed.vertical, @@ -125,7 +125,7 @@ awful.screen.connect_for_each_screen(function(s) prompt, widget = wibox.container.margin, margins = dpi(10), - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), }, widget = wibox.container.background, @@ -227,7 +227,7 @@ awful.screen.connect_for_each_screen(function(s) { { image = entry.icon, - clip_shape = utilities.widgets.mkroundedrect(), + clip_shape = utilities.graphics.mkroundedrect(), forced_height = dpi(48), forced_width = dpi(48), valign = "center", @@ -250,7 +250,7 @@ awful.screen.connect_for_each_screen(function(s) forced_width = dpi(360), forced_height = dpi(60), border_color = beautiful.grey .. "88", - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), border_width = dpi(2), widget = wibox.container.background, bg = beautiful.bg_contrast .. "22", diff --git a/ui/launcher/powermenu_containers/lock.lua b/ui/launcher/powermenu_containers/lock.lua index 4bace0a..8a9a427 100644 --- a/ui/launcher/powermenu_containers/lock.lua +++ b/ui/launcher/powermenu_containers/lock.lua @@ -5,56 +5,54 @@ -- +---------------------------------------------------------------+ -- confirmation dialog local function do_notify() - local confirm = naughty.action({ name = "Confirm" }) - local cancel = naughty.action({ name = "Cancel" }) - -- +---------------------------------------------------------------+ - -- copy to clipboard button - confirm:connect_signal("invoked", function() - awful.spawn("dm-tool lock") - end) - -- +---------------------------------------------------------------+ - -- delete - cancel:connect_signal("invoked", function() - return - end) - -- +---------------------------------------------------------------+ - -- Show the notification. - naughty.notify({ - app_name = "Confirmation", - app_icon = icons.power, - icon = icons.lock, - ontop = true, - position = "top_middle", - title = "Please Confirm You Want to Lock the Screen", - text = "Please Confirm You Would Like to Lock the Screen by Pressing Confirm Below", - actions = { confirm, cancel }, - }) + local confirm = naughty.action({ name = "Confirm" }) + local cancel = naughty.action({ name = "Cancel" }) + -- +---------------------------------------------------------------+ + -- copy to clipboard button + confirm:connect_signal("invoked", function() + awful.spawn("dm-tool lock") + end) + -- +---------------------------------------------------------------+ + -- delete + cancel:connect_signal("invoked", function() + return + end) + -- +---------------------------------------------------------------+ + -- Show the notification. + naughty.notify({ + app_name = "Confirmation", + app_icon = icons.power, + icon = icons.lock, + ontop = true, + position = "top_middle", + title = "Please Confirm You Want to Lock the Screen", + text = "Please Confirm You Would Like to Lock the Screen by Pressing Confirm Below", + actions = { confirm, cancel }, + }) end -- +---------------------------------------------------------------+ -- lock button -Lock = utilities.widgets.mkbtn({ +Lock = utilities.interaction.mkbtn({ + { { - { - widget = wibox.widget.imagebox, - image = icons.lock, - resize = true, - opacity = 1, - }, - left = dpi(5), - right = dpi(5), - top = dpi(5), - bottom = dpi(5), - widget = wibox.container.margin, + widget = wibox.widget.imagebox, + image = icons.lock, + resize = true, + opacity = 1, }, - bg = beautiful.widget_bg, - shape = utilities.widgets.mkroundedrect(), - widget = wibox.container.background, + valign = "center", + halign = "center", + layout = wibox.container.place, + }, + bg = beautiful.widget_bg, + shape = utilities.graphics.mkroundedrect(), + widget = wibox.container.background, - forced_height = dpi(48), - forced_width = dpi(48), + forced_height = dpi(48), + forced_width = dpi(48), }, beautiful.widget_back, beautiful.widget_back_focus) Lock:connect_signal("button::press", function() - do_notify() + do_notify() end) return Lock diff --git a/ui/launcher/powermenu_containers/logout.lua b/ui/launcher/powermenu_containers/logout.lua index 9c493eb..3b07bb3 100644 --- a/ui/launcher/powermenu_containers/logout.lua +++ b/ui/launcher/powermenu_containers/logout.lua @@ -1,53 +1,51 @@ -- +---------------------------------------------------------------+ local function do_notify() - local confirm = naughty.action({ name = "Confirm" }) - local cancel = naughty.action({ name = "Cancel" }) - -- +---------------------------------------------------------------+ - -- copy to clipboard button - confirm:connect_signal("invoked", function() - awful.spawn("doas systemctl restart display-manager") - end) - -- +---------------------------------------------------------------+ - -- delete - cancel:connect_signal("invoked", function() - return - end) - -- +---------------------------------------------------------------+ - -- Show the notification. - naughty.notify({ - app_name = "Confirmation", - app_icon = icons.power, - position = "top_middle", - ontop = true, - icon = icons.logout, - title = "Please Confirm You Want to Log Out", - text = "Please Confirm You Would Like to Log Out by Pressing Confirm Below", - actions = { confirm, cancel }, - }) + local confirm = naughty.action({ name = "Confirm" }) + local cancel = naughty.action({ name = "Cancel" }) + -- +---------------------------------------------------------------+ + -- copy to clipboard button + confirm:connect_signal("invoked", function() + awful.spawn("doas systemctl restart display-manager") + end) + -- +---------------------------------------------------------------+ + -- delete + cancel:connect_signal("invoked", function() + return + end) + -- +---------------------------------------------------------------+ + -- Show the notification. + naughty.notify({ + app_name = "Confirmation", + app_icon = icons.power, + position = "top_middle", + ontop = true, + icon = icons.logout, + title = "Please Confirm You Want to Log Out", + text = "Please Confirm You Would Like to Log Out by Pressing Confirm Below", + actions = { confirm, cancel }, + }) end -- +---------------------------------------------------------------+ -- log out button -Logout = utilities.widgets.mkbtn({ +Logout = utilities.interaction.mkbtn({ + { { - { - widget = wibox.widget.imagebox, - image = icons.logout, - resize = true, - opacity = 1, - }, - left = dpi(5), - right = dpi(5), - top = dpi(5), - bottom = dpi(5), - widget = wibox.container.margin, + widget = wibox.widget.imagebox, + image = icons.logout, + resize = true, + opacity = 1, }, + valign = "center", + halign = "center", + layout = wibox.container.place, + }, - shape = utilities.widgets.mkroundedrect(), - widget = wibox.container.background, - forced_height = dpi(48), - forced_width = dpi(48), + shape = utilities.graphics.mkroundedrect(), + widget = wibox.container.background, + forced_height = dpi(48), + forced_width = dpi(48), }, beautiful.widget_back, beautiful.widget_back_focus) Logout:connect_signal("button::press", function() - do_notify() + do_notify() end) return Logout diff --git a/ui/launcher/powermenu_containers/restart.lua b/ui/launcher/powermenu_containers/restart.lua index 8a3883b..1b1fb75 100644 --- a/ui/launcher/powermenu_containers/restart.lua +++ b/ui/launcher/powermenu_containers/restart.lua @@ -1,50 +1,48 @@ local function do_notify() - local confirm = naughty.action({ name = "Confirm" }) - local cancel = naughty.action({ name = "Cancel" }) - -- -------------------------------------------------------------------------- -- - -- copy to clipboard button - confirm:connect_signal("invoked", function() - awful.spawn("doas systemctl reboot") - end) - -- -------------------------------------------------------------------------- -- - -- delete - cancel:connect_signal("invoked", function() - return - end) - -- -------------------------------------------------------------------------- -- - -- Show the notification. - naughty.notify({ - app_name = "Confirmation", - app_icon = icons.power, - position = "top_middle", - icon = icons.restart, - ontop = true, - title = "Please Confirm You Want to Reboot", - text = "Please Confirm You Would Like to Reboot by Pressing Confirm Below", - actions = { confirm, cancel }, - }) + local confirm = naughty.action({ name = "Confirm" }) + local cancel = naughty.action({ name = "Cancel" }) + -- -------------------------------------------------------------------------- -- + -- copy to clipboard button + confirm:connect_signal("invoked", function() + awful.spawn("doas systemctl reboot") + end) + -- -------------------------------------------------------------------------- -- + -- delete + cancel:connect_signal("invoked", function() + return + end) + -- -------------------------------------------------------------------------- -- + -- Show the notification. + naughty.notify({ + app_name = "Confirmation", + app_icon = icons.power, + position = "top_middle", + icon = icons.restart, + ontop = true, + title = "Please Confirm You Want to Reboot", + text = "Please Confirm You Would Like to Reboot by Pressing Confirm Below", + actions = { confirm, cancel }, + }) end -Restart = utilities.widgets.mkbtn({ +Restart = utilities.interaction.mkbtn({ + { { - { - widget = wibox.widget.imagebox, - image = icons.restart, - resize = true, - opacity = 1, - }, - left = dpi(5), - right = dpi(5), - top = dpi(5), - bottom = dpi(5), - widget = wibox.container.margin, + widget = wibox.widget.imagebox, + image = icons.restart, + resize = true, + opacity = 1, }, - shape = utilities.widgets.mkroundedrect(), - widget = wibox.container.background, - forced_height = dpi(48), - forced_width = dpi(48), + valign = "center", + halign = "center", + layout = wibox.container.place, + }, + shape = utilities.graphics.mkroundedrect(), + widget = wibox.container.background, + forced_height = dpi(48), + forced_width = dpi(48), }, beautiful.widget_back, beautiful.widget_back_focus) Restart:connect_signal("button::press", function() - do_notify() + do_notify() end) return Restart diff --git a/ui/launcher/powermenu_containers/shutdown.lua b/ui/launcher/powermenu_containers/shutdown.lua index e85890c..4be6d96 100644 --- a/ui/launcher/powermenu_containers/shutdown.lua +++ b/ui/launcher/powermenu_containers/shutdown.lua @@ -1,52 +1,50 @@ local function do_notify() - local confirm = naughty.action({ name = "Confirm" }) - local cancel = naughty.action({ name = "Cancel" }) - -- -------------------------------------------------------------------------- -- - -- copy to clipboard button - confirm:connect_signal("invoked", function() - awful.spawn("doas shutdown -n now") - end) - -- -------------------------------------------------------------------------- -- - -- delete - cancel:connect_signal("invoked", function() - return - end) - -- -------------------------------------------------------------------------- -- - -- Show the notification. - naughty.notify({ - app_name = "Confirmation", - app_icon = icons.power, - position = "top_middle", - ontop = true, - icon = icons.power, - title = "Please Confirm You Want to Shut Down", - text = "Please Confirm You Would Like to Shut Down by Pressing Confirm Below", - actions = { confirm, cancel }, - }) + local confirm = naughty.action({ name = "Confirm" }) + local cancel = naughty.action({ name = "Cancel" }) + -- -------------------------------------------------------------------------- -- + -- copy to clipboard button + confirm:connect_signal("invoked", function() + awful.spawn("doas shutdown -n now") + end) + -- -------------------------------------------------------------------------- -- + -- delete + cancel:connect_signal("invoked", function() + return + end) + -- -------------------------------------------------------------------------- -- + -- Show the notification. + naughty.notify({ + app_name = "Confirmation", + app_icon = icons.power, + position = "top_middle", + ontop = true, + icon = icons.power, + title = "Please Confirm You Want to Shut Down", + text = "Please Confirm You Would Like to Shut Down by Pressing Confirm Below", + actions = { confirm, cancel }, + }) end -Shutdown = utilities.widgets.mkbtn({ +Shutdown = utilities.interaction.mkbtn({ + { { - { - widget = wibox.widget.imagebox, - image = icons.power, - resize = true, - opacity = 1, - }, - left = dpi(5), - right = dpi(5), - top = dpi(5), - bottom = dpi(5), - widget = wibox.container.margin, + widget = wibox.widget.imagebox, + image = icons.power, + resize = true, + opacity = 1, }, + valign = "center", + halign = "center", + layout = wibox.container.place, + }, - shape = utilities.widgets.mkroundedrect(), - widget = wibox.container.background, + shape = utilities.graphics.mkroundedrect(), + widget = wibox.container.background, - forced_height = dpi(48), - forced_width = dpi(48), + forced_height = dpi(48), + forced_width = dpi(48), }, beautiful.widget_back, beautiful.widget_back_focus) Shutdown:connect_signal("button::press", function() - do_notify() + do_notify() end) return Shutdown diff --git a/ui/menu/init.lua b/ui/menu/init.lua index 72dd1d7..aca163c 100644 --- a/ui/menu/init.lua +++ b/ui/menu/init.lua @@ -28,12 +28,11 @@ menu.mainmenu = awful.menu({ { "Explorer", filemanager, icons.files }, { "Browser", browser, icons.web_browser }, { "Editor", editor_cmd, icons.text_editor }, - { "GUI Editor", visual_editor, icons.text }, { "AwesomeWM", menu.awesome, icons.awesome }, }, }) -menu.mainmenu.wibox.shape = utilities.widgets.mkroundedrect() +menu.mainmenu.wibox.shape = utilities.graphics.mkroundedrect() -- menu.mainmenu.wibox.bg = beautiful.bg_normal .. "00" menu.mainmenu.wibox:set_widget(wibox.widget({ { @@ -45,7 +44,7 @@ menu.mainmenu.wibox:set_widget(wibox.widget({ -- bg = beautiful.bg_normal .. "bb", border_width = dpi(1), border_color = beautiful.grey .. "cc", - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), widget = wibox.container.background, })) @@ -54,7 +53,7 @@ awful.menu.original_new = awful.menu.new function awful.menu.new(...) local ret = awful.menu.original_new(...) - ret.wibox.shape = utilities.widgets.mkroundedrect() + ret.wibox.shape = utilities.graphics.mkroundedrect() ret.wibox:set_widget(wibox.widget({ { ret.wibox.widget, @@ -65,7 +64,7 @@ function awful.menu.new(...) -- bg = beautiful.bg_normal .. "00", border_width = dpi(1), border_color = beautiful.grey .. "cc", - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), })) return ret end diff --git a/ui/notifications/brightness.lua b/ui/notifications/brightness.lua index 87e0790..ba57fed 100644 --- a/ui/notifications/brightness.lua +++ b/ui/notifications/brightness.lua @@ -61,7 +61,7 @@ bright_adjust:setup({ widget = wibox.container.margin, }, }, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), bg = beautiful.bg_normal .. "66", border_width = dpi(2), border_color = beautiful.grey .. "cc", diff --git a/ui/notifications/init.lua b/ui/notifications/init.lua index 8acc38c..010e859 100644 --- a/ui/notifications/init.lua +++ b/ui/notifications/init.lua @@ -23,14 +23,13 @@ end) require("ui.notifications.brightness") require("ui.notifications.volume") --- require("ui.notifications.osd") + require("ui.notifications.battery") naughty.config.defaults.ontop = true naughty.config.defaults.screen = awful.screen.focused() naughty.config.defaults.timeout = 6 naughty.config.defaults.title = "System Notification" ---naughty.config.defaults.position = "top_right" -- Timeouts naughty.config.presets.low.timeout = 3 @@ -68,7 +67,7 @@ ruled.notification.connect_signal("request::rules", function() end) naughty.connect_signal("added", function() - -- modules.sfx.play() + modules.sfx.play() end) naughty.connect_signal("request::display", function(n) @@ -90,12 +89,12 @@ naughty.connect_signal("request::display", function(n) right = dpi(6), widget = wibox.container.margin, }, - bg = beautiful.bg_contrast, + bg = beautiful.bg_contrast .. "dd", border_width = dpi(0.5), border_color = beautiful.grey, forced_height = dpi(25), forced_width = dpi(20), - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), widget = wibox.container.background, } @@ -126,7 +125,7 @@ naughty.connect_signal("request::display", function(n) { image = appicon, resize = true, - clip_shape = utilities.widgets.mkroundedrect(), + clip_shape = utilities.graphics.mkroundedrect(), widget = wibox.widget.imagebox, }, strategy = "max", @@ -188,7 +187,7 @@ naughty.connect_signal("request::display", function(n) { { { - utilities.widgets.vertical_pad(5), + utilities.layout.vertical_pad(5), { { step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth, @@ -215,7 +214,7 @@ naughty.connect_signal("request::display", function(n) spacing = 0, layout = wibox.layout.flex.vertical, }, - utilities.widgets.vertical_pad(5), + utilities.layout.vertical_pad(5), layout = wibox.layout.align.vertical, }, left = dpi(20), @@ -228,11 +227,11 @@ naughty.connect_signal("request::display", function(n) { image = n.icon, resize = true, - clip_shape = utilities.widgets.mkroundedrect(), + clip_shape = utilities.graphics.mkroundedrect(), widget = wibox.widget.imagebox, }, strategy = "max", - height = dpi(80), + height = dpi(120), widget = wibox.container.constraint, }, valign = "center", @@ -261,7 +260,7 @@ naughty.connect_signal("request::display", function(n) bg = beautiful.bg_normal .. "88", border_width = dpi(0.25), border_color = beautiful.grey, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), widget = wibox.container.background, }, }) diff --git a/ui/notifications/volume.lua b/ui/notifications/volume.lua index 091b66b..e201e48 100644 --- a/ui/notifications/volume.lua +++ b/ui/notifications/volume.lua @@ -31,7 +31,7 @@ local volume_osd_bar = wibox.widget({ border_width = dpi(1), border_color = beautiful.grey .. "66", shape = gears.shape.rounded_bar, - bar_shape = utilities.widgets.mkroundedrect(), + bar_shape = utilities.graphics.mkroundedrect(), widget = wibox.widget.progressbar, }, nil, @@ -70,7 +70,7 @@ volume_osd:setup({ widget = wibox.container.margin, }, }, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), bg = beautiful.bg_normal .. "66", border_width = dpi(2), border_color = beautiful.grey .. "cc", diff --git a/ui/popups/network/init.lua b/ui/popups/network/init.lua index 6f80abc..34958b6 100644 --- a/ui/popups/network/init.lua +++ b/ui/popups/network/init.lua @@ -15,7 +15,7 @@ awful.screen.connect_for_each_screen(function(s) -- ------------------------------------------------- -- network = wibox({ type = "dock", - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), screen = s, width = dpi(380), height = dpi(560), @@ -66,7 +66,7 @@ awful.screen.connect_for_each_screen(function(s) margins = dpi(5), widget = wibox.container.margin, }, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), bg = beautiful.black .. "77", forced_width = dpi(380), forced_height = dpi(70), @@ -91,7 +91,7 @@ awful.screen.connect_for_each_screen(function(s) margins = dpi(5), widget = wibox.container.margin, }, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), bg = beautiful.black .. "77", forced_width = dpi(380), forced_height = dpi(50), @@ -115,7 +115,7 @@ awful.screen.connect_for_each_screen(function(s) margins = dpi(5), widget = wibox.container.margin, }, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), bg = beautiful.bg_normal .. "33", forced_width = dpi(380), ontop = true, diff --git a/ui/popups/network/widgets/elements/init.lua b/ui/popups/network/widgets/elements/init.lua index a026445..8f4afc8 100755 --- a/ui/popups/network/widgets/elements/init.lua +++ b/ui/popups/network/widgets/elements/init.lua @@ -6,143 +6,143 @@ local elements = {} elements.create = function(SSID, BSSID, connectStatus, signal, secure, speed) - local box = {} + local box = {} - local signalIcon = wibox.widget({ - layout = wibox.layout.align.vertical, - expand = "none", - nil, - { - id = "icon", - image = icons.wifi_problem, - resize = true, - widget = wibox.widget.imagebox, - }, - nil, - }) + local signalIcon = wibox.widget({ + layout = wibox.layout.align.vertical, + expand = "none", + nil, + { + id = "icon", + image = icons.wifi_problem, + resize = true, + widget = wibox.widget.imagebox, + }, + nil, + }) - local wifiIcon = wibox.widget({ - { - { - signalIcon, - margins = dpi(7), - widget = wibox.container.margin, - }, - shape = utilities.widgets.mkroundedrect(), - bg = beautiful.widget_back, - border_width = dpi(0.75), + local wifiIcon = wibox.widget({ + { + { + signalIcon, + margins = dpi(7), + widget = wibox.container.margin, + }, + shape = utilities.graphics.mkroundedrect(), + bg = beautiful.widget_back, + border_width = dpi(0.75), - border_color = beautiful.grey .. "cc", - widget = wibox.container.background, - }, - forced_width = dpi(48), - forced_height = dpi(48), + border_color = beautiful.grey .. "cc", + widget = wibox.container.background, + }, + forced_width = dpi(48), + forced_height = dpi(48), - widget = wibox.container.margin, - margins = dpi(4), - }) - wifiIcon:buttons(gears.table.join(awful.button({}, 1, nil, function() - awful.spawn.easy_async_with_shell( - "nmcli connection show '" + widget = wibox.container.margin, + margins = dpi(4), + }) + wifiIcon:buttons(gears.table.join(awful.button({}, 1, nil, function() + awful.spawn.easy_async_with_shell( + "nmcli connection show '" + .. SSID + .. "' | grep 'connection.autoconnect:' | awk '{print $2}'", + function(stdout) + local knownStatus = stdout:gsub("\n", "") + if knownStatus == "yes" then + awful.spawn.with_shell( + "nmcli device wifi connect " + .. BSSID + .. " && notify-send 'Connected to internet' '" + .. SSID + .. "' || notify-send 'Unable to connect' '" + .. SSID + .. "'" + ) + else + if secure == "no" then + awful.spawn.with_shell( + "nmcli device wifi connect " + .. BSSID + .. " && notify-send 'Connected to internet' '" + .. SSID + .. "' || notify-send 'Unable to connect' '" .. SSID - .. "' | grep 'connection.autoconnect:' | awk '{print $2}'", - function(stdout) - local knownStatus = stdout:gsub("\n", "") - if knownStatus == "yes" then - awful.spawn.with_shell( - "nmcli device wifi connect " - .. BSSID - .. " && notify-send 'Connected to internet' '" - .. SSID - .. "' || notify-send 'Unable to connect' '" - .. SSID - .. "'" - ) - else - if secure == "no" then - awful.spawn.with_shell( - "nmcli device wifi connect " - .. BSSID - .. " && notify-send 'Connected to internet' '" - .. SSID - .. "' || notify-send 'Unable to connect' '" - .. SSID - .. "'" - ) - else - awful.spawn.with_shell( - "nmcli device wifi connect " - .. BSSID - .. " password $(rofi -dmenu -p '" - .. SSID - .. "' -theme ~/.config/awesome/configuration/rofi/centered.rasi -password)" - .. " && notify-send 'Connected to internet' '" - .. SSID - .. "' || notify-send 'Unable to connect' '" - .. SSID - .. "'" - ) - end - end - end - ) - end))) - local content = wibox.widget({ + .. "'" + ) + else + awful.spawn.with_shell( + "nmcli device wifi connect " + .. BSSID + .. " password $(rofi -dmenu -p '" + .. SSID + .. "' -theme ~/.config/awesome/configuration/rofi/centered.rasi -password)" + .. " && notify-send 'Connected to internet' '" + .. SSID + .. "' || notify-send 'Unable to connect' '" + .. SSID + .. "'" + ) + end + end + end + ) + end))) + local content = wibox.widget({ + { + { + nil, { - { - nil, - { - text = SSID, - font = beautiful.font .. " Bold 14", - widget = wibox.widget.textbox, - }, - - layout = wibox.layout.align.vertical, - }, - margins = dpi(10), - widget = wibox.container.margin, + text = SSID, + font = beautiful.font .. " Bold 14", + widget = wibox.widget.textbox, }, - shape = utilities.widgets.mkroundedrect(), - bg = beautiful.bg_normal .. "00", - widget = wibox.container.background, - }) + layout = wibox.layout.align.vertical, + }, + margins = dpi(10), + widget = wibox.container.margin, + }, + shape = utilities.graphics.mkroundedrect(), + bg = beautiful.bg_normal .. "00", - local icon_table = { - icons.wifi_0, - icons.wifi_1, - icons.wifi_2, - icons.wifi_3, - } + widget = wibox.container.background, + }) - signalIcon.icon:set_image(icon_table[math.ceil(tonumber(signal) / 25)]) + local icon_table = { + icons.wifi_0, + icons.wifi_1, + icons.wifi_2, + icons.wifi_3, + } - if connectStatus == "yes" then - awesome.emit_signal( - "network::status:updateIcon", - icon_table[math.ceil(tonumber(signal) / 25)] - ) - else - awesome.emit_signal("network::status:updateIcon", nil) - end + signalIcon.icon:set_image(icon_table[math.ceil(tonumber(signal) / 25)]) - box = wibox.widget({ - { - wifiIcon, - content, - nil, - layout = wibox.layout.align.horizontal, - }, + if connectStatus == "yes" then + awesome.emit_signal( + "network::status:updateIcon", + icon_table[math.ceil(tonumber(signal) / 25)] + ) + else + awesome.emit_signal("network::status:updateIcon", nil) + end + + box = wibox.widget({ + { + wifiIcon, + content, + nil, + layout = wibox.layout.align.horizontal, + }, - shape = utilities.widgets.mkroundedrect(), - fg = beautiful.white, - border_width = dpi(1), - border_color = beautiful.grey .. "cc", - widget = wibox.container.background, - bg = beautiful.bg_contrast .. "22", - }) + shape = utilities.graphics.mkroundedrect(), + fg = beautiful.white, + border_width = dpi(1), + border_color = beautiful.grey .. "cc", + widget = wibox.container.background, + bg = beautiful.bg_contrast .. "22", + }) - return box + return box end return elements diff --git a/ui/popups/network/widgets/searching/init.lua b/ui/popups/network/widgets/searching/init.lua index 1a7ba3f..401c759 100755 --- a/ui/popups/network/widgets/searching/init.lua +++ b/ui/popups/network/widgets/searching/init.lua @@ -7,66 +7,66 @@ local box = {} local signalIcon = wibox.widget({ - layout = wibox.layout.align.vertical, - expand = "none", - nil, - { - id = "icon", - image = icons.wifi_3, - resize = true, - widget = wibox.widget.imagebox, - }, - nil, + layout = wibox.layout.align.vertical, + expand = "none", + nil, + { + id = "icon", + image = icons.wifi_3, + resize = true, + widget = wibox.widget.imagebox, + }, + nil, }) local wifiIcon = wibox.widget({ + { { - { - signalIcon, - margins = dpi(7), - widget = wibox.container.margin, - }, - shape = utilities.widgets.mkroundedrect(), - bg = beautiful.widget_back, - widget = wibox.container.background, + signalIcon, + margins = dpi(7), + widget = wibox.container.margin, }, - forced_width = dpi(48), - forced_height = dpi(48), - shape = utilities.widgets.mkroundedrect(), - border_width = dpi(2), - border_color = beautiful.grey .. "cc", + shape = utilities.graphics.mkroundedrect(), + bg = beautiful.widget_back, + widget = wibox.container.background, + }, + forced_width = dpi(48), + forced_height = dpi(48), + shape = utilities.graphics.mkroundedrect(), + border_width = dpi(2), + border_color = beautiful.grey .. "cc", }) local content = wibox.widget({ + { { - { - { - text = "Searching...", - font = beautiful.font .. " Bold 14", - widget = wibox.widget.textbox, - }, - layout = wibox.layout.align.vertical, - }, - margins = dpi(10), - widget = wibox.container.margin, + { + text = "Searching...", + font = beautiful.font .. " Bold 14", + widget = wibox.widget.textbox, + }, + layout = wibox.layout.align.vertical, }, - shape = utilities.widgets.mkroundedrect(), - bg = beautiful.bg_normal, - widget = wibox.container.background, + margins = dpi(10), + widget = wibox.container.margin, + }, + shape = utilities.graphics.mkroundedrect(), + bg = beautiful.bg_normal, + widget = wibox.container.background, }) box = wibox.widget({ - { - wifiIcon, - content, - -- buttons, - layout = wibox.layout.align.horizontal, - }, - shape = utilities.widgets.mkroundedrect(), - fg = beautiful.white, - border_width = dpi(2), - border_color = beautiful.grey .. "cc", - widget = wibox.container.background, + { + wifiIcon, + content, + -- buttons, + layout = wibox.layout.align.horizontal, + }, + shape = utilities.graphics.mkroundedrect(), + fg = beautiful.white, + border_width = dpi(2), + border_color = beautiful.grey .. "cc", + widget = wibox.container.background, }) return box diff --git a/ui/popups/network/widgets/status-icon/init.lua b/ui/popups/network/widgets/status-icon/init.lua index 3ae9705..3820bcb 100755 --- a/ui/popups/network/widgets/status-icon/init.lua +++ b/ui/popups/network/widgets/status-icon/init.lua @@ -10,75 +10,75 @@ -- Icon widget local widget_icon = wibox.widget({ - layout = wibox.layout.align.vertical, - expand = "none", - nil, - { - id = "icon", - image = icons.wifi_problem, - resize = true, - widget = wibox.widget.imagebox, - }, - nil, + layout = wibox.layout.align.vertical, + expand = "none", + nil, + { + id = "icon", + image = icons.wifi_problem, + resize = true, + widget = wibox.widget.imagebox, + }, + nil, }) -- Icon widget container local widget = wibox.widget({ + { { - { - { - widget_icon, - layout = wibox.layout.fixed.horizontal, - }, - margins = dpi(4), - widget = wibox.container.margin, - }, - forced_height = dpi(40), - widget = wibox.container.background, - bg = beautiful.widget_back, - border_width = dpi(0.75), - border_color = beautiful.bg_normal .. "cc", - shape = utilities.widgets.mkroundedrect(), + { + widget_icon, + layout = wibox.layout.fixed.horizontal, + }, + margins = dpi(4), + widget = wibox.container.margin, }, - shape = utilities.widgets.mkroundedrect(), - bg = "transparent", + forced_height = dpi(40), widget = wibox.container.background, + bg = beautiful.widget_back, + border_width = dpi(0.75), + border_color = beautiful.bg_normal .. "cc", + shape = utilities.graphics.mkroundedrect(), + }, + shape = utilities.graphics.mkroundedrect(), + bg = "transparent", + widget = wibox.container.background, }) awesome.connect_signal( - "network::status::wireless", - function(interface, healthy, essid, bitrate, strength) - if healthy == true then - if strength <= 100 then - widget_icon.icon:set_image(icons.wifi_3) - elseif strength <= 75 then - widget_icon.icon:set_image(icons.wifi_2) - elseif strength <= 50 then - widget_icon.icon:set_image(icons.wifi_1) - elseif strength <= 25 then - widget_icon.icon:set_image(icons.wifi_0) - end - else - widget_icon.icon:set_image(icons.wifi_problem) - end - end -) -awesome.connect_signal("network::status::wired", function(interface, healthy) + "network::status::wireless", + function(interface, healthy, essid, bitrate, strength) if healthy == true then - widget_icon.icon:set_image(icons.wired) + if strength <= 100 then + widget_icon.icon:set_image(icons.wifi_3) + elseif strength <= 75 then + widget_icon.icon:set_image(icons.wifi_2) + elseif strength <= 50 then + widget_icon.icon:set_image(icons.wifi_1) + elseif strength <= 25 then + widget_icon.icon:set_image(icons.wifi_0) + end else - widget_icon.icon:set_image(icons.wired_alert) + widget_icon.icon:set_image(icons.wifi_problem) end + end +) +awesome.connect_signal("network::status::wired", function(interface, healthy) + if healthy == true then + widget_icon.icon:set_image(icons.wired) + else + widget_icon.icon:set_image(icons.wired_alert) + end end) awesome.connect_signal("network::disconnected::wireless", function() - widget_icon.icon:set_image(icons.wifi_off) + widget_icon.icon:set_image(icons.wifi_off) end) awesome.connect_signal("network::disconnected::wired", function() - widget_icon.icon:set_image(icons.wired_off) + widget_icon.icon:set_image(icons.wired_off) end) widget_icon:buttons(awful.util.table.join(awful.button({}, 1, nil, function() - awesome.emit_signal("networks::network:refreshPanel") + awesome.emit_signal("networks::network:refreshPanel") end))) return widget diff --git a/ui/popups/notification_center/init.lua b/ui/popups/notification_center/init.lua index 632fe27..d628b29 100644 --- a/ui/popups/notification_center/init.lua +++ b/ui/popups/notification_center/init.lua @@ -8,7 +8,7 @@ awful.screen.connect_for_each_screen(function(s) -- ----------------------------------------------------------- -- notification_center = wibox({ type = "dock", - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), screen = s, width = dpi(380), height = dpi(560), @@ -139,7 +139,7 @@ awful.screen.connect_for_each_screen(function(s) { nil, require("ui.popups.notification_center.widgets.notifcenter"), - utilities.widgets.vertical_pad(dpi(12)), + utilities.layout.vertical_pad(dpi(12)), height = dpi(400), minimum_height = dpi(400), forced_height = dpi(400), diff --git a/ui/popups/notification_center/widgets/action_buttons/network.lua b/ui/popups/notification_center/widgets/action_buttons/network.lua index 6440879..3790777 100644 --- a/ui/popups/notification_center/widgets/action_buttons/network.lua +++ b/ui/popups/notification_center/widgets/action_buttons/network.lua @@ -7,36 +7,36 @@ local awful = require("awful") require("signal.system.network") local network = wibox.widget({ - widget = wibox.widget.imagebox, - image = icons.wifi_3, - align = "center", + widget = wibox.widget.imagebox, + image = icons.wifi_3, + align = "center", }) -local tooltip = utilities.widgets.make_popup_tooltip( - "Press to toggle network", - function(d) - return awful.placement.bottom_right(d, { - margins = { - bottom = beautiful.bar_height + beautiful.useless_gap * 2, - right = beautiful.useless_gap * 2 + 85, - }, - }) - end +local tooltip = utilities.interaction.make_popup_tooltip( + "Press to toggle network", + function(d) + return awful.placement.bottom_right(d, { + margins = { + bottom = beautiful.bar_height + beautiful.useless_gap * 2, + right = beautiful.useless_gap * 2 + 85, + }, + }) + end ) tooltip.attach_to_object(network) network:add_button(awful.button({}, 1, function() - nc_toggle() - awesome.emit_signal("network::networks:refreshPanel") + nc_toggle() + awesome.emit_signal("network::networks:refreshPanel") end)) awesome.connect_signal("network::connected", function() - network.image = icons.wifi_3 + network.image = icons.wifi_3 end) awesome.connect_signal("network::disconnected", function() - network.image = icons.wifi_off + network.image = icons.wifi_off end) return network diff --git a/ui/popups/notification_center/widgets/controls.lua b/ui/popups/notification_center/widgets/controls.lua index 52955aa..6e34adc 100644 --- a/ui/popups/notification_center/widgets/controls.lua +++ b/ui/popups/notification_center/widgets/controls.lua @@ -5,73 +5,73 @@ local gears = require("gears") local dpi = beautiful.xresources.apply_dpi local function base_slider(icon) - return wibox.widget({ + return wibox.widget({ + { + { + id = "slider", + bar_shape = utilities.graphics.mkroundedrect(), + bar_height = dpi(18), + bar_active_color = beautiful.grey .. "88", + bar_color = beautiful.black .. "88", + handle_color = beautiful.white, + handle_shape = utilities.graphics.mkroundedrect(), + handle_width = dpi(18), + handle_border_width = dpi(1), + forced_height = dpi(18), + handle_border_color = beautiful.bg_normal, + minimum = 5, + maximum = 100, + widget = wibox.widget.slider, + }, + { { - { - id = "slider", - bar_shape = utilities.widgets.mkroundedrect(), - bar_height = dpi(18), - bar_active_color = beautiful.grey .. "88", - bar_color = beautiful.black .. "88", - handle_color = beautiful.white, - handle_shape = utilities.widgets.mkroundedrect(), - handle_width = dpi(18), - handle_border_width = dpi(1), - forced_height = dpi(18), - handle_border_color = beautiful.bg_normal, - minimum = 5, - maximum = 100, - widget = wibox.widget.slider, - }, - { - { - { - id = "icon_role", - markup = icon, - valign = "center", - align = "left", - font = beautiful.nerd_font .. " 28", - widget = wibox.widget.textbox, - }, - fg = beautiful.fg_normal, - widget = wibox.container.background, - }, - left = dpi(7), - widget = wibox.container.margin, - }, - layout = wibox.layout.stack, + { + id = "icon_role", + markup = icon, + valign = "center", + align = "left", + font = beautiful.nerd_font .. " 28", + widget = wibox.widget.textbox, + }, + fg = beautiful.fg_normal, + widget = wibox.container.background, }, - layout = wibox.layout.fixed.horizontal, - set_value = function(self, value) - self:get_children_by_id("slider")[1].value = value - end, - set_icon = function(self, new_icon) - self:get_children_by_id("icon_role")[1].markup = new_icon - end, - get_slider = function(self) - return self:get_children_by_id("slider")[1] - end, - }) + left = dpi(7), + widget = wibox.container.margin, + }, + layout = wibox.layout.stack, + }, + layout = wibox.layout.fixed.horizontal, + set_value = function(self, value) + self:get_children_by_id("slider")[1].value = value + end, + set_icon = function(self, new_icon) + self:get_children_by_id("icon_role")[1].markup = new_icon + end, + get_slider = function(self) + return self:get_children_by_id("slider")[1] + end, + }) end -- volume local volume_slider = base_slider("") volume_slider.slider:connect_signal("property::value", function(_, value) - awful.spawn.with_shell("wpctl set-mute @DEFAULT_AUDIO_SINK@ 0") - awful.spawn.with_shell( - "wpctl set-volume @DEFAULT_AUDIO_SINK@ " .. value .. "%" - ) - awesome.emit_signal("widget::volume") + awful.spawn.with_shell("wpctl set-mute @DEFAULT_AUDIO_SINK@ 0") + awful.spawn.with_shell( + "wpctl set-volume @DEFAULT_AUDIO_SINK@ " .. value .. "%" + ) + awesome.emit_signal("widget::volume") end) awesome.connect_signal("signal::volume", function(volume, is_muted) - volume_slider.value = volume - if is_muted == "MUTED" then - volume_slider.icon = "" - else - volume_slider.icon = "" - end + volume_slider.value = volume + if is_muted == "MUTED" then + volume_slider.icon = "" + else + volume_slider.icon = "" + end end) -- brightness @@ -79,50 +79,50 @@ local brightness_slider = base_slider("") -- 100 by-default. if brightness_slider.slider.value == 0 then - brightness_slider.value = 100 + brightness_slider.value = 100 end -- signals brightness_slider.slider:connect_signal("property::value", function(_, new_br) - awful.spawn("brightnessctl s " .. new_br .. "%") - awesome.emit_signal("signal::brightness", math.floor(new_br)) + awful.spawn("brightnessctl s " .. new_br .. "%") + awesome.emit_signal("signal::brightness", math.floor(new_br)) end) awesome.connect_signal("brightness::value", function(brightness) - brightness_slider.value = brightness - brightness_slider.icon = brightness == 0 and "" or "" + brightness_slider.value = brightness + brightness_slider.icon = brightness == 0 and "" or "" end) local controls = wibox.widget({ + { { + { { - { - { - { - bottom = dpi(8), - widget = wibox.container.margin, - }, - widget = wibox.container.background, - }, - layout = wibox.layout.fixed.horizontal, - }, - { - volume_slider, - brightness_slider, - spacing = dpi(5), - layout = wibox.layout.fixed.vertical, - }, - nil, - layout = wibox.layout.align.vertical, + { + bottom = dpi(8), + widget = wibox.container.margin, + }, + widget = wibox.container.background, }, - margins = dpi(12), - widget = wibox.container.margin, + layout = wibox.layout.fixed.horizontal, + }, + { + volume_slider, + brightness_slider, + spacing = dpi(5), + layout = wibox.layout.fixed.vertical, + }, + nil, + layout = wibox.layout.align.vertical, }, - shape = utilities.widgets.mkroundedrect(), - bg = beautiful.bg_contrast, - border_color = beautiful.grey, - border_width = 0.75, - widget = wibox.container.background, + margins = dpi(12), + widget = wibox.container.margin, + }, + shape = utilities.graphics.mkroundedrect(), + bg = beautiful.bg_contrast, + border_color = beautiful.grey, + border_width = 0.75, + widget = wibox.container.background, }) return controls diff --git a/ui/popups/notification_center/widgets/notifcenter.lua b/ui/popups/notification_center/widgets/notifcenter.lua index 18d7a61..9856b91 100644 --- a/ui/popups/notification_center/widgets/notifcenter.lua +++ b/ui/popups/notification_center/widgets/notifcenter.lua @@ -14,7 +14,7 @@ local main_widget local entry_template = { widget = wibox.container.background, bg = beautiful.bg_contrast .. "88", - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), { widget = wibox.container.constraint, width = dpi(400), @@ -58,7 +58,7 @@ local entry_template = { resize = true, forced_width = 0, forced_height = 0, - clip_shape = utilities.widgets.mkroundedrect(), + clip_shape = utilities.graphics.mkroundedrect(), }, }, { @@ -93,7 +93,7 @@ main_widget = wibox.widget({ -- this is basically just a simple header + layout to hold notifs local app_revealer_template = { widget = wibox.container.background, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), border_color = beautiful.grey .. "cc", border_width = dpi(1.25), { @@ -210,7 +210,7 @@ local function add_notif_widget(n) collectgarbage("collect") end, })) - utilities.widgets.pointer_on_focus( + utilities.interaction.pointer_on_focus( drawer:get_children_by_id("reveal_button")[1] ) drawer:get_children_by_id("clear_button")[1]:add_button(awful.button({ @@ -223,7 +223,7 @@ local function add_notif_widget(n) collectgarbage("collect") end, })) - utilities.widgets.pointer_on_focus( + utilities.interaction.pointer_on_focus( drawer:get_children_by_id("clear_button")[1] ) main_widget:insert(1, drawer) @@ -297,7 +297,7 @@ notifbox = bg = beautiful.black .. "88", border_color = beautiful.grey, border_width = dpi(1.25), - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), { layout = wibox.layout.align.horizontal, expand = "inside", diff --git a/ui/popups/notification_center/widgets/sliders/brightness-slider/init.lua b/ui/popups/notification_center/widgets/sliders/brightness-slider/init.lua index 76ad907..79896db 100644 --- a/ui/popups/notification_center/widgets/sliders/brightness-slider/init.lua +++ b/ui/popups/notification_center/widgets/sliders/brightness-slider/init.lua @@ -36,7 +36,7 @@ local widget_content = wibox.widget({ margins = dpi(6), widget = wibox.container.margin, }, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), bg = beautiful.bg_focus .. "66", widget = wibox.container.background, }) @@ -50,7 +50,7 @@ local slider = wibox.widget({ bar_color = beautiful.bg_normal .. "cc", bar_active_color = beautiful.grey .. "dd", handle_color = beautiful.fg_normal, - handle_shape = utilities.widgets.mkroundedrect(), + handle_shape = utilities.graphics.mkroundedrect(), handle_width = dpi(24), handle_border_color = beautiful.bg_normal, handle_border_width = dpi(2), @@ -185,7 +185,7 @@ local cc_brightness = wibox.widget({ margins = dpi(5), widget = wibox.container.margin, }, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), bg = beautiful.bg_contrast .. "66", fg = beautiful.fg_normal, widget = wibox.container.background, diff --git a/ui/popups/notification_center/widgets/sliders/init.lua b/ui/popups/notification_center/widgets/sliders/init.lua index 6987c58..05981d2 100644 --- a/ui/popups/notification_center/widgets/sliders/init.lua +++ b/ui/popups/notification_center/widgets/sliders/init.lua @@ -26,7 +26,7 @@ local sliders = wibox.widget({ bg = beautiful.bg_contrast .. "bb", border_color = beautiful.grey .. "cc", border_width = dpi(2), - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), }, { { @@ -44,13 +44,13 @@ local sliders = wibox.widget({ bg = beautiful.bg_normal .. "66", border_color = beautiful.grey .. "cc", border_width = dpi(1), - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), }, }, margins = dpi(0), widget = wibox.container.margin, }, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), widget = wibox.container.background, }) -- ------------------------------------------------- -- diff --git a/ui/popups/notification_center/widgets/sliders/volume-slider/init.lua b/ui/popups/notification_center/widgets/sliders/volume-slider/init.lua index b0f3882..b7f45ad 100644 --- a/ui/popups/notification_center/widgets/sliders/volume-slider/init.lua +++ b/ui/popups/notification_center/widgets/sliders/volume-slider/init.lua @@ -8,210 +8,205 @@ -- |_______|__|__||_____||_____|__| -- ------------------------------------------------- -- local widget_name = wibox.widget({ - text = "Volume", - font = beautiful.font .. " 26", - align = "left", - widget = wibox.widget.textbox, + text = "Volume", + font = beautiful.font .. " 26", + align = "left", + widget = wibox.widget.textbox, }) -- ------------------------------------------------- -- local widget_icon = wibox.widget({ - layout = wibox.layout.align.vertical, - expand = "none", - nil, - { - id = "icon", - image = icons.volume, - resize = true, - widget = wibox.widget.imagebox, - }, - nil, + layout = wibox.layout.align.vertical, + expand = "none", + nil, + { + id = "icon", + image = icons.volume, + resize = true, + widget = wibox.widget.imagebox, + }, + nil, }) -- ------------------------------------------------- -- local widget_content = wibox.widget({ - { - widget_icon, - margins = dpi(6), - widget = wibox.container.margin, - }, - bg = beautiful.bg_contrast .. "66", - shape = utilities.widgets.mkroundedrect(), - widget = wibox.container.background, + { + widget_icon, + margins = dpi(6), + widget = wibox.container.margin, + }, + bg = beautiful.bg_contrast .. "66", + shape = utilities.graphics.mkroundedrect(), + widget = wibox.container.background, }) -- ------------------------------------------------- -- local slider = wibox.widget({ - nil, - { - id = "volume_slider", - bar_shape = gears.shape.rounded_bar, - bar_height = dpi(18), - bar_color = beautiful.bg_normal .. "cc", - bar_active_color = beautiful.grey .. "dd", - handle_color = beautiful.fg_normal, - handle_shape = utilities.widgets.mkroundedrect(), - handle_width = dpi(24), - handle_border_color = beautiful.bg_normal, - handle_border_width = dpi(2), - maximum = 100, - value = 100, - handle_margins = { - left = 0, - right = 0, - top = dpi(3), - bottom = dpi(3), - }, - widget = wibox.widget.slider, + nil, + { + id = "volume_slider", + bar_shape = gears.shape.rounded_bar, + bar_height = dpi(18), + bar_color = beautiful.bg_normal .. "cc", + bar_active_color = beautiful.grey .. "dd", + handle_color = beautiful.fg_normal, + handle_shape = utilities.graphics.mkroundedrect(), + handle_width = dpi(24), + handle_border_color = beautiful.bg_normal, + handle_border_width = dpi(2), + maximum = 100, + value = 100, + handle_margins = { + left = 0, + right = 0, + top = dpi(3), + bottom = dpi(3), }, - nil, - expand = "outside", - forced_height = dpi(22), - layout = wibox.layout.align.vertical, + widget = wibox.widget.slider, + }, + nil, + expand = "outside", + forced_height = dpi(22), + layout = wibox.layout.align.vertical, }) local volume_slider = slider.volume_slider -- ------------------------------------------------- -- volume_slider:connect_signal("property::value", function() - local volume_level = volume_slider:get_value() - if volume_level ~= nil then - spawn("pamixer --set-volume " .. volume_level, false) - awesome.emit_signal("signal::volume:update", tonumber(volume_level)) - awesome.emit_signal("signal::volume", tonumber(volume_level), 0) - widget_icon.icon:set_image(icons.volume) - else - volume_slider:set_value(0) - spawn("pamixer --mute", false) - widget_icon.icon:set_image(icons.mute) - end + local volume_level = volume_slider:get_value() + if volume_level ~= nil then + spawn("pamixer --set-volume " .. volume_level, false) + awesome.emit_signal("signal::volume:update", tonumber(volume_level)) + awesome.emit_signal("signal::volume", tonumber(volume_level), 0) + widget_icon.icon:set_image(icons.volume) + else + volume_slider:set_value(0) + spawn("pamixer --mute", false) + widget_icon.icon:set_image(icons.mute) + end end) -- ------------------------------------------------- -- volume_slider:buttons(gears.table.join( - awful.button({}, 9, nil, function() - if volume_slider:get_value() > 100 then - volume_slider:set_value(100) - return - end - volume_slider:set_value(volume_slider:get_value() + 5) - awesome.emit_signal("signal::volume:update", volume_slider:get_value()) - end), - awful.button({}, 8, nil, function() - if volume_slider:get_value() < 0 then - volume_slider:set_value(0) - return - end - volume_slider:set_value(volume_slider:get_value() - 5) + awful.button({}, 9, nil, function() + if volume_slider:get_value() > 100 then + volume_slider:set_value(100) + return + end + volume_slider:set_value(volume_slider:get_value() + 5) + awesome.emit_signal("signal::volume:update", volume_slider:get_value()) + end), + awful.button({}, 8, nil, function() + if volume_slider:get_value() < 0 then + volume_slider:set_value(0) + return + end + volume_slider:set_value(volume_slider:get_value() - 5) - awesome.emit_signal("signal::volume:update", volume_slider:get_value()) - end) + awesome.emit_signal("signal::volume:update", volume_slider:get_value()) + end) )) -- ------------------------------------------------- -- local update_slider_mute = function() - awful.spawn.easy_async_with_shell([["pamixer --get-mute"]], function(stdout) - if stdout ~= nil then - local status = string.match(stdout, "%a+") - if stdout == "true" then - widget_icon.icon:set_image(icons.mute) - awful.spawn.easy_async_with_shell([["pamixer --mute "]], false) - awesome.emit_signal("signal:volume:mute") - elseif status == "false" then - awful.spawn.easy_async_with_shell( - [["pamixer --unmute "]], - false - ) - awesome.emit_signal("signal:volume:unmute") - widget_icon.icon:set_image(icons.volume) - end - else - return - end - end) + awful.spawn.easy_async_with_shell([["pamixer --get-mute"]], function(stdout) + if stdout ~= nil then + local status = string.match(stdout, "%a+") + if stdout == "true" then + widget_icon.icon:set_image(icons.mute) + awful.spawn.easy_async_with_shell([["pamixer --mute "]], false) + awesome.emit_signal("signal:volume:mute") + elseif status == "false" then + awful.spawn.easy_async_with_shell([["pamixer --unmute "]], false) + awesome.emit_signal("signal:volume:unmute") + widget_icon.icon:set_image(icons.volume) + end + else + return + end + end) end update_slider_mute() -- ------------------------------------------------- -- local update_slider = function() - awful.spawn.easy_async_with_shell("pamixer --get-volume", function(stdout) - if stdout ~= nil then - local volume = tonumber(stdout) - if volume ~= nil then - volume_slider:set_value(volume) - end - update_slider_mute() - else - volume = volume_slider:get_value() - update_slider_mute() - end - end) + awful.spawn.easy_async_with_shell("pamixer --get-volume", function(stdout) + if stdout ~= nil then + local volume = tonumber(stdout) + if volume ~= nil then + volume_slider:set_value(volume) + end + update_slider_mute() + else + volume = volume_slider:get_value() + update_slider_mute() + end + end) end -- Update on startup update_slider() -- ------------------------------------------------- -- local mute_toggle = function() - awful.spawn.easy_async_with_shell([[ pamixer --mute]], function() - if volume_slider:get_value() ~= 0 then - widget_icon.icon:set_image(icons.mute) - awesome.emit_signal("signal::volume:mute") - else - awesome.emit_signal("signal::volume:unmute") - widget_icon.icon:set_image(icons.volume) - end - end) + awful.spawn.easy_async_with_shell([[ pamixer --mute]], function() + if volume_slider:get_value() ~= 0 then + widget_icon.icon:set_image(icons.mute) + awesome.emit_signal("signal::volume:mute") + else + awesome.emit_signal("signal::volume:unmute") + widget_icon.icon:set_image(icons.volume) + end + end) end -- ------------------------------------------------- -- widget_content:buttons(awful.util.table.join(awful.button({}, 1, nil, function() - mute_toggle() - update_slider_mute() + mute_toggle() + update_slider_mute() end))) -- ------------------------------------------------- -- local volume_tooltip = awful.tooltip({ - objects = { widget_icon }, - text = "None", - mode = "outside", - align = "right", - margin_leftright = dpi(8), - margin_topbottom = dpi(8), - preferred_positions = { "right", "left", "top", "bottom" }, + objects = { widget_icon }, + text = "None", + mode = "outside", + align = "right", + margin_leftright = dpi(8), + margin_topbottom = dpi(8), + preferred_positions = { "right", "left", "top", "bottom" }, }) -- ------------------------------------------------- -- -- The emit will come from the global keybind awesome.connect_signal("signal::volume:update", function(value) - local percentage = tonumber(value) - if percentage ~= nil then - update_slider() - update_slider_mute() - volume_tooltip:set_text( - "Volume Level is Currently: " .. percentage .. "%" - ) - end + local percentage = tonumber(value) + if percentage ~= nil then + update_slider() + update_slider_mute() + volume_tooltip:set_text("Volume Level is Currently: " .. percentage .. "%") + end end) -- ------------------------------------------------- -- local cc_volume = wibox.widget({ + { { + layout = wibox.layout.fixed.horizontal, + spacing = dpi(5), + { + layout = wibox.layout.align.vertical, + expand = "none", + nil, { - layout = wibox.layout.fixed.horizontal, - spacing = dpi(5), - { - layout = wibox.layout.align.vertical, - expand = "none", - nil, - { - layout = wibox.layout.fixed.horizontal, - forced_height = dpi(64), - forced_width = dpi(64), - widget_content, - }, - handle_color = beautiful.sliders_fg, - nil, - }, - slider, + layout = wibox.layout.fixed.horizontal, + forced_height = dpi(64), + forced_width = dpi(64), + widget_content, }, - margins = dpi(5), - widget = wibox.container.margin, + handle_color = beautiful.sliders_fg, + nil, + }, + slider, }, - shape = utilities.widgets.mkroundedrect(), - bg = beautiful.bg_contrast .. "66", - fg = beautiful.fg_normal, - widget = wibox.container.background, + margins = dpi(5), + widget = wibox.container.margin, + }, + shape = utilities.graphics.mkroundedrect(), + bg = beautiful.bg_contrast .. "66", + fg = beautiful.fg_normal, + widget = wibox.container.background, }) return cc_volume diff --git a/ui/popups/window_switcher/elements.lua b/ui/popups/window_switcher/elements.lua index 1025d18..f09f13b 100644 --- a/ui/popups/window_switcher/elements.lua +++ b/ui/popups/window_switcher/elements.lua @@ -87,7 +87,7 @@ return function() }, -- forced_height = dpi(96), -- forced_width = dpi(108), - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), widget = wibox.container.background, bg = beautiful.dimblack .. "66", }) diff --git a/ui/popups/window_switcher/init.lua b/ui/popups/window_switcher/init.lua index e0f5e04..d66a95a 100644 --- a/ui/popups/window_switcher/init.lua +++ b/ui/popups/window_switcher/init.lua @@ -22,7 +22,7 @@ local window_switcher = function(s) visible = false, stretch = false, screen = s, - shape = utilities.widgets.mkroundedrect(), + shape = utilities.graphics.mkroundedrect(), placement = awful.placement.centered, bg = beautiful.dimblack .. "66", border_width = dpi(1), diff --git a/ui/titlebar.lua b/ui/titlebar.lua index dab8118..8cdbff7 100644 --- a/ui/titlebar.lua +++ b/ui/titlebar.lua @@ -26,7 +26,7 @@ local function make_button(txt, onclick) }, layout = wibox.layout.fixed.horizontal, }, - shape = utilities.widgets.mkroundedrect(2), + shape = utilities.graphics.mkroundedrect(2), border_width = dpi(1), border_color = beautiful.black .. "ee", bg = beautiful.btn_back, @@ -94,7 +94,7 @@ client.connect_signal("request::titlebars", function(c) wibox.widget.base.make_widget(awful.titlebar.widget.iconwidget(c)), buttons = titlebars_buttons, layout = wibox.layout.fixed.horizontal, - clip_shape = utilities.widgets.mkroundedrect(6), + clip_shape = utilities.graphics.mkroundedrect(6), }, widget = wibox.container.margin, right = dpi(2), diff --git a/utilities/README.md b/utilities/README.md index a9a8d3d..5fec229 100644 --- a/utilities/README.md +++ b/utilities/README.md @@ -1,3 +1,3 @@ -# Utilities +# Utilities -Each of the subdirectories within this subdirectory contain anonymous functions one can call to achieve the effect generally indicated by the name of the file containing the function. +Each of the subdirectories within this subdirectory contain anonymous functions one can call to achieve the effect generally indicated by the name of the file containing the function. They have been roughly grouped according to Codeium's suggested categorization (until I think of some better taxonomy). diff --git a/utilities/widgets/crop_surface.lua b/utilities/graphics/crop_surface.lua similarity index 100% rename from utilities/widgets/crop_surface.lua rename to utilities/graphics/crop_surface.lua diff --git a/utilities/graphics/init.lua b/utilities/graphics/init.lua new file mode 100644 index 0000000..0efd752 --- /dev/null +++ b/utilities/graphics/init.lua @@ -0,0 +1,15 @@ +-- crop_surface.lua +-- mkroundedcontainer.lua +-- mkroundedrect.lua +-- random_color.lua +return{ + crop_surface = require(... .. ".crop_surface"), + + + mkroundedcontainer = require(... .. ".mkroundedcontainer"), + mkroundedrect = require(... .. ".mkroundedrect"), + + + + random_color = require(... .. ".random_color"), +} diff --git a/utilities/graphics/mkroundedcontainer.lua b/utilities/graphics/mkroundedcontainer.lua new file mode 100755 index 0000000..6ea7b7b --- /dev/null +++ b/utilities/graphics/mkroundedcontainer.lua @@ -0,0 +1,12 @@ +local mkroundedrect = require("utilities.graphics.mkroundedrect") +local wibox = require("wibox") + +-- make a rounded container for antialiasing purposes +return function(template, bg) + return wibox.widget({ + template, + shape = mkroundedrect(), + bg = bg, + widget = wibox.container.background, + }) +end diff --git a/utilities/widgets/mkroundedrect.lua b/utilities/graphics/mkroundedrect.lua similarity index 100% rename from utilities/widgets/mkroundedrect.lua rename to utilities/graphics/mkroundedrect.lua diff --git a/utilities/widgets/random_color.lua b/utilities/graphics/random_color.lua similarity index 100% rename from utilities/widgets/random_color.lua rename to utilities/graphics/random_color.lua diff --git a/utilities/init.lua b/utilities/init.lua index 039259c..23395ff 100755 --- a/utilities/init.lua +++ b/utilities/init.lua @@ -1,7 +1,8 @@ return { - +layout = require(... .. ".layout"), textual = require(... .. ".textual"), - widgets = require(... .. ".widgets"), + interaction = require(... .. ".interaction"), + graphics = require(... .. ".graphics"), } diff --git a/utilities/widgets/add_buttons.lua b/utilities/interaction/add_buttons.lua similarity index 100% rename from utilities/widgets/add_buttons.lua rename to utilities/interaction/add_buttons.lua diff --git a/utilities/widgets/add_hover.lua b/utilities/interaction/add_hover.lua similarity index 100% rename from utilities/widgets/add_hover.lua rename to utilities/interaction/add_hover.lua diff --git a/utilities/interaction/init.lua b/utilities/interaction/init.lua new file mode 100644 index 0000000..2f04b87 --- /dev/null +++ b/utilities/interaction/init.lua @@ -0,0 +1,12 @@ + + + +-- pointer_on_focus.lua +return{ + add_hover = require(... .. ".add_hover"), + add_buttons = require(... .. ".add_buttons"), + mkbtn = require(... .. ".mkbtn"), + + make_popup_tooltip = require(... .. ".make_popup_tooltip"), + pointer_on_focus = require(... .. ".pointer_on_focus"), +} diff --git a/utilities/interaction/make_popup_tooltip.lua b/utilities/interaction/make_popup_tooltip.lua new file mode 100755 index 0000000..78328d8 --- /dev/null +++ b/utilities/interaction/make_popup_tooltip.lua @@ -0,0 +1,89 @@ +-- _______ __ ______ +-- | | |.---.-.| |--.-----. | __ \.-----.-----.--.--.-----. +-- | || _ || <| -__| | __/| _ | _ | | | _ | +-- |__|_|__||___._||__|__|_____| |___| |_____| __|_____| __| +-- |__| |__| +-- _______ __ __ __ +-- |_ _|.-----.-----.| | |_|__|.-----. +-- | | | _ | _ || | _| || _ | +-- |___| |_____|_____||__|____|__|| __| +-- |__| +-- +---------------------------------------------------------------+ +-- Generates tooltip that popups up upon hovering a button or other widget +-- @param text string included in tooltip +-- @param placement strong location where the tooltip should present itself +local awful = require("awful") +local beautiful = require("beautiful") +local wibox = require("wibox") +local dpi = beautiful.xresources.apply_dpi +local mkroundedrect = require("utilities.graphics.mkroundedcontainer") +local mkroundedcontainer = require("utilities.graphics.mkroundedcontainer") + +return function(text, placement) + local ret = {} + + ret.widget = wibox.widget({ + { + { + id = "image", + image = icons.hints, + forced_height = dpi(12), + forced_width = dpi(12), + halign = "center", + valign = "center", + widget = wibox.widget.imagebox, + }, + { + id = "text", + markup = text or "", + align = "center", + widget = wibox.widget.textbox, + }, + spacing = dpi(7), + layout = wibox.layout.fixed.horizontal, + }, + margins = dpi(12), + widget = wibox.container.margin, + set_text = function(self, t) + self:get_children_by_id("text")[1].markup = t + end, + set_image = function(self, i) + self:get_children_by_id("image")[1].image = i + end, + }) + + ret.popup = awful.popup({ + visible = false, + bg = beautiful.bg_normal .. "00", + fg = beautiful.fg_normal, + ontop = true, + placement = placement or awful.placement.centered, + screen = awful.screen.focused(), + widget = mkroundedcontainer(ret.widget, beautiful.bg_normal), + }) + + local self = ret.popup + + function ret.show() + self.screen = awful.screen.focused() + self.visible = true + end + + function ret.hide() + self.visible = false + end + + function ret.toggle() + if not self.visible and self.screen ~= awful.screen.focused() then + self.screen = awful.screen.focused() + end + self.visible = not self.visible + end + + function ret.attach_to_object(object) + object:connect_signal("mouse::enter", ret.show) + object:connect_signal("mouse::leave", ret.hide) + end + + return ret +end diff --git a/utilities/widgets/mkbtn.lua b/utilities/interaction/mkbtn.lua similarity index 90% rename from utilities/widgets/mkbtn.lua rename to utilities/interaction/mkbtn.lua index 397ad20..8cae646 100755 --- a/utilities/widgets/mkbtn.lua +++ b/utilities/interaction/mkbtn.lua @@ -12,8 +12,8 @@ -- @return button object local wibox = require("wibox") local beautiful = require("beautiful") -local mkroundedrect = require("utilities.widgets.mkroundedrect") -local add_hover = require("utilities.widgets.add_hover") +local mkroundedrect = require("utilities.graphics.mkroundedrect") +local add_hover = require("utilities.interaction.add_hover") local dpi = beautiful.xresources.apply_dpi return function(template, bg, hbg, radius) diff --git a/utilities/widgets/pointer_on_focus.lua b/utilities/interaction/pointer_on_focus.lua similarity index 100% rename from utilities/widgets/pointer_on_focus.lua rename to utilities/interaction/pointer_on_focus.lua diff --git a/utilities/widgets/horizontal_pad.lua b/utilities/layout/horizontal_pad.lua similarity index 100% rename from utilities/widgets/horizontal_pad.lua rename to utilities/layout/horizontal_pad.lua diff --git a/utilities/layout/init.lua b/utilities/layout/init.lua new file mode 100644 index 0000000..629a664 --- /dev/null +++ b/utilities/layout/init.lua @@ -0,0 +1,7 @@ +-- Layout and positioning helper functions + +return{ +horizontal_pad = require(... .. ".horizontal_pad"), +vertical_pad = require(... .. ".vertical_pad"), + +} diff --git a/utilities/widgets/vertical_pad.lua b/utilities/layout/vertical_pad.lua similarity index 100% rename from utilities/widgets/vertical_pad.lua rename to utilities/layout/vertical_pad.lua diff --git a/utilities/widgets/init.lua b/utilities/widgets/init.lua deleted file mode 100644 index 42101ad..0000000 --- a/utilities/widgets/init.lua +++ /dev/null @@ -1,17 +0,0 @@ - --- Anonymous helper functions for use by various widgets. - -return { - add_hover = require(... .. ".add_hover"), - add_buttons = require(... .. ".add_buttons"), - crop_surface = require(... .. ".crop_surface"), - horizontal_pad = require(... .. ".horizontal_pad"), - make_popup_tooltip = require(... .. ".make_popup_tooltip"), - mkbtn = require(... .. ".mkbtn"), - mkroundedcontainer = require(... .. ".mkroundedcontainer"), - mkroundedrect = require(... .. ".mkroundedrect"), - volume_control = require(... .. ".volume_control"), - pointer_on_focus = require(... .. ".pointer_on_focus"), - vertical_pad = require(... .. ".vertical_pad"), - random_color = require(... .. ".random_color"), -} diff --git a/utilities/widgets/make_popup_tooltip.lua b/utilities/widgets/make_popup_tooltip.lua deleted file mode 100755 index 226421b..0000000 --- a/utilities/widgets/make_popup_tooltip.lua +++ /dev/null @@ -1,89 +0,0 @@ --- _______ __ ______ --- | | |.---.-.| |--.-----. | __ \.-----.-----.--.--.-----. --- | || _ || <| -__| | __/| _ | _ | | | _ | --- |__|_|__||___._||__|__|_____| |___| |_____| __|_____| __| --- |__| |__| --- _______ __ __ __ --- |_ _|.-----.-----.| | |_|__|.-----. --- | | | _ | _ || | _| || _ | --- |___| |_____|_____||__|____|__|| __| --- |__| --- +---------------------------------------------------------------+ --- Generates tooltip that popups up upon hovering a button or other widget --- @param text string included in tooltip --- @param placement strong location where the tooltip should present itself -local awful = require("awful") -local beautiful = require("beautiful") -local wibox = require("wibox") -local dpi = beautiful.xresources.apply_dpi -local mkroundedrect = require("utilities.widgets.mkroundedcontainer") -local mkroundedcontainer = require("utilities.widgets.mkroundedcontainer") - -return function(text, placement) - local ret = {} - - ret.widget = wibox.widget({ - { - { - id = "image", - image = icons.hints, - forced_height = dpi(12), - forced_width = dpi(12), - halign = "center", - valign = "center", - widget = wibox.widget.imagebox, - }, - { - id = "text", - markup = text or "", - align = "center", - widget = wibox.widget.textbox, - }, - spacing = dpi(7), - layout = wibox.layout.fixed.horizontal, - }, - margins = dpi(12), - widget = wibox.container.margin, - set_text = function(self, t) - self:get_children_by_id("text")[1].markup = t - end, - set_image = function(self, i) - self:get_children_by_id("image")[1].image = i - end, - }) - - ret.popup = awful.popup({ - visible = false, - bg = beautiful.bg_normal .. "00", - fg = beautiful.fg_normal, - ontop = true, - placement = placement or awful.placement.centered, - screen = awful.screen.focused(), - widget = mkroundedcontainer(ret.widget, beautiful.bg_normal), - }) - - local self = ret.popup - - function ret.show() - self.screen = awful.screen.focused() - self.visible = true - end - - function ret.hide() - self.visible = false - end - - function ret.toggle() - if not self.visible and self.screen ~= awful.screen.focused() then - self.screen = awful.screen.focused() - end - self.visible = not self.visible - end - - function ret.attach_to_object(object) - object:connect_signal("mouse::enter", ret.show) - object:connect_signal("mouse::leave", ret.hide) - end - - return ret -end diff --git a/utilities/widgets/mkroundedcontainer.lua b/utilities/widgets/mkroundedcontainer.lua deleted file mode 100755 index f2df129..0000000 --- a/utilities/widgets/mkroundedcontainer.lua +++ /dev/null @@ -1,12 +0,0 @@ -local mkroundedrect = require("utilities.widgets.mkroundedrect") -local wibox = require("wibox") - --- make a rounded container for antialiasing purposes -return function(template, bg) - return wibox.widget({ - template, - shape = mkroundedrect(), - bg = bg, - widget = wibox.container.background, - }) -end diff --git a/utilities/widgets/volume_control.lua b/utilities/widgets/volume_control.lua deleted file mode 100644 index f52d4e4..0000000 --- a/utilities/widgets/volume_control.lua +++ /dev/null @@ -1,13 +0,0 @@ -return function(step) - local cmd - if step == 0 then - cmd = "pactl set-sink-mute @DEFAULT_SINK@ toggle" - else - sign = step > 0 and "+" or "" - cmd = "pactl set-sink-mute @DEFAULT_SINK@ 0 && pactl set-sink-volume @DEFAULT_SINK@ " - .. sign - .. tostring(step) - .. "%" - end - awful.spawn.with_shell(cmd) -end