diff --git a/awesome/rc.lua b/awesome/rc.lua index 98be6fe..875a6ad 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -7,7 +7,8 @@ -- ╚═╝ ╚═╝ ╚══╝╚══╝ ╚══════╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚═╝ ╚═╝ -- ----------------------------------------------------------------------------------------- -- Initialising, order is important! -require("src.theme.user_variables") +require("src.theme.user_config") +require("src.theme.theme_config") require("src.theme.init") require("src.core.error_handling") require("src.core.signals") @@ -16,5 +17,5 @@ require("src.core.rules") require("src.bindings.global_buttons") require("src.bindings.bind_to_tags") require("src.modules.init") -require("src.tools.auto_starter")(user_vars.autostart) +require("src.tools.auto_starter")(User_config.autostart) require("src.dbus.bluetooth_dbus")() diff --git a/awesome/src/assets/icons/discord-0.0.18.deb b/awesome/src/assets/icons/discord-0.0.18.deb new file mode 100644 index 0000000..59049a1 Binary files /dev/null and b/awesome/src/assets/icons/discord-0.0.18.deb differ diff --git a/awesome/src/assets/icons/fallback.svg b/awesome/src/assets/icons/fallback.svg new file mode 100644 index 0000000..731a5a7 --- /dev/null +++ b/awesome/src/assets/icons/fallback.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/awesome/src/assets/rules.txt b/awesome/src/assets/rules.txt index 9f2298f..bf4237c 100644 --- a/awesome/src/assets/rules.txt +++ b/awesome/src/assets/rules.txt @@ -1 +1 @@ -Lutris;Steam;Io.elementary.appcenter;Repoman;Com.github.donadigo.eddy;Sysmontask;join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=Gnome-calculator;Virt-manager;Gwe;whatsdesk;Totem;steam_app_431960; \ No newline at end of file +Lutris;Steam;Io.elementary.appcenter;Repoman;Com.github.donadigo.eddy;Sysmontask;join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=Gnome-calculator;Virt-manager;Gwe;whatsdesk;Totem;steam_app_431960;Viewer,;Viewer,;Nvidia-settings;openrgb; \ No newline at end of file diff --git a/awesome/src/bindings/bind_to_tags.lua b/awesome/src/bindings/bind_to_tags.lua index ebc6247..9a213da 100644 --- a/awesome/src/bindings/bind_to_tags.lua +++ b/awesome/src/bindings/bind_to_tags.lua @@ -2,7 +2,7 @@ local awful = require("awful") local gears = require("gears") local globalkeys = require("src.bindings.global_keys") -local modkey = user_vars.modkey +local modkey = User_config.modkey for i = 1, 9 do globalkeys = gears.table.join(globalkeys, diff --git a/awesome/src/bindings/client_buttons.lua b/awesome/src/bindings/client_buttons.lua index dcbb7e9..d24d617 100644 --- a/awesome/src/bindings/client_buttons.lua +++ b/awesome/src/bindings/client_buttons.lua @@ -2,7 +2,7 @@ local awful = require("awful") local gears = require("gears") -local modkey = user_vars.modkey +local modkey = User_config.modkey return gears.table.join( awful.button({}, 1, function(c) diff --git a/awesome/src/bindings/client_keys.lua b/awesome/src/bindings/client_keys.lua index 274f1fe..8f5b191 100644 --- a/awesome/src/bindings/client_keys.lua +++ b/awesome/src/bindings/client_keys.lua @@ -2,7 +2,7 @@ local awful = require("awful") local gears = require("gears") -local modkey = user_vars.modkey +local modkey = User_config.modkey return gears.table.join( awful.key( diff --git a/awesome/src/bindings/global_keys.lua b/awesome/src/bindings/global_keys.lua index 7fdb93f..db3d776 100644 --- a/awesome/src/bindings/global_keys.lua +++ b/awesome/src/bindings/global_keys.lua @@ -4,7 +4,7 @@ local awful = require("awful") local hotkeys_popup = require("awful.hotkeys_popup") local ruled = require("ruled") -local modkey = user_vars.modkey +local modkey = User_config.modkey return gears.table.join( awful.key( @@ -90,7 +90,7 @@ return gears.table.join( { modkey }, "#36", function() - awful.spawn(user_vars.terminal) + awful.spawn(User_config.terminal) end, { description = "Open terminal", group = "Applications" } ), @@ -160,7 +160,7 @@ return gears.table.join( { modkey }, "#23", function() - awful.spawn("rofi -show window -theme ~/.config/rofi/window.rasi") + awful.spawn("rofi -kb-accept-entry '!Alt-Tab' -kb-row-down Alt-Tab -show window -theme ~/.config/rofi/window.rasi") end, { descripton = "Client switcher (alt+tab)", group = "Application" } ), @@ -168,7 +168,7 @@ return gears.table.join( { "Mod1" }, "#23", function() - awful.spawn("rofi -show window -theme ~/.config/rofi/window.rasi") + awful.spawn("rofi -kb-accept-entry '!Alt-Tab' -kb-row-down Alt-Tab -show window -theme ~/.config/rofi/window.rasi") end, { descripton = "Client switcher (alt+tab)", group = "Application" } ), @@ -176,7 +176,7 @@ return gears.table.join( { modkey }, "#26", function() - awful.spawn(user_vars.file_manager) + awful.spawn(User_config.file_manager) end, { descripton = "Open file manager", group = "System" } ), @@ -192,7 +192,7 @@ return gears.table.join( {}, "#107", function() - awful.spawn(user_vars.screenshot_program) + awful.spawn(User_config.screenshot_program) end, { description = "Screenshot", group = "Applications" } ), @@ -239,7 +239,8 @@ return gears.table.join( awful.spawn.easy_async_with_shell( "pkexec xfpm-power-backlight-helper --get-brightness", function(stdout) - awful.spawn.easy_async_with_shell("pkexec xfpm-power-backlight-helper --set-brightness " .. tostring(tonumber(stdout) + BACKLIGHT_SEPS), function(stdou2) + awful.spawn.easy_async_with_shell("pkexec xfpm-power-backlight-helper --set-brightness " .. + tostring(tonumber(stdout) + BACKLIGHT_SEPS), function(stdou2) end) awesome.emit_signal("module::brightness_osd:show", true) @@ -257,7 +258,8 @@ return gears.table.join( awful.spawn.easy_async_with_shell( "pkexec xfpm-power-backlight-helper --get-brightness", function(stdout) - awful.spawn.easy_async_with_shell("pkexec xfpm-power-backlight-helper --set-brightness " .. tostring(tonumber(stdout) - BACKLIGHT_SEPS), function(stdout2) + awful.spawn.easy_async_with_shell("pkexec xfpm-power-backlight-helper --set-brightness " .. + tostring(tonumber(stdout) - BACKLIGHT_SEPS), function(stdout2) end) awesome.emit_signal("module::brightness_osd:show", true) @@ -322,7 +324,8 @@ return gears.table.join( return end end - awful.spawn.with_shell("echo -n '" .. stdout:gsub("\n", "") .. ";' >> ~/.config/awesome/src/assets/rules.txt") + awful.spawn.with_shell("echo -n '" .. + stdout:gsub("\n", "") .. ";' >> ~/.config/awesome/src/assets/rules.txt") local c = mouse.screen.selected_tag:clients() for j, client in ipairs(c) do if client.class:match(stdout:gsub("\n", "")) then diff --git a/awesome/src/core/notifications.lua b/awesome/src/core/notifications.lua index ec8138a..4e3d1d6 100644 --- a/awesome/src/core/notifications.lua +++ b/awesome/src/core/notifications.lua @@ -28,6 +28,8 @@ naughty.config.defaults.border_width = dpi(4) naughty.config.defaults.border_color = color["Grey800"] naughty.config.defaults.spacing = dpi(10) +Theme.notification_spacing = dpi(20) + naughty.connect_signal( 'request::icon', function(n, context, hints) @@ -44,7 +46,7 @@ naughty.connect_signal( naughty.connect_signal( "request::display", function(n) - if user_vars.dnd then + if User_config.dnd then n:destroy() else if n.urgency == "critical" then @@ -89,6 +91,8 @@ naughty.connect_signal( { { id = "icon_role", + valign = "center", + halign = "center", widget = wibox.widget.imagebox }, id = "centered", @@ -179,6 +183,8 @@ naughty.connect_signal( { image = gears.color.recolor_image(icondir .. "notification-outline.svg", color["Teal200"]), resize = false, + valign = "center", + halign = "center", widget = wibox.widget.imagebox }, right = dpi(5), @@ -214,7 +220,7 @@ naughty.connect_signal( { { { - font = user_vars.font.specify .. ", 10", + font = User_config.font.specify .. ", 10", text = "✕", align = "center", valign = "center", @@ -262,6 +268,8 @@ naughty.connect_signal( image = n.icon, resize = true, widget = wibox.widget.imagebox, + valign = "center", + halign = "center", clip_shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, 10) end @@ -328,7 +336,8 @@ naughty.connect_signal( widget = wibox.container.background } - local close = w_template.max_size.min_size.widget_layout.arc_app_bg.arc_app_layout.arc_app_layout_2.arc_margin.const.background + local close = w_template.max_size.min_size.widget_layout.arc_app_bg.arc_app_layout.arc_app_layout_2.arc_margin. + const.background local arc = close.arc_chart local timeout = n.timeout diff --git a/awesome/src/core/rules.lua b/awesome/src/core/rules.lua index fe5106e..a81dd92 100644 --- a/awesome/src/core/rules.lua +++ b/awesome/src/core/rules.lua @@ -39,14 +39,37 @@ awful.rules.rules = { "pop-up" } }, - properties = { floating = true, titlebars_enabled = true } + properties = { + floating = true, + titlebars_enabled = true + } }, { id = "titlebar", rule_any = { - type = { "normal", "dialog", "modal", "utility" } + type = { + "normal", + "dialog", + "modal", + "utility" + } }, - properties = { titlebars_enabled = true } + properties = { + titlebars_enabled = true + } + }, + rule_any = { + class = { + 'Wine', + 'dolphin-emu', + 'Steam', + 'Citra', + }, + name = { 'Steam' } + }, + properties = { + skip_decoration = true, + placement = awful.placement.centered } } diff --git a/awesome/src/core/signals.lua b/awesome/src/core/signals.lua index 002291d..956f2a3 100644 --- a/awesome/src/core/signals.lua +++ b/awesome/src/core/signals.lua @@ -1,9 +1,7 @@ ---@diagnostic disable: undefined-field -- Awesome Libs local awful = require("awful") -local beautiful = require("beautiful") local gears = require("gears") -local wibox = require("wibox") screen.connect_signal( "added", @@ -50,8 +48,8 @@ client.connect_signal( end ) -client.connect_signal( - 'tag::switched', +tag.connect_signal( + 'property::selected', function(c) if #awful.screen.focused().clients > 0 then awful.screen.focused().clients[1]:emit_signal( @@ -79,22 +77,6 @@ client.connect_signal( end ) --- Workaround for focused border color, why in the love of god doesnt it work with --- beautiful.border_focus -client.connect_signal( - "focus", - function(c) - c.border_color = "#616161" - end -) - -client.connect_signal( - "unfocus", - function(c) - c.border_color = beautiful.border_normal - end -) - --- Takes a wibox.container.background and connects four signals to it ---@param widget widget.container.background ---@param bg string diff --git a/awesome/src/dbus/bluetooth_dbus.lua b/awesome/src/dbus/bluetooth_dbus.lua index ce453e0..8c51a0a 100644 --- a/awesome/src/dbus/bluetooth_dbus.lua +++ b/awesome/src/dbus/bluetooth_dbus.lua @@ -28,12 +28,16 @@ return function() interface = "org.freedesktop.DBus.Properties", path = object_path } - awesome.emit_signal("bluetooth::scan") - if device.Name ~= nil or device.Alias ~= nil then + + if device.Name ~= "" and device.Name ~= nil then device_properties:connect_signal(function() - awesome.emit_signal("bluetooth::device_changed", device, battery) + naughty.notification { + title = "Bluetooth Device Connected", + message = device.Name, + icon = require("awful").util.getdir("config") .. "src/assets/icons/bluetooth/bluetooth.svg" + } + awesome.emit_signal("device_added", object_path, device, battery) end, "PropertiesChanged") - awesome.emit_signal("bluetooth::device_changed", device, battery) end end end @@ -87,16 +91,10 @@ return function() "PropertiesChanged" ) - awesome.connect_signal( - "bluetooth::scan", - function() - Adapter:StartDiscovery() - end - ) - AdapterProperties:connect_signal( function(data) if data.Powered ~= nil then + awesome.emit_signal("state", data.Powered) if data.Powered then Adapter:StartDiscovery() end diff --git a/awesome/src/modules/application_launcher/application.lua b/awesome/src/modules/application_launcher/application.lua new file mode 100644 index 0000000..e69de29 diff --git a/awesome/src/modules/application_launcher/init.lua b/awesome/src/modules/application_launcher/init.lua new file mode 100644 index 0000000..27ba9da --- /dev/null +++ b/awesome/src/modules/application_launcher/init.lua @@ -0,0 +1,25 @@ +-------------------------------------- +-- This is the application launcher -- +-------------------------------------- + +-- Awesome Libs +local awful = require("awful") +local color = require("src.theme.colors") +local dpi = require("beautiful").xresources.apply_dpi +local gears = require("gears") +local wibox = require("wibox") + +-- Icon directory path +local icondir = awful.util.getdir("config") .. "src/assets/icons/application_launcher/" + +return function(s) + + local applicaton_launcher = wibox.widget { + + } + + local application_container = awful.popup { + + } + +end diff --git a/awesome/src/modules/application_launcher/searchbar.lua b/awesome/src/modules/application_launcher/searchbar.lua new file mode 100644 index 0000000..e69de29 diff --git a/awesome/src/modules/bluetooth_controller.lua b/awesome/src/modules/bluetooth_controller.lua index 43a61cb..4fd8c1e 100644 --- a/awesome/src/modules/bluetooth_controller.lua +++ b/awesome/src/modules/bluetooth_controller.lua @@ -4,10 +4,8 @@ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") -local naughty = require("naughty") local wibox = require("wibox") local rubato = require("src.lib.rubato") @@ -24,7 +22,8 @@ return function(s) { { { - image = gears.color.recolor_image(icondir .. icon .. ".svg", color["Purple200"]), + image = gears.color.recolor_image( + icondir .. icon .. ".svg", Theme_config.bluetooth_controller.icon_color), id = "icon", resize = false, valign = "center", @@ -50,7 +49,7 @@ return function(s) text = "Connecting...", id = "connecting", visible = false, - font = user_vars.font.specify .. ", regular 10", + font = User_config.font.specify .. ", regular 10", widget = wibox.widget.textbox }, id = "alias_container", @@ -95,7 +94,7 @@ return function(s) shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, dpi(4)) end, - bg = color["Blue200"], + bg = Theme_config.bluetooth_controller.con_button_color, widget = wibox.container.background }, id = "margin0", @@ -109,23 +108,24 @@ return function(s) margins = dpi(5), widget = wibox.container.margin }, - bg = color["Grey900"], - fg = color["LightBlue200"], - border_color = color["Grey800"], - border_width = dpi(2), + bg = Theme_config.bluetooth_controller.device_bg, + fg = Theme_config.bluetooth_controller.device_fg, + border_color = Theme_config.bluetooth_controller.device_border_color, + border_width = Theme_config.bluetooth_controller.device_border_width, id = "background", shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end, widget = wibox.container.background } --! using :Connect freezes awesome, either find a solution or switch to console commands if device.Connected then - device_widget:get_children_by_id("con")[1].image = gears.color.recolor_image(icondir .. "link-off.svg", color["Grey900"]) + device_widget:get_children_by_id("con")[1].image = gears.color.recolor_image(icondir .. "link-off.svg", + Theme_config.bluetooth_controller.icon_color_dark) device_widget:connect_signal( "button::press", - function(c, d, e, key) + function(_, _, _, key) if key == 1 then device:Disconnect() awesome.emit_signal("bluetooth::connect", device) @@ -133,10 +133,11 @@ return function(s) end ) else - device_widget:get_children_by_id("con")[1].image = gears.color.recolor_image(icondir .. "link.svg", color["Grey900"]) + device_widget:get_children_by_id("con")[1].image = gears.color.recolor_image(icondir .. "link.svg", + Theme_config.bluetooth_controller.icon_color_dark) device_widget:connect_signal( "button::press", - function(c, d, e, key) + function(_, _, _, key) if key == 1 then device:Connect() awesome.emit_signal("bluetooth::disconnect", device) @@ -144,7 +145,8 @@ return function(s) end ) end - Hover_signal(device_widget, '#313131', color["LightBlue100"]) + Hover_signal(device_widget, Theme_config.bluetooth_controller.device_bg_hover, + Theme_config.bluetooth_controller.device_fg_hover) return device_widget end @@ -168,10 +170,10 @@ return function(s) widget = wibox.container.constraint }, id = "connected_device_background", - border_color = color["Grey800"], - border_width = dpi(2), + border_color = Theme_config.bluetooth_controller.con_device_border_color, + border_width = Theme_config.bluetooth_controller.con_device_border_width, shape = function(cr, width, height) - gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, 4) + gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, dpi(4)) end, widget = wibox.container.background } @@ -196,10 +198,10 @@ return function(s) widget = wibox.container.constraint }, id = "discovered_device_background", - border_color = color["Grey800"], - border_width = dpi(2), + border_color = Theme_config.bluetooth_controller.con_device_border_color, + border_width = Theme_config.bluetooth_controller.con_device_border_width, shape = function(cr, width, height) - gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, 4) + gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, dpi(4)) end, widget = wibox.container.background } @@ -214,8 +216,11 @@ return function(s) { { resize = false, - image = gears.color.recolor_image(icondir .. "menu-down.svg", color["Purple200"]), + image = gears.color.recolor_image(icondir .. "menu-down.svg", + Theme_config.bluetooth_controller.connected_icon_color), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", id = "icon" }, id = "center", @@ -225,7 +230,7 @@ return function(s) }, { { - text = "Coupled Devices", + text = "Paired Devices", widget = wibox.widget.textbox, id = "device_name" }, @@ -236,10 +241,10 @@ return function(s) layout = wibox.layout.fixed.horizontal }, id = "connected_bg", - bg = color["Grey800"], - fg = color["Purple200"], + bg = Theme_config.bluetooth_controller.connected_bg, + fg = Theme_config.bluetooth_controller.connected_fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end, widget = wibox.container.background }, @@ -257,8 +262,11 @@ return function(s) { { resize = false, - image = gears.color.recolor_image(icondir .. "menu-down.svg", color["LightBlueA200"]), + image = gears.color.recolor_image(icondir .. "menu-down.svg", + Theme_config.bluetooth_controller.discovered_icon_color), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", id = "icon", }, id = "center", @@ -279,10 +287,10 @@ return function(s) layout = wibox.layout.fixed.horizontal }, id = "discovered_bg", - bg = color["Grey800"], - fg = color["Blue200"], + bg = Theme_config.bluetooth_controller.discovered_bg, + fg = Theme_config.bluetooth_controller.discovered_fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end, widget = wibox.container.background }, @@ -305,9 +313,9 @@ return function(s) shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, dpi(8)) end, - border_color = color["Grey800"], - border_width = dpi(4), - bg = color["Grey900"], + border_color = Theme_config.bluetooth_controller.container_border_color, + border_width = Theme_config.bluetooth_controller.container_border_width, + bg = Theme_config.bluetooth_controller.container_bg, id = "background", widget = wibox.container.background }, @@ -320,13 +328,15 @@ return function(s) local bluetooth_controller_container = awful.popup { widget = wibox.container.background, ontop = true, - bg = color["Grey900"], + bg = Theme_config.bluetooth_controller.container_bg, stretch = false, visible = false, screen = s, - placement = function(c) awful.placement.align(c, { position = "top_right", margins = { right = dpi(380), top = dpi(60) } }) end, + placement = function(c) awful.placement.align(c, + { position = "top_right", margins = { right = dpi(380), top = dpi(60) } }) + end, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 12) + gears.shape.rounded_rect(cr, width, height, dpi(12)) end } @@ -404,15 +414,17 @@ return function(s) rubato_timer.target = dpi(210) end connected_margin.connected_bg.shape = function(cr, width, height) - gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, 4) + gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, dpi(4)) end - connected.icon:set_image(gears.color.recolor_image(icondir .. "menu-up.svg", color["Purple200"])) + connected.icon:set_image(gears.color.recolor_image(icondir .. "menu-up.svg", + Theme_config.bluetooth_controller.connected_icon_color)) else rubato_timer.target = 0 connected_bg.shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, 4) end - connected.icon:set_image(gears.color.recolor_image(icondir .. "menu-down.svg", color["Purple200"])) + connected.icon:set_image(gears.color.recolor_image(icondir .. "menu-down.svg", + Theme_config.bluetooth_controller.connected_icon_color)) end end ) @@ -446,15 +458,17 @@ return function(s) rubato_timer.target = dpi(20) end discovered_margin.discovered_bg.shape = function(cr, width, height) - gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, 4) + gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, dpi(4)) end - discovered.icon:set_image(gears.color.recolor_image(icondir .. "menu-up.svg", color["LightBlue200"])) + discovered.icon:set_image(gears.color.recolor_image(icondir .. "menu-up.svg", + Theme_config.bluetooth_controller.discovered_icon_color)) else - rubato_timer.target = dpi(0) + rubato_timer.target = 0 discovered_bg.shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, 4) end - discovered.icon:set_image(gears.color.recolor_image(icondir .. "menu-down.svg", color["LightBlue200"])) + discovered.icon:set_image(gears.color.recolor_image(icondir .. "menu-down.svg", + Theme_config.bluetooth_controller.discovered_icon_color)) end end ) diff --git a/awesome/src/modules/brightness_osd.lua b/awesome/src/modules/brightness_osd.lua index d90730b..8dce657 100644 --- a/awesome/src/modules/brightness_osd.lua +++ b/awesome/src/modules/brightness_osd.lua @@ -28,159 +28,91 @@ return function(s) local brightness_osd_widget = wibox.widget { { { - { - { - nil, - { - nil, - { - id = "icon", - forced_height = dpi(220), - image = icondir .. "brightness-high.svg", - widget = wibox.widget.imagebox - }, - nil, - expand = "none", - id = "icon_margin2", - layout = wibox.layout.align.vertical - }, - nil, - id = "icon_margin1", - expand = "none", - layout = wibox.layout.align.horizontal - }, + { -- Brightness Icon + image = gears.color.recolor_image(icondir .. "brightness-high.svg", Theme_config.brightness_osd.icon_color), + valign = "center", + halign = "center", + resize = false, + id = "icon", + widget = wibox.widget.imagebox + }, + { -- Brightness Bar { { - id = "label", - text = "Brightness", - align = "left", - valign = "center", - widget = wibox.widget.textbox + id = "progressbar1", + color = Theme_config.brightness_osd.bar_bg_active, + background_color = Theme_config.brightness_osd.bar_bg, + max_value = 100, + value = 50, + forced_height = dpi(6), + shape = function(cr, width, height) + gears.shape.rounded_bar(cr, width, height, dpi(6)) + end, + widget = wibox.widget.progressbar }, - nil, - { - id = "value", - text = "0%", - align = "center", - valign = "center", - widget = wibox.widget.textbox - }, - id = "label_value_layout", - forced_height = dpi(48), - layout = wibox.layout.align.horizontal, - }, - { - { - id = "brightness_slider", - bar_shape = gears.shape.rounded_rect, - bar_height = dpi(10), - bar_color = color["Grey800"] .. "88", - bar_active_color = "#ffffff", - handle_color = "#ffffff", - handle_shape = gears.shape.circle, - handle_width = dpi(10), - handle_border_color = color["White"], - maximum = 100, - widget = wibox.widget.slider - }, - id = "slider_layout", - forced_height = dpi(24), + id = "progressbar_container2", + halign = "center", + valign = "center", widget = wibox.container.place }, - id = "icon_slider_layout", - spacing = dpi(0), - layout = wibox.layout.align.vertical + id = "progressbar_container", + width = dpi(240), + heigth = dpi(20), + stragety = "max", + widget = wibox.container.constraint }, - id = "osd_layout", - layout = wibox.layout.align.vertical + id = "layout1", + spacing = dpi(10), + layout = wibox.layout.fixed.horizontal }, - id = "container", - left = dpi(24), - right = dpi(24), + id = "margin", + margins = dpi(10), widget = wibox.container.margin }, - bg = color["Grey900"] .. "88", - widget = wibox.container.background, - ontop = true, - visible = true, - type = "notification", - forced_height = dpi(300), forced_width = dpi(300), - offset = dpi(5), + forced_height = dpi(80), + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, dpi(12)) + end, + border_color = Theme_config.brightness_osd.border_color, + border_width = Theme_config.brightness_osd.border_width, + fg = Theme_config.brightness_osd.fg, + bg = Theme_config.brightness_osd.bg, + widget = wibox.container.background } - brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:connect_signal( - "property::value", - function() - awful.spawn.easy_async_with_shell( - "pkexec xfpm-power-backlight-helper --get-brightness", - function(stdout) - local brightness_value = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100) - brightness_osd_widget.container.osd_layout.icon_slider_layout.label_value_layout.value:set_text(tostring(brightness_value) .. "%") - - awesome.emit_signal( - "widget::brightness:update", - brightness_value - ) - - if awful.screen.focused().show_brightness_osd then - awesome.emit_signal( - "module::brightness_osd:show", - true - ) - end - - local icon = icondir .. "brightness" - if brightness_value >= 0 and brightness_value < 34 then - icon = icon .. "-low" - elseif brightness_value >= 34 and brightness_value < 67 then - icon = icon .. "-medium" - elseif brightness_value >= 67 then - icon = icon .. "-high" - end - brightness_osd_widget.container.osd_layout.icon_slider_layout.icon_margin1.icon_margin2.icon:set_image(icon .. ".svg") - awesome.emit_signal("update::backlight_widget", brightness_value, icon .. ".svg") - end - ) - end - ) - local update_slider = function() awful.spawn.easy_async_with_shell( [[ pkexec xfpm-power-backlight-helper --get-brightness ]], function(stdout) - stdout = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100) - brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(stdout) + local brightness_value = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100) + brightness_osd_widget:get_children_by_id("progressbar")[1].value = stdout + + local icon = icondir .. "brightness" + if brightness_value >= 0 and brightness_value < 34 then + icon = icon .. "-low" + elseif brightness_value >= 34 and brightness_value < 67 then + icon = icon .. "-medium" + elseif brightness_value >= 67 then + icon = icon .. "-high" + end + brightness_osd_widget:get_children_by_id("icon"):set_image(gears.color.recolor_image(icon .. ".svg", + Theme_config.brightness_osd.icon_color)) end ) end - awesome.connect_signal( - "module::brightness_slider:update", - function() - update_slider() - end - ) - - awesome.connect_signal( - "widget::brightness:update", - function(value) - brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(tonumber(value)) - end - ) - update_slider() local brightness_container = awful.popup { - widget = wibox.container.background, + widget = {}, ontop = true, - bg = color["Grey900"] .. "00", stretch = false, visible = false, screen = s, - placement = function(c) awful.placement.centered(c, { margins = { top = dpi(200) } }) end, + placement = function(c) awful.placement.bottom_left(c, { margins = dpi(20) }) end, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 15) + gears.shape.rounded_rect(cr, width, height, dpi(14)) end } @@ -200,36 +132,14 @@ return function(s) awesome.connect_signal( "widget::brightness_osd:rerun", function() + brightness_container.visible = true if hide_brightness_osd.started then hide_brightness_osd:again() + update_slider() else hide_brightness_osd:start() + update_slider() end end ) - - awesome.connect_signal( - "module::brightness_osd:show", - function() - if s == mouse.screen then - brightness_container.visible = true - end - end - ) - - brightness_container:connect_signal( - "mouse::enter", - function() - brightness_container.visible = true - hide_brightness_osd:stop() - end - ) - - brightness_container:connect_signal( - "mouse::leave", - function() - brightness_container.visible = true - hide_brightness_osd:again() - end - ) end diff --git a/awesome/src/modules/crylia_bar/center_bar.lua b/awesome/src/modules/crylia_bar/center_bar.lua index 3da39a9..27dbf49 100644 --- a/awesome/src/modules/crylia_bar/center_bar.lua +++ b/awesome/src/modules/crylia_bar/center_bar.lua @@ -19,7 +19,7 @@ return function(s, widgets) maximum_width = dpi(500), placement = function(c) awful.placement.top(c, { margins = dpi(10) }) end, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end } @@ -27,42 +27,42 @@ return function(s, widgets) top = 55 } - local function prepare_widgets(widgets) + local function prepare_widgets(w) local layout = { - forced_height = 45, + forced_height = dpi(50), layout = wibox.layout.fixed.horizontal } - for i, widget in pairs(widgets) do + for i, widget in pairs(w) do if i == 1 then table.insert(layout, { - widget, - left = dpi(6), - right = dpi(6), - top = dpi(6), - bottom = dpi(6), - widget = wibox.container.margin - }) - elseif i == #widgets then + widget, + left = dpi(6), + right = dpi(6), + top = dpi(6), + bottom = dpi(6), + widget = wibox.container.margin + }) + elseif i == #w then table.insert(layout, { - widget, - left = dpi(3), - right = dpi(6), - top = dpi(6), - bottom = dpi(6), - widget = wibox.container.margin - }) + widget, + left = dpi(3), + right = dpi(6), + top = dpi(6), + bottom = dpi(6), + widget = wibox.container.margin + }) else table.insert(layout, { - widget, - left = dpi(3), - right = dpi(3), - top = dpi(6), - bottom = dpi(6), - widget = wibox.container.margin - }) + widget, + left = dpi(3), + right = dpi(3), + top = dpi(6), + bottom = dpi(6), + widget = wibox.container.margin + }) end end return layout @@ -78,45 +78,45 @@ return function(s, widgets) client.connect_signal( "manage", function(c) - if #s.selected_tag:clients() < 1 then - top_center.visible = false - else - top_center.visible = true + if #s.selected_tag:clients() < 1 then + top_center.visible = false + else + top_center.visible = true + end end - end ) client.connect_signal( "unmanage", function(c) - if #s.selected_tag:clients() < 1 then - top_center.visible = false - else - top_center.visible = true + if #s.selected_tag:clients() < 1 then + top_center.visible = false + else + top_center.visible = true + end end - end ) client.connect_signal( - "tag::switched", + "property::selected", function(c) - if #s.selected_tag:clients() < 1 then - top_center.visible = false - else - top_center.visible = true + if #s.selected_tag:clients() < 1 then + top_center.visible = false + else + top_center.visible = true + end end - end ) awesome.connect_signal( "refresh", function(c) - if #s.selected_tag:clients() < 1 then - top_center.visible = false - else - top_center.visible = true + if #s.selected_tag:clients() < 1 then + top_center.visible = false + else + top_center.visible = true + end end - end ) end diff --git a/awesome/src/modules/crylia_bar/dock.lua b/awesome/src/modules/crylia_bar/dock.lua index 55d028d..7537d2f 100644 --- a/awesome/src/modules/crylia_bar/dock.lua +++ b/awesome/src/modules/crylia_bar/dock.lua @@ -8,31 +8,38 @@ local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") +local desktop_parser = require("src.tools.desktop_parser") + return function(screen, programs) - local function create_dock_element(class, program, name, user_icon, is_steam, size) - if program == nil or class == nil then + local function create_dock_element(program, size) + if not program then return end - is_steam = is_steam or false - user_icon = user_icon or nil + local dock_element = wibox.widget { { { { - resize = true, - forced_width = size, - forced_height = size, - image = user_icon or Get_icon(user_vars.icon_theme, nil, program, class, is_steam), - widget = wibox.widget.imagebox, - id = "icon", + { + resize = true, + widget = wibox.widget.imagebox, + valign = "center", + halign = "center", + id = "icon", + }, + id = "icon_container", + strategy = "exact", + width = size, + height = size, + widget = wibox.container.constraint }, margins = dpi(5), widget = wibox.container.margin, id = "margin" }, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 10) + gears.shape.rounded_rect(cr, width, height, dpi(10)) end, bg = color["Grey900"], widget = wibox.container.background, @@ -44,8 +51,10 @@ return function(screen, programs) widget = wibox.container.margin } + dock_element.background.margin.icon_container.icon.image = xdg_icon_lookup:find_icon(program["Icon"], 64) + for _, c in ipairs(client.get()) do - if string.lower(c.class):match(program) and c == client.focus then + if string.lower(c.class):match(program["Icon"]) and c == client.focus then dock_element.background.bg = color["Grey800"] end end @@ -54,18 +63,16 @@ return function(screen, programs) dock_element:connect_signal( "button::press", - function() - if is_steam then - awful.spawn("steam steam://rungameid/" .. program) - else - awful.spawn(program) + function(_, _, _, button) + if button == 1 then + awful.spawn(program["Exec"]) end end ) awful.tooltip { objects = { dock_element }, - text = name, + text = program["Name"], mode = "outside", preferred_alignments = "middle", margins = dpi(10) @@ -81,10 +88,10 @@ return function(screen, programs) visible = true, screen = screen, type = "dock", - height = user_vars.dock_icon_size + 10, + height = User_config.dock_icon_size + 10, placement = function(c) awful.placement.bottom(c, { margins = dpi(10) }) end, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 15) + gears.shape.rounded_rect(cr, width, height, dpi(16)) end } @@ -97,14 +104,14 @@ return function(screen, programs) type = "dock", id = "fakedock", height = dpi(10), - placement = function(c) awful.placement.bottom(c, { margins = dpi(0) }) end, + placement = function(c) awful.placement.bottom(c) end, } local function get_dock_elements(pr) local dock_elements = { layout = wibox.layout.fixed.horizontal } for i, p in ipairs(pr) do - dock_elements[i] = create_dock_element(p[1], p[2], p[3], p[4], p[5], user_vars.dock_icon_size) + dock_elements[i] = create_dock_element(desktop_parser(p), User_config.dock_icon_size) end return dock_elements @@ -118,7 +125,7 @@ return function(screen, programs) for i = 0, amount, 1 do fake_elements[i] = wibox.widget { bg = '00000000', - forced_width = user_vars.dock_icon_size + dpi(20), + forced_width = User_config.dock_icon_size + dpi(20), forced_height = dpi(10), id = "fake", widget = wibox.container.background @@ -134,27 +141,31 @@ return function(screen, programs) local indicators = { layout = wibox.layout.flex.horizontal, spacing = dpi(5) } local col = color["Grey600"] for i, c in ipairs(clients) do - if string.lower(c.class or c.name):match(string.lower(pr[1]) or string.lower(pr[2])) then - if c == client.focus then - col = color["YellowA200"] - elseif c.urgent then - col = color["RedA200"] - elseif c.maximized then - col = color["GreenA200"] - elseif c.minimized then - col = color["BlueA200"] - elseif c.fullscreen then - col = color["PinkA200"] - else - col = color["Grey600"] + local icon = desktop_parser(pr) + if icon then + local icon_name = icon["Icon"] or "" + if icon_name:match(string.lower(c.class or c.name or nil)) then + if c == client.focus then + col = color["YellowA200"] + elseif c.urgent then + col = color["RedA200"] + elseif c.maximized then + col = color["GreenA200"] + elseif c.minimized then + col = color["BlueA200"] + elseif c.fullscreen then + col = color["PinkA200"] + else + col = color["Grey600"] + end + indicators[i] = wibox.widget { + widget = wibox.container.background, + shape = gears.shape.rounded_rect, + forced_height = dpi(3), + bg = col, + forced_width = dpi(5), + } end - indicators[i] = wibox.widget { - widget = wibox.container.background, - shape = gears.shape.rounded_rect, - forced_height = dpi(3), - bg = col, - forced_width = dpi(5), - } end end container[index] = wibox.widget { @@ -206,7 +217,7 @@ return function(screen, programs) if not c.minimized then local y = c:geometry().y local h = c.height - if (y + h) >= s.geometry.height - user_vars.dock_icon_size - 35 then + if (y + h) >= s.geometry.height - User_config.dock_icon_size - 35 then dock.visible = false return else @@ -304,10 +315,4 @@ return function(screen, programs) dock_intelligent_hide:again() end ) - - dock:setup { - get_dock_elements(programs), - create_incicator_widget(programs), - layout = wibox.layout.fixed.vertical - } end diff --git a/awesome/src/modules/crylia_bar/init.lua b/awesome/src/modules/crylia_bar/init.lua index 6dbda0a..38af29c 100644 --- a/awesome/src/modules/crylia_bar/init.lua +++ b/awesome/src/modules/crylia_bar/init.lua @@ -3,50 +3,71 @@ -------------------------------------------------------------------------------------------------------------- return function(s) + xdg_icon_lookup = require("src.tools.xdg_icon_lookup")() - -- Every Widget - --[[ - If you are going to use a widget on a single screen only, put it inside the s.index == X where X is the screen number. - This will lead to better performance and prevent widgets to be loaded but not used - --]] - s.audio = require("src.widgets.audio")(s) - s.date = require("src.widgets.date")() - s.clock = require("src.widgets.clock")() - s.layoutlist = require("src.widgets.layout_list")() - s.powerbutton = require("src.widgets.power")() - s.kblayout = require("src.widgets.kblayout")(s) - s.taglist = require("src.widgets.taglist")(s) - s.tasklist = require("src.widgets.tasklist")(s) - -- s.battery = require("src.widgets.battery")() - -- s.bluetooth = require("src.widgets.bluetooth")() - -- s.cpu_freq = require("src.widgets.cpu_info")("freq", "average") - -- s.systray = require("src.widgets.systray")(s) - -- s.cpu_usage = require("src.widgets.cpu_info")("usage") - -- s.cpu_temp = require("src.widgets.cpu_info")("temp") - -- s.gpu_usage = require("src.widgets.gpu_info")("usage") - -- s.gpu_temp = require("src.widgets.gpu_info")("temp") - -- s.network = require("src.widgets.network")() - -- s.ram_info = require("src.widgets.ram_info")() - - if s.index == 1 then - s.systray = require("src.widgets.systray")(s) - s.cpu_usage = require("src.widgets.cpu_info")("usage") - s.cpu_temp = require("src.widgets.cpu_info")("temp") - s.gpu_usage = require("src.widgets.gpu_info")("usage") - s.gpu_temp = require("src.widgets.gpu_info")("temp") - - require("src.modules.crylia_bar.left_bar")(s, { s.layoutlist, s.systray, s.taglist }) - require("src.modules.crylia_bar.center_bar")(s, { s.tasklist }) - require("src.modules.crylia_bar.right_bar")(s, { s.gpu_usage, s.gpu_temp, s.cpu_usage, s.cpu_temp, s.audio, s.kblayout, s.date, s.clock, s.powerbutton }) - require("src.modules.crylia_bar.dock")(s, user_vars.dock_programs) + ---Lookup function to return the widget from its easy name string + ---@param widgets table + ---@return widget + local function get_widgets(widgets) + local widget_table = {} + if widgets then + for _, widget in ipairs(widgets) do + if widget == "Audio" then + table.insert(widget_table, require("src.widgets.audio")(s)) + elseif widget == "Battery" then + table.insert(widget_table, require("src.widgets.battery")(User_config.battery_path)) + elseif widget == "Bluetooth" then + table.insert(widget_table, require("src.widgets.bluetooth")()) + elseif widget == "Clock" then + table.insert(widget_table, require("src.widgets.clock")()) + elseif widget == "Cpu Frequency" then + table.insert(widget_table, require("src.widgets.cpu_info")("freq", User_config.cpu_frequency)) + elseif widget == "Cpu Temperature" then + table.insert(widget_table, require("src.widgets.cpu_info")("temp")) + elseif widget == "Cpu Usage" then + table.insert(widget_table, require("src.widgets.cpu_info")("usage")) + elseif widget == "Date" then + table.insert(widget_table, require("src.widgets.date")()) + elseif widget == "Gpu Temperature" then + table.insert(widget_table, require("src.widgets.gpu_info")("temp")) + elseif widget == "Gpu Usage" then + table.insert(widget_table, require("src.widgets.gpu_info")("usage")) + elseif widget == "Keyboard Layout" then + table.insert(widget_table, require("src.widgets.kblayout")(s)) + elseif widget == "Tiling Layout" then + table.insert(widget_table, require("src.widgets.layout_list")()) + elseif widget == "Network" then + table.insert(widget_table, require("src.widgets.network")()) + elseif widget == "Power Button" then + table.insert(widget_table, require("src.widgets.power")()) + elseif widget == "Ram Usage" then + table.insert(widget_table, require("src.widgets.ram_info")()) + elseif widget == "Systray" then + table.insert(widget_table, require("src.widgets.systray")(s)) + elseif widget == "Taglist" then + table.insert(widget_table, require("src.widgets.taglist")(s)) + elseif widget == "Tasklist" then + table.insert(widget_table, require("src.widgets.tasklist")(s)) + end + end + end + return widget_table end - if s.index == 2 then - s.network = require("src.widgets.network")() - s.ram_info = require("src.widgets.ram_info")() - - require("src.modules.crylia_bar.left_bar")(s, { s.layoutlist, s.taglist }) - require("src.modules.crylia_bar.center_bar")(s, { s.tasklist }) - require("src.modules.crylia_bar.right_bar")(s, { s.ram_info, s.audio, s.kblayout, s.network, s.date, s.clock, s.powerbutton }) + if User_config.widgets then + for index, screen in ipairs(User_config.widgets) do + if index == s.index then + if screen.left_bar then + require("src.modules.crylia_bar.left_bar")(s, get_widgets(screen.left_bar)) + end + if screen.center_bar then + require("src.modules.crylia_bar.center_bar")(s, get_widgets(screen.center_bar)) + end + if screen.right_bar then + require("src.modules.crylia_bar.right_bar")(s, get_widgets(screen.right_bar)) + end + end + end end + require("src.modules.crylia_bar.dock")(s, User_config.dock_programs) end diff --git a/awesome/src/modules/crylia_bar/left_bar.lua b/awesome/src/modules/crylia_bar/left_bar.lua index 93f2031..4e79a5a 100644 --- a/awesome/src/modules/crylia_bar/left_bar.lua +++ b/awesome/src/modules/crylia_bar/left_bar.lua @@ -8,18 +8,20 @@ local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") -return function(s, widgets) +return function(s, w) local top_left = awful.popup { screen = s, - widget = wibox.container.background, + widget = { + + }, ontop = false, bg = color["Grey900"], visible = true, maximum_width = dpi(650), placement = function(c) awful.placement.top_left(c, { margins = dpi(10) }) end, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end } @@ -29,47 +31,47 @@ return function(s, widgets) local function prepare_widgets(widgets) local layout = { - forced_height = 45, + forced_height = dpi(50), layout = wibox.layout.fixed.horizontal } for i, widget in pairs(widgets) do if i == 1 then table.insert(layout, { - widget, - left = dpi(6), - right = dpi(3), - top = dpi(6), - bottom = dpi(6), - widget = wibox.container.margin - }) + widget, + left = dpi(6), + right = dpi(3), + top = dpi(6), + bottom = dpi(6), + widget = wibox.container.margin + }) elseif i == #widgets then table.insert(layout, { - widget, - left = dpi(3), - right = dpi(6), - top = dpi(6), - bottom = dpi(6), - widget = wibox.container.margin - }) + widget, + left = dpi(3), + right = dpi(6), + top = dpi(6), + bottom = dpi(6), + widget = wibox.container.margin + }) else table.insert(layout, { - widget, - left = dpi(3), - right = dpi(3), - top = dpi(6), - bottom = dpi(6), - widget = wibox.container.margin - }) + widget, + left = dpi(3), + right = dpi(3), + top = dpi(6), + bottom = dpi(6), + widget = wibox.container.margin + }) end end return layout end top_left:setup { - prepare_widgets(widgets), + prepare_widgets(w), nil, nil, layout = wibox.layout.fixed.horizontal diff --git a/awesome/src/modules/crylia_bar/right_bar.lua b/awesome/src/modules/crylia_bar/right_bar.lua index 3e4ec2e..9ff6590 100644 --- a/awesome/src/modules/crylia_bar/right_bar.lua +++ b/awesome/src/modules/crylia_bar/right_bar.lua @@ -8,7 +8,7 @@ local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") -return function(s, widgets) +return function(s, w) local top_right = awful.popup { widget = wibox.container.background, @@ -18,7 +18,7 @@ return function(s, widgets) screen = s, placement = function(c) awful.placement.top_right(c, { margins = dpi(10) }) end, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end } @@ -28,40 +28,40 @@ return function(s, widgets) local function prepare_widgets(widgets) local layout = { - forced_height = 45, + forced_height = dpi(50), layout = wibox.layout.fixed.horizontal } for i, widget in pairs(widgets) do if i == 1 then table.insert(layout, { - widget, - left = dpi(6), - right = dpi(3), - top = dpi(6), - bottom = dpi(6), - widget = wibox.container.margin - }) + widget, + left = dpi(6), + right = dpi(3), + top = dpi(6), + bottom = dpi(6), + widget = wibox.container.margin + }) elseif i == #widgets then table.insert(layout, { - widget, - left = dpi(3), - right = dpi(6), - top = dpi(6), - bottom = dpi(6), - widget = wibox.container.margin - }) + widget, + left = dpi(3), + right = dpi(6), + top = dpi(6), + bottom = dpi(6), + widget = wibox.container.margin + }) else table.insert(layout, { - widget, - left = dpi(3), - right = dpi(3), - top = dpi(6), - bottom = dpi(6), - widget = wibox.container.margin - }) + widget, + left = dpi(3), + right = dpi(3), + top = dpi(6), + bottom = dpi(6), + widget = wibox.container.margin + }) end end return layout @@ -70,7 +70,7 @@ return function(s, widgets) top_right:setup { nil, nil, - prepare_widgets(widgets), + prepare_widgets(w), layout = wibox.layout.align.horizontal } end diff --git a/awesome/src/modules/init.lua b/awesome/src/modules/init.lua index f0fe395..8c952ad 100644 --- a/awesome/src/modules/init.lua +++ b/awesome/src/modules/init.lua @@ -10,11 +10,11 @@ awful.screen.connect_for_each_screen( -- e.g. 1 would be the primary screen and 2 the secondary screen. function(s) -- Create 9 tags - awful.layout.layouts = user_vars.layouts + awful.layout.layouts = User_config.layouts awful.tag( { "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, - user_vars.layouts[1] + User_config.layouts[1] ) require("src.modules.powermenu")(s) @@ -24,5 +24,6 @@ awful.screen.connect_for_each_screen( require("src.modules.volume_controller")(s) require("src.modules.crylia_bar.init")(s) require("src.modules.notification-center.init")(s) + require("src.modules.window_switcher.init")(s) end ) diff --git a/awesome/src/modules/notification-center/init.lua b/awesome/src/modules/notification-center/init.lua index ffd01db..d10cd6d 100644 --- a/awesome/src/modules/notification-center/init.lua +++ b/awesome/src/modules/notification-center/init.lua @@ -149,13 +149,13 @@ return function(s) right_button.visible = false toggle_button.active = not toggle_button.active toggle_button.border_color = color["Grey800"] - user_vars.dnd = false + User_config.dnd = false else left_button.visible = false right_button.visible = true toggle_button.active = not toggle_button.active toggle_button.border_color = color["Purple200"] - user_vars.dnd = true + User_config.dnd = true end end ) diff --git a/awesome/src/modules/notification-center/notification_list.lua b/awesome/src/modules/notification-center/notification_list.lua index 8b729b5..7a5533e 100644 --- a/awesome/src/modules/notification-center/notification_list.lua +++ b/awesome/src/modules/notification-center/notification_list.lua @@ -15,7 +15,7 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/notifications/" local nl = {} -nl.notification_list = { layout = require("src.lib.overflow_widget.overflow").vertical, scrollbar_width = 0, scroll_speed = 10, spacing = dpi(20) } +nl.notification_list = { layout = wibox.layout.overflow.vertical, scrollbar_width = 0, step = dpi(10), spacing = dpi(20) } -- @param {table} notification -- @return {widget} notifications_list @@ -66,7 +66,7 @@ function nl.create_notification(n) { { { - font = user_vars.font.specify .. ", 10", + font = User_config.font.specify .. ", 10", text = "✕", align = "center", valign = "center", @@ -110,6 +110,8 @@ function nl.create_notification(n) { image = gears.color.recolor_image(icondir .. "notification-outline.svg", color["Teal200"]), resize = false, + valign = "center", + halign = "center", widget = wibox.widget.imagebox }, right = dpi(5), @@ -151,6 +153,8 @@ function nl.create_notification(n) image = n.icon, resize = true, widget = wibox.widget.imagebox, + valign = "center", + halign = "center", clip_shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, 10) end diff --git a/awesome/src/modules/notification-center/song_info.lua b/awesome/src/modules/notification-center/song_info.lua index e076875..41f34bf 100644 --- a/awesome/src/modules/notification-center/song_info.lua +++ b/awesome/src/modules/notification-center/song_info.lua @@ -44,6 +44,8 @@ return function(s) local shuffle_button = wibox.widget { resize = false, image = gears.color.recolor_image(icondir .. "shuffle.svg", color["Grey800"]), + valign = "center", + halign = "center", widget = wibox.widget.imagebox, } @@ -81,6 +83,8 @@ return function(s) resize = false, image = gears.color.recolor_image(icondir .. "repeat.svg", color["Grey800"]), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", id = "imagebox" } @@ -108,6 +112,8 @@ return function(s) local prev_button = wibox.widget { resize = false, + valign = "center", + halign = "center", image = gears.color.recolor_image(icondir .. "skip-prev.svg", color["Teal200"]), widget = wibox.widget.imagebox } @@ -126,6 +132,8 @@ return function(s) local pause_play_button = wibox.widget { resize = false, + valign = "center", + halign = "center", image = gears.color.recolor_image(icondir .. "play-pause.svg", color["Teal200"]), widget = wibox.widget.imagebox } @@ -139,6 +147,8 @@ return function(s) local next_button = wibox.widget { resize = false, + valign = "center", + halign = "center", image = gears.color.recolor_image(icondir .. "skip-next.svg", color["Teal200"]), widget = wibox.widget.imagebox } @@ -192,11 +202,13 @@ return function(s) { { -- Album art { - image = icondir .. "spotify.svg", + image = "default image", resize = true, clip_shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, dpi(8)) end, + valign = "center", + halign = "center", widget = wibox.widget.imagebox, id = "imagebox" }, @@ -211,7 +223,6 @@ return function(s) { { { --Title - markup = "Title", halign = "center", align = "center", widget = wibox.widget.textbox, @@ -234,7 +245,6 @@ return function(s) { { { --Artist - markup = "Artist", halign = "center", align = "center", widget = wibox.widget.textbox, @@ -304,7 +314,7 @@ return function(s) color = color["Purple200"], background_color = color["Grey800"], max_value = 100, - value = 0, + value = 50, forced_height = dpi(5), shape = function(cr, width) gears.shape.rounded_bar(cr, width, dpi(5)) @@ -380,7 +390,7 @@ return function(s) function(stdout2) local tit = stdout2:gsub("\n", "") title = tit - music_widget:get_children_by_id("textbox4")[1].text = tit or "Title" + music_widget:get_children_by_id("textbox4")[1].text = tit end ) @@ -390,7 +400,7 @@ return function(s) function(stdout2) local art = stdout2:gsub("\n", "") artist = art - music_widget:get_children_by_id("textbox3")[1].text = art or "Artist" + music_widget:get_children_by_id("textbox3")[1].text = art end ) diff --git a/awesome/src/modules/notification-center/status_bars.lua b/awesome/src/modules/notification-center/status_bars.lua index 5a39103..1441311 100644 --- a/awesome/src/modules/notification-center/status_bars.lua +++ b/awesome/src/modules/notification-center/status_bars.lua @@ -20,7 +20,7 @@ return function() ---Creates a layout with bar widgets based on the given table ---@param widget_table string{} - ---@return table @{layout} + ---@return table local function create_bar_layout(widget_table) local bar_layout = { layout = wibox.layout.flex.horizontal, spacing = dpi(10) } @@ -105,7 +105,7 @@ return function() color = color["Blue200"], background_color = color["Grey800"], max_value = 100, - value = 50, + value = 0, forced_height = dpi(8), shape = function(cr, width, heigth) gears.shape.rounded_bar(cr, dpi(58), dpi(8)) @@ -177,7 +177,7 @@ return function() color = color["Red200"], background_color = color["Grey800"], max_value = 100, - value = 50, + value = 0, forced_height = dpi(8), shape = function(cr, width, heigth) gears.shape.rounded_bar(cr, dpi(58), dpi(8)) @@ -246,7 +246,7 @@ return function() color = color["Green200"], background_color = color["Grey800"], max_value = 100, - value = 50, + value = 0, forced_height = dpi(8), shape = function(cr, width, heigth) gears.shape.rounded_bar(cr, dpi(58), dpi(8)) @@ -315,7 +315,7 @@ return function() color = color["Green200"], background_color = color["Grey800"], max_value = 100, - value = 50, + value = 0, forced_height = dpi(8), shape = function(cr, width, heigth) gears.shape.rounded_bar(cr, dpi(58), dpi(8)) @@ -387,7 +387,7 @@ return function() color = color["Yellow200"], background_color = color["Grey800"], max_value = 100, - value = 50, + value = 0, forced_height = dpi(8), shape = function(cr, width, heigth) gears.shape.rounded_bar(cr, dpi(58), dpi(8)) @@ -459,7 +459,7 @@ return function() color = color["Purple200"], background_color = color["Grey800"], max_value = 100, - value = 50, + value = 0, forced_height = dpi(8), shape = function(cr, width, heigth) gears.shape.rounded_bar(cr, dpi(58), dpi(8)) @@ -531,7 +531,7 @@ return function() color = color["Pink200"], background_color = color["Grey800"], max_value = 100, - value = 50, + value = 0, forced_height = dpi(8), shape = function(cr, width, heigth) gears.shape.rounded_bar(cr, dpi(58), dpi(8)) @@ -603,7 +603,7 @@ return function() color = color["Purple200"], background_color = color["Grey800"], max_value = 100, - value = 50, + value = 0, forced_height = dpi(8), shape = function(cr, width, heigth) gears.shape.rounded_bar(cr, dpi(58), dpi(8)) @@ -679,7 +679,7 @@ return function() { { { - create_bar_layout({ "cpu_usage", "cpu_temp", "ram_usage", "battery", "microphone", "backlight", "volume", "gpu_temp", "gpu_usage" }), + create_bar_layout(User_config.status_bar_widgets), width = dpi(480), strategy = "exact", widget = wibox.container.constraint diff --git a/awesome/src/modules/notification-center/time_date.lua b/awesome/src/modules/notification-center/time_date.lua index b7c11f6..d23b0a2 100644 --- a/awesome/src/modules/notification-center/time_date.lua +++ b/awesome/src/modules/notification-center/time_date.lua @@ -28,7 +28,7 @@ return function() id = "label", align = "left", valign = "bottom", - format = "%e %b %Y", + format = "%d %b %Y", widget = wibox.widget.textclock }, widget = wibox.container.margin diff --git a/awesome/src/modules/notification-center/weather.lua b/awesome/src/modules/notification-center/weather.lua index 6fd28e0..1ab3fa8 100644 --- a/awesome/src/modules/notification-center/weather.lua +++ b/awesome/src/modules/notification-center/weather.lua @@ -18,9 +18,9 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/weather/" return function() local api_secrets = { - key = user_vars.weather_secrets.key, - city_id = user_vars.weather_secrets.city_id, - unit = user_vars.weather_secrets.unit + key = User_config.weather_secrets.key, + city_id = User_config.weather_secrets.city_id, + unit = User_config.weather_secrets.unit } local weather_widget = wibox.widget { @@ -83,6 +83,8 @@ return function() resize = true, forced_width = dpi(24), forced_height = dpi(24), + valign = "center", + halign = "center", widget = wibox.widget.imagebox }, { @@ -107,6 +109,8 @@ return function() forced_width = dpi(24), forced_height = dpi(24), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", image = gears.color.recolor_image(icondir .. "humidity.svg", color["OrangeA200"]), id = "humidity_icon" }, @@ -156,7 +160,8 @@ return function() local function fetch_weather_data() awful.spawn.easy_async_with_shell( - "curl -sf 'http://api.openweathermap.org/data/2.5/weather?id=" .. api_secrets.city_id .. "&units=" .. api_secrets.unit .. "&appid=" .. api_secrets.key .. "'", + "curl -sf 'http://api.openweathermap.org/data/2.5/weather?id=" .. + api_secrets.city_id .. "&units=" .. api_secrets.unit .. "&appid=" .. api_secrets.key .. "'", function(stdout) if not stdout:match('error') then local weather_metadata = json_lua:decode(stdout) @@ -193,7 +198,8 @@ return function() weather_widget:get_children_by_id("icon")[1].image = icondir .. icon_table[weather_icon] .. ".svg" weather_widget:get_children_by_id("temp")[1].text = math.floor(temp + 0.5) .. "°C" weather_widget:get_children_by_id("city_country")[1].text = city .. ", " .. country - weather_widget:get_children_by_id("description")[1].text = description:sub(1, 1):upper() .. description:sub(2) + weather_widget:get_children_by_id("description")[1].text = description:sub(1, 1):upper() .. + description:sub(2) weather_widget:get_children_by_id("line")[1].bg = color["Grey800"] weather_widget:get_children_by_id("speed")[1].text = speed .. " m/s" weather_widget:get_children_by_id("humidity")[1].text = humidity .. "%" diff --git a/awesome/src/modules/powermenu.lua b/awesome/src/modules/powermenu.lua index 90cff4f..accd32e 100644 --- a/awesome/src/modules/powermenu.lua +++ b/awesome/src/modules/powermenu.lua @@ -4,11 +4,9 @@ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") -require("src.core.signals") -- Icon directory path local icondir = awful.util.getdir("config") .. "src/assets/icons/powermenu/" @@ -21,8 +19,10 @@ return function(s) resize = true, forced_height = dpi(200), clip_shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 30) + gears.shape.rounded_rect(cr, width, height, dpi(30)) end, + valign = "center", + halign = "center", widget = wibox.widget.imagebox } @@ -55,7 +55,7 @@ return function(s) -- Get the full username(if set) and the username + hostname local update_user_name = function() awful.spawn.easy_async_with_shell( - "./.config/awesome/src/scripts/pfp.sh 'userName' '" .. user_vars.namestyle .. "'", + "./.config/awesome/src/scripts/pfp.sh 'userName' '" .. User_config.namestyle .. "'", function(stdout) if stdout:gsub("\n", "") == "Rick Astley" then profile_picture:set_image(awful.util.getdir("config") .. "src/assets/userpfp/" .. "rickastley.jpg") @@ -73,42 +73,35 @@ return function(s) { { { - { - -- TODO: using gears.color to recolor a SVG will make it look super low res - -- currently I recolor it in the .svg file directly, but later implement - -- a better way to recolor a SVG - -- image = gears.color.recolor_image(icon, color["Grey900"]), - image = icon, - resize = true, - forced_height = dpi(30), - widget = wibox.widget.imagebox - }, - margins = dpi(0), - widget = wibox.container.margin + -- TODO: using gears.color to recolor a SVG will make it look super low res + -- currently I recolor it in the .svg file directly, but later implement + -- a better way to recolor a SVG + -- image = gears.color.recolor_image(icon, color["Grey900"]), + image = icon, + resize = true, + forced_height = dpi(30), + valign = "center", + halign = "center", + widget = wibox.widget.imagebox }, { - { - text = name, - font = "JetBrains Mono Bold 30", - widget = wibox.widget.textbox - }, - margins = dpi(0), - widget = wibox.container.margin + text = name, + font = "JetBrains Mono Bold 30", + widget = wibox.widget.textbox }, widget = wibox.layout.fixed.horizontal }, margins = dpi(10), widget = wibox.container.margin }, - fg = color["Grey900"], + fg = Theme_config.powermenu.button_fg, bg = bg_color, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 10) + gears.shape.rounded_rect(cr, width, height, dpi(10)) end, widget = wibox.container.background, id = 'background' }, - spacing = dpi(0), layout = wibox.layout.align.vertical } @@ -148,79 +141,49 @@ return function(s) end -- Create the buttons with their command and name etc - local shutdown_button = button("Shutdown", icondir .. "shutdown.svg", color["Blue200"], shutdown_command) - local reboot_button = button("Reboot", icondir .. "reboot.svg", color["Red200"], reboot_command) - local suspend_button = button("Suspend", icondir .. "suspend.svg", color["Yellow200"], suspend_command) - local logout_button = button("Logout", icondir .. "logout.svg", color["Green200"], logout_command) - local lock_button = button("Lock", icondir .. "lock.svg", color["Orange200"], lock_command) + local shutdown_button = button("Shutdown", icondir .. "shutdown.svg", Theme_config.powermenu.shutdown_button_bg, + shutdown_command) + local reboot_button = button("Reboot", icondir .. "reboot.svg", Theme_config.powermenu.reboot_button_bg, reboot_command) + local suspend_button = button("Suspend", icondir .. "suspend.svg", Theme_config.powermenu.suspend_button_bg, + suspend_command) + local logout_button = button("Logout", icondir .. "logout.svg", Theme_config.powermenu.logout_button_bg, logout_command) + local lock_button = button("Lock", icondir .. "lock.svg", Theme_config.powermenu.lock_button_bg, lock_command) -- Signals to change color on hover - Hover_signal(shutdown_button.background, color["Blue200"], color["Grey900"]) - Hover_signal(reboot_button.background, color["Red200"], color["Grey900"]) - Hover_signal(suspend_button.background, color["Yellow200"], color["Grey900"]) - Hover_signal(logout_button.background, color["Green200"], color["Grey900"]) - Hover_signal(lock_button.background, color["Orange200"], color["Grey900"]) + Hover_signal(shutdown_button.background, Theme_config.powermenu.shutdown_button_bg, Theme_config.powermenu.button_fg) + Hover_signal(reboot_button.background, Theme_config.powermenu.reboot_button_bg, Theme_config.powermenu.button_fg) + Hover_signal(suspend_button.background, Theme_config.powermenu.suspend_button_bg, Theme_config.powermenu.button_fg) + Hover_signal(logout_button.background, Theme_config.powermenu.logout_button_bg, Theme_config.powermenu.button_fg) + Hover_signal(lock_button.background, Theme_config.powermenu.lock_button_bg, Theme_config.powermenu.button_fg) -- The powermenu widget local powermenu = wibox.widget { - layout = wibox.layout.align.vertical, - expand = "none", - nil, { { - nil, - { - { - nil, - { - nil, - { - profile_picture, - margins = dpi(0), - widget = wibox.container.margin - }, - nil, - expand = "none", - layout = wibox.layout.align.horizontal - }, - nil, - layout = wibox.layout.align.vertical, - expand = "none" - }, - spacing = dpi(50), - { - profile_name, - margins = dpi(0), - widget = wibox.container.margin - }, - layout = wibox.layout.fixed.vertical - }, - nil, - expand = "none", - layout = wibox.layout.align.horizontal + profile_picture, + profile_name, + spacing = dpi(50), + layout = wibox.layout.fixed.vertical }, { - nil, { - { - shutdown_button, - reboot_button, - logout_button, - lock_button, - suspend_button, - spacing = dpi(30), - layout = wibox.layout.fixed.horizontal - }, - margins = dpi(0), - widget = wibox.container.margin + shutdown_button, + reboot_button, + logout_button, + lock_button, + suspend_button, + spacing = dpi(30), + layout = wibox.layout.fixed.horizontal }, - nil, - expand = "none", - layout = wibox.layout.align.horizontal + halign = "center", + valign = "center", + widget = wibox.container.place }, - layout = wibox.layout.align.vertical + layout = wibox.layout.fixed.vertical }, - nil + halign = "center", + valign = "center", + widget = wibox.container.place } -- Container for the widget, covers the entire screen @@ -230,7 +193,7 @@ return function(s) type = "splash", visible = false, ontop = true, - bg = "#21212188", + bg = Theme_config.powermenu.container_bg, height = s.geometry.height, width = s.geometry.width, x = s.geometry.x, diff --git a/awesome/src/modules/titlebar.lua b/awesome/src/modules/titlebar.lua index 2f58d3d..f691442 100644 --- a/awesome/src/modules/titlebar.lua +++ b/awesome/src/modules/titlebar.lua @@ -4,11 +4,9 @@ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") -require("src.core.signals") -- Icon directory path local icondir = awful.util.getdir("config") .. "src/assets/icons/titlebar/" @@ -16,6 +14,12 @@ local icondir = awful.util.getdir("config") .. "src/assets/icons/titlebar/" awful.titlebar.enable_tooltip = true awful.titlebar.fallback_name = 'Client' +Theme.titlebar_close_button_normal = icondir .. "close.svg" +Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg" +Theme.titlebar_minimize_button_normal = icondir .. "minimize.svg" +Theme.titlebar_maximized_button_active = icondir .. "maximize.svg" +Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg" + local double_click_event_handler = function(double_click_event) if double_click_timer then double_click_timer:stop() @@ -60,10 +64,10 @@ local create_click_events = function(c) return buttons end -local create_titlebar = function(c, bg, size) +local create_titlebar = function(c, size) local titlebar = awful.titlebar(c, { position = "left", - bg = bg, + bg = Theme_config.titlebar.bg, size = size }) @@ -73,27 +77,27 @@ local create_titlebar = function(c, bg, size) { awful.titlebar.widget.closebutton(c), widget = wibox.container.background, - bg = color["Red200"], + bg = Theme_config.titlebar.close_button_bg, shape = function(cr, height, width) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end, id = "closebutton" }, { awful.titlebar.widget.maximizedbutton(c), widget = wibox.container.background, - bg = color["Yellow200"], + bg = Theme_config.titlebar.minimize_button_bg, shape = function(cr, height, width) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end, id = "maximizebutton" }, { awful.titlebar.widget.minimizebutton(c), widget = wibox.container.background, - bg = color["Green200"], + bg = Theme_config.titlebar.maximize_button_bg, shape = function(cr, height, width) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end, id = "minimizebutton" }, @@ -119,15 +123,18 @@ local create_titlebar = function(c, bg, size) layout = wibox.layout.align.vertical, id = "main" } - Hover_signal(titlebar.main.margin.spacing.closebutton, color["Red200"], color["Grey900"]) - Hover_signal(titlebar.main.margin.spacing.maximizebutton, color["Yellow200"], color["Grey900"]) - Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"], color["Grey900"]) + Hover_signal(titlebar.main.margin.spacing.closebutton, Theme_config.titlebar.close_button_bg, + Theme_config.titlebar.close_button_fg) + Hover_signal(titlebar.main.margin.spacing.maximizebutton, Theme_config.titlebar.minimize_button_bg, + Theme_config.titlebar.minimize_button_fg) + Hover_signal(titlebar.main.margin.spacing.minimizebutton, Theme_config.titlebar.maximize_button_bg, + Theme_config.titlebar.maximize_button_fg) end -local create_titlebar_dialog = function(c, bg, size) +local create_titlebar_dialog_modal = function(c, size) local titlebar = awful.titlebar(c, { position = "left", - bg = bg, + bg = Theme_config.titlebar.bg, size = size }) @@ -137,18 +144,18 @@ local create_titlebar_dialog = function(c, bg, size) { awful.titlebar.widget.closebutton(c), widget = wibox.container.background, - bg = color["Red200"], + bg = Theme_config.titlebar.close_button_bg, shape = function(cr, height, width) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end, id = "closebutton" }, { awful.titlebar.widget.minimizebutton(c), widget = wibox.container.background, - bg = color["Green200"], + bg = Theme_config.titlebar.minimize_button_bg, shape = function(cr, height, width) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end, id = "minimizebutton" }, @@ -174,79 +181,38 @@ local create_titlebar_dialog = function(c, bg, size) layout = wibox.layout.align.vertical, id = "main" } - Hover_signal(titlebar.main.margin.spacing.closebutton, color["Red200"], color["Grey900"]) - Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"], color["Grey900"]) + Hover_signal(titlebar.main.margin.spacing.closebutton, Theme_config.titlebar.close_button_bg, + Theme_config.titlebar.close_button_fg) + Hover_signal(titlebar.main.margin.spacing.minimizebutton, Theme_config.titlebar.minimize_button_bg, + Theme_config.titlebar.minimize_button_fg) end -local draw_titlebar = function(c) - if c.type == 'normal' and not c.requests_no_titlebar then - if c.class == 'Firefox' then - create_titlebar(c, '#121212AA', 35) - elseif c.name == "Steam" then - create_titlebar(c, '#121212AA', 0) - elseif c.name == "Settings" then - create_titlebar(c, '#121212AA', 0) - elseif c.class == "gcr-prompter" or c.class == "Gcr-prompter" then - create_titlebar(c, '#121212AA', 0) - else - create_titlebar(c, '#121212AA', 35) - end - elseif c.type == 'dialog' then - create_titlebar_dialog(c, '#121212AA', 35) - end -end - -client.connect_signal( - "property::maximized", - function(c) - if c.maximized then - Theme.titlebar_maximized_button_normal = icondir .. "unmaximize.svg" - Theme.titlebar_maximized_button_active = icondir .. "unmaximize.svg" - Theme.titlebar_maximized_button_inactive = icondir .. "unmaximize.svg" - elseif not c.minimized then - Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg" - Theme.titlebar_maximized_button_active = icondir .. "maximize.svg" - Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg" - end - end -) - client.connect_signal( "request::titlebars", function(c) - if c.maximized then - Theme.titlebar_maximized_button_normal = icondir .. "unmaximize.svg" - Theme.titlebar_maximized_button_active = icondir .. "unmaximize.svg" - Theme.titlebar_maximized_button_inactive = icondir .. "unmaximize.svg" - draw_titlebar(c) - elseif not c.minimized then - Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg" - Theme.titlebar_maximized_button_active = icondir .. "maximize.svg" - Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg" - draw_titlebar(c) + if c.type == "normal" then + create_titlebar(c, dpi(35)) + elseif c.type == "dialog" then + create_titlebar_dialog_modal(c, dpi(35)) + elseif c.type == "modal" then + create_titlebar_dialog_modal(c, dpi(35)) + else + create_titlebar(c, dpi(35)) end - if not c.floating or c.maximized then - awful.titlebar.hide(c, 'left') - awful.titlebar.hide(c, 'right') - awful.titlebar.hide(c, 'top') - awful.titlebar.hide(c, 'bottom') + + if not c.floating then + awful.titlebar.hide(c, "left") end end ) client.connect_signal( - 'property::floating', + "property::floating", function(c) - if c.floating or (c.floating and c.maximized) then - awful.titlebar.show(c, 'left') - awful.titlebar.hide(c, 'right') - awful.titlebar.hide(c, 'top') - awful.titlebar.hide(c, 'bottom') + if c.floating and not (c.maximized or c.fullscreen) then + awful.titlebar.show(c, "left") else - awful.titlebar.hide(c, 'left') - awful.titlebar.hide(c, 'right') - awful.titlebar.hide(c, 'top') - awful.titlebar.hide(c, 'bottom') + awful.titlebar.hide(c, "left") end end ) diff --git a/awesome/src/modules/volume_controller.lua b/awesome/src/modules/volume_controller.lua index 6126651..4487495 100644 --- a/awesome/src/modules/volume_controller.lua +++ b/awesome/src/modules/volume_controller.lua @@ -7,7 +7,6 @@ local awful = require("awful") local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") -local naughty = require("naughty") local wibox = require("wibox") local rubato = require("src.lib.rubato") @@ -26,6 +25,8 @@ return function(s) { id = "icon", resize = false, + valign = "center", + halign = "center", widget = wibox.widget.imagebox }, spacing = dpi(10), @@ -46,7 +47,7 @@ return function(s) border_color = color["Grey800"], border_width = dpi(2), shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end, widget = wibox.container.background } @@ -64,11 +65,13 @@ return function(s) "update::bg_sink", function(new_node) if node == new_node then - device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "headphones.svg", color["Grey900"]) + device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "headphones.svg", + color["Grey900"]) device.bg = color["Purple200"] device.fg = color["Grey900"] else - device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "headphones.svg", color["Purple200"]) + device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "headphones.svg", + color["Purple200"]) device.bg = color["Grey900"] device.fg = color["Purple200"] end @@ -79,18 +82,19 @@ return function(s) function(stdout) local node_active = stdout:gsub("\n", "") if node == node_active then - device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "headphones.svg", color["Grey900"]) + device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "headphones.svg", + color["Grey900"]) device.bg = color["Purple200"] device.fg = color["Grey900"] else - device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "headphones.svg", color["Purple200"]) + device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "headphones.svg", + color["Purple200"]) device.bg = color["Grey900"] device.fg = color["Purple200"] end end ) awesome.emit_signal("update::bg_sink", node) - --Hover_signal(device, "#313131", color["Purple200"]) else device:connect_signal( @@ -106,11 +110,13 @@ return function(s) "update::bg_source", function(new_node) if node == new_node then - device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "microphone.svg", color["Grey900"]) + device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "microphone.svg", + color["Grey900"]) device.bg = color["Blue200"] device.fg = color["Grey900"] else - device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "microphone.svg", color["Blue200"]) + device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "microphone.svg", + color["Blue200"]) device.bg = color["Grey900"] device.fg = color["Blue200"] end @@ -121,11 +127,13 @@ return function(s) function(stdout) local node_active = stdout:gsub("\n", "") if node == node_active then - device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "microphone.svg", color["Grey900"]) + device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "microphone.svg", + color["Grey900"]) device.bg = color["Blue200"] device.fg = color["Grey900"] else - device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "microphone.svg", color["Blue200"]) + device:get_children_by_id("icon")[1].image = gears.color.recolor_image(icondir .. "microphone.svg", + color["Blue200"]) device.bg = color["Grey900"] device.fg = color["Blue200"] end @@ -161,7 +169,7 @@ return function(s) border_width = dpi(2), id = "volume_device_background", shape = function(cr, width, height) - gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, 4) + gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, dpi(4)) end, widget = wibox.container.background }, @@ -195,7 +203,7 @@ return function(s) border_color = color["Grey800"], border_width = dpi(2), shape = function(cr, width, height) - gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, 4) + gears.shape.partially_rounded_rect(cr, width, height, false, false, true, true, dpi(4)) end, widget = wibox.container.background }, @@ -216,6 +224,8 @@ return function(s) resize = false, image = gears.color.recolor_image(icondir .. "menu-down.svg", color["Purple200"]), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", id = "icon" }, id = "center", @@ -239,7 +249,7 @@ return function(s) bg = color["Grey800"], fg = color["Purple200"], shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end, widget = wibox.container.background }, @@ -263,6 +273,8 @@ return function(s) resize = false, image = gears.color.recolor_image(icondir .. "menu-down.svg", color["LightBlueA200"]), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", id = "icon", }, id = "center", @@ -286,7 +298,7 @@ return function(s) bg = color["Grey800"], fg = color["LightBlueA200"], shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end, widget = wibox.container.background }, @@ -307,13 +319,15 @@ return function(s) { resize = false, widget = wibox.widget.imagebox, + valign = "center", + halign = "center", image = gears.color.recolor_image(icondir .. "volume-high.svg", color["Purple200"]), id = "icon", }, { { bar_shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(5)) end, bar_height = dpi(5), bar_color = color["Grey800"], @@ -321,13 +335,12 @@ return function(s) handle_color = color["Purple200"], handle_shape = gears.shape.circle, handle_border_color = color["Purple200"], - handle_width = dpi(15), + handle_width = dpi(12), maximum = 100, forced_height = dpi(26), widget = wibox.widget.slider, id = "slider" }, - bottom = dpi(12), left = dpi(5), id = "slider_margin", widget = wibox.container.margin @@ -347,13 +360,15 @@ return function(s) { resize = false, widget = wibox.widget.imagebox, + valign = "center", + halign = "center", image = gears.color.recolor_image(icondir .. "microphone.svg", color["Blue200"]), id = "icon" }, { { bar_shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(5)) end, bar_height = dpi(5), bar_color = color["Grey800"], @@ -361,7 +376,7 @@ return function(s) handle_color = color["Blue200"], handle_shape = gears.shape.circle, handle_border_color = color["Blue200"], - handle_width = dpi(15), + handle_width = dpi(12), maximum = 100, forced_height = dpi(26), widget = wibox.widget.slider, @@ -377,6 +392,7 @@ return function(s) id = "mic_volume_margin", left = dpi(10), right = dpi(10), + top = dpi(10), widget = wibox.container.margin }, id = "controller_layout", @@ -390,7 +406,7 @@ return function(s) border_color = color["Grey800"], border_width = dpi(4), shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 12) + gears.shape.rounded_rect(cr, width, height, dpi(12)) end, forced_width = dpi(400), widget = wibox.container.background @@ -419,13 +435,13 @@ return function(s) if volume_list.forced_height == 0 then rubato_timer.target = dpi(200) audio_bg.shape = function(cr, width, height) - gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, 4) + gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, dpi(4)) end audio_volume.icon:set_image(gears.color.recolor_image(icondir .. "menu-up.svg", color["Purple200"])) else rubato_timer.target = 0 audio_bg.shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end audio_volume.icon:set_image(gears.color.recolor_image(icondir .. "menu-down.svg", color["Purple200"])) end @@ -455,20 +471,21 @@ return function(s) if mic_list.forced_height == 0 then rubato_timer.target = dpi(200) mic_selector_margin.mic_bg.shape = function(cr, width, height) - gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, 4) + gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, dpi(4)) end mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "menu-up.svg", color["Blue200"])) else rubato_timer.target = 0 mic_bg.shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 4) + gears.shape.rounded_rect(cr, width, height, dpi(4)) end mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "menu-down.svg", color["Blue200"])) end end ) - local audio_slider_margin = volume_controller:get_children_by_id("audio_volume_margin")[1].audio_volume.slider_margin.slider + local audio_slider_margin = volume_controller:get_children_by_id("audio_volume_margin")[1].audio_volume.slider_margin. + slider -- Volume slider change event audio_slider_margin:connect_signal( @@ -499,17 +516,20 @@ return function(s) stretch = false, visible = false, screen = s, - placement = function(c) awful.placement.align(c, { position = "top_right", margins = { right = dpi(305), top = dpi(60) } }) end, + placement = function(c) awful.placement.align(c, + { position = "top_right", margins = { right = dpi(305), top = dpi(60) } }) + end, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 12) + gears.shape.rounded_rect(cr, width, height, dpi(12)) end } -- Get all source devices local function get_source_devices() awful.spawn.easy_async_with_shell( - [[ pactl list sinks | grep -E 'node.name|device.description|alsa.card_name' | awk '{gsub(/"/, ""); for(i = 1;i < NF;i++) printf $i " "; print $NF}' ]], - + [[ + pactl list sinks | grep -E 'node.name|device.description|alsa.card_name' | awk '{gsub(/"/, ""); for(i = 1;i < NF;i++) printf $i " "; print $NF}' + ]], function(stdout) local device_list = {} local was_alsa = false @@ -543,8 +563,9 @@ return function(s) -- Get all input devices local function get_input_devices() awful.spawn.easy_async_with_shell( - [[ pactl list sources | grep -E "node.name|device.description|alsa.card_name" | awk '{gsub(/"/, ""); for(i = 1;i < NF;i++) printf $i " "; print $NF}' ]], - + [[ + pactl list sources | grep -E "node.name|device.description|alsa.card_name" | awk '{gsub(/"/, ""); for(i = 1;i < NF;i++) printf $i " "; print $NF}' + ]], function(stdout) local device_list = {} local was_alsa = false @@ -603,9 +624,11 @@ return function(s) local volume = stdout:gsub("%%", ""):gsub("\n", "") volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.slider_margin.slider:set_value(tonumber(volume)) if volume > 0 then - volume_controller:get_children_by_id("mic_volume_margin")[1].icon:set_image(gears.color.recolor_image(icondir .. "microphone.svg", color["LightBlue200"])) + volume_controller:get_children_by_id("mic_volume_margin")[1].icon:set_image(gears.color.recolor_image(icondir + .. "microphone.svg", color["LightBlue200"])) else - volume_controller:get_children_by_id("mic_volume_margin")[1].icon:set_image(gears.color.recolor_image(icondir .. "microphone-off.svg", color["LightBlue200"])) + volume_controller:get_children_by_id("mic_volume_margin")[1].icon:set_image(gears.color.recolor_image(icondir + .. "microphone-off.svg", color["LightBlue200"])) end end ) @@ -620,7 +643,8 @@ return function(s) function(stdout) if stdout:match("yes") then volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.slider_margin.slider:set_value(tonumber(0)) - volume_controller:get_children_by_id("mic_volume_margin")[1].icon:set_image(gears.color.recolor_image(icondir .. "microphone-off.svg", color["LightBlue200"])) + volume_controller:get_children_by_id("mic_volume_margin")[1].icon:set_image(gears.color.recolor_image(icondir + .. "microphone-off.svg", color["LightBlue200"])) else get_mic_volume() end @@ -654,10 +678,10 @@ return function(s) -- Grabs all keys and hides popup when anything is pressed -- TODO: Make it possible to navigate and select using the kb - local volume_controller_keygrabber = awful.keygrabber { + awful.keygrabber { autostart = false, stop_event = 'release', - keypressed_callback = function(self, mod, key, command) + keypressed_callback = function() awesome.emit_signal("volume_controller::toggle", s) mousegrabber.stop() end @@ -669,18 +693,6 @@ return function(s) layout = wibox.layout.fixed.horizontal } - --[[ awesome.connect_signal( - "volume_controller::toggle:keygrabber", - function() - if awful.keygrabber.is_running then - volume_controller_keygrabber:stop() - else - volume_controller_keygrabber:start() - end - - end - ) ]] - -- Set the volume and icon awesome.connect_signal( "get::volume", @@ -698,8 +710,10 @@ return function(s) icon = icon .. "-high" end - volume_controller.controller_margin.controller_layout.audio_volume_margin.audio_volume.slider_margin.slider:set_value(volume) - volume_controller.controller_margin.controller_layout.audio_volume_margin.audio_volume.icon:set_image(gears.color.recolor_image(icon .. ".svg", color["Purple200"])) + volume_controller.controller_margin.controller_layout.audio_volume_margin.audio_volume.slider_margin.slider: + set_value(volume) + volume_controller.controller_margin.controller_layout.audio_volume_margin.audio_volume.icon:set_image(gears.color. + recolor_image(icon .. ".svg", color["Purple200"])) end ) @@ -708,7 +722,8 @@ return function(s) "get::volume_mute", function(mute) if mute then - volume_controller.controller_margin.controller_layout.audio_volume_margin.audio_volume.icon:set_image(gears.color.recolor_image(icondir .. "volume-mute.svg", color["Purple200"])) + volume_controller.controller_margin.controller_layout.audio_volume_margin.audio_volume.icon:set_image(gears. + color.recolor_image(icondir .. "volume-mute.svg", color["Purple200"])) end end ) @@ -718,10 +733,12 @@ return function(s) "get::mic_volume", function(volume) if volume > 0 then - volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "microphone.svg", color["LightBlue200"])) + volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.icon:set_image(gears.color.recolor_image(icondir + .. "microphone.svg", color["LightBlue200"])) awesome.emit_signal("update::microphone_widget", tonumber(volume), icondir .. "microphone.svg") else - volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "microphone-off.svg", color["LightBlue200"])) + volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.icon:set_image(gears.color.recolor_image(icondir + .. "microphone-off.svg", color["LightBlue200"])) awesome.emit_signal("update::microphone_widget", tonumber(volume), icondir .. "microphone-off.svg") end end diff --git a/awesome/src/modules/volume_osd.lua b/awesome/src/modules/volume_osd.lua index 8189791..03ef22d 100644 --- a/awesome/src/modules/volume_osd.lua +++ b/awesome/src/modules/volume_osd.lua @@ -18,177 +18,104 @@ return function(s) local volume_osd_widget = wibox.widget { { { - { - { - nil, - { - nil, - { - id = "icon", - forced_height = dpi(220), - image = icondir .. "volume-high.svg", - widget = wibox.widget.imagebox - }, - nil, - expand = "none", - id = "icon_margin2", - layout = wibox.layout.align.vertical - }, - nil, - id = "icon_margin1", - expand = "none", - layout = wibox.layout.align.horizontal - }, + { -- Volume Icon + image = gears.color.recolor_image(icondir .. "volume-high.svg", Theme_config.volume_osd.icon_color), + valign = "center", + halign = "center", + resize = false, + id = "icon", + widget = wibox.widget.imagebox + }, + { -- Volume Bar { { - id = "label", - text = "Volume", - align = "left", - valign = "center", - widget = wibox.widget.textbox + id = "progressbar1", + color = Theme_config.volume_osd.bar_bg_active, + background_color = Theme_config.volume_osd.bar_bg, + max_value = 100, + value = 50, + forced_height = dpi(6), + shape = function(cr, width, heigth) + gears.shape.rounded_bar(cr, width, heigth, dpi(6)) + end, + widget = wibox.widget.progressbar }, - nil, - { - id = "value", - text = "0%", - align = "center", - valign = "center", - widget = wibox.widget.textbox - }, - id = "label_value_layout", - forced_height = dpi(48), - layout = wibox.layout.align.horizontal, - }, - { - { - id = "volume_slider", - bar_shape = gears.shape.rounded_rect, - bar_height = dpi(10), - bar_color = color["Grey800"] .. "88", - bar_active_color = "#ffffff", - handle_color = "#ffffff", - handle_shape = gears.shape.circle, - handle_width = dpi(10), - handle_border_color = color["White"], - maximum = 100, - widget = wibox.widget.slider - }, - id = "slider_layout", - forced_height = dpi(24), + id = "progressbar_container2", + halign = "center", + valign = "center", widget = wibox.container.place }, - id = "icon_slider_layout", - spacing = dpi(0), - layout = wibox.layout.align.vertical + id = "progressbar_container", + width = dpi(240), + heigth = dpi(20), + stragety = "max", + widget = wibox.container.constraint }, - id = "osd_layout", - layout = wibox.layout.align.vertical + id = "layout1", + spacing = dpi(10), + layout = wibox.layout.fixed.horizontal }, - id = "container", - left = dpi(24), - right = dpi(24), + id = "margin", + margins = dpi(10), widget = wibox.container.margin }, - bg = color["Grey900"] .. '88', - widget = wibox.container.background, - ontop = true, - visible = true, - type = "notification", - forced_height = dpi(300), forced_width = dpi(300), - offset = dpi(5), + forced_height = dpi(80), + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, dpi(12)) + end, + border_color = Theme_config.volume_osd.border_color, + border_width = Theme_config.volume_osd.border_width, + fg = Theme_config.volume_osd.fg, + bg = Theme_config.volume_osd.bg, + widget = wibox.container.background } - local function update_osd() - awful.spawn.easy_async_with_shell( - "./.config/awesome/src/scripts/vol.sh volume", - function(stdout) - local volume_level = stdout:gsub("\n", ""):gsub("%%", "") - awesome.emit_signal("widget::volume") - volume_osd_widget.container.osd_layout.icon_slider_layout.label_value_layout.value:set_text(volume_level .. "%") - - awesome.emit_signal( - "widget::volume:update", - volume_level - ) - - if awful.screen.focused().show_volume_osd then - awesome.emit_signal( - "module::volume_osd:show", - true - ) - end - volume_level = tonumber(volume_level) - local icon = icondir .. "volume" - if volume_level < 1 then - icon = icon .. "-mute" - elseif volume_level >= 1 and volume_level < 34 then - icon = icon .. "-low" - elseif volume_level >= 34 and volume_level < 67 then - icon = icon .. "-medium" - elseif volume_level >= 67 then - icon = icon .. "-high" - end - volume_osd_widget.container.osd_layout.icon_slider_layout.icon_margin1.icon_margin2.icon:set_image(icon .. ".svg") - end - ) - end - - volume_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.volume_slider:connect_signal( - "property::value", - function() - update_osd() - end - ) - local update_slider = function() awful.spawn.easy_async_with_shell( "./.config/awesome/src/scripts/vol.sh mute", function(stdout) - if stdout:match("yes") then - volume_osd_widget.container.osd_layout.icon_slider_layout.label_value_layout.value:set_text("0%") - volume_osd_widget.container.osd_layout.icon_slider_layout.icon_margin1.icon_margin2.icon:set_image(icondir .. "volume-mute" .. ".svg") - else - awful.spawn.easy_async_with_shell( - "./.config/awesome/src/scripts/vol.sh volume", - function(stdout2) - stdout2 = stdout2:gsub("%%", ""):gsub("\n", "") - volume_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.volume_slider:set_value(tonumber(stdout2)) - update_osd() + if stdout:match("yes") then + volume_osd_widget:get_children_by_id("icon")[1] + :set_image(gears.color.recolor_image( + icondir .. "volume-mute" .. ".svg", Theme_config.volume_osd.icon_color)) + volume_osd_widget:get_children_by_id("progressbar1")[1].value = tonumber(0) + else + awful.spawn.easy_async_with_shell( + "./.config/awesome/src/scripts/vol.sh volume", + function(stdout2) + local volume_level = stdout2:gsub("%%", ""):gsub("\n", "") + volume_osd_widget:get_children_by_id("progressbar1")[1].value = tonumber(volume_level) + local icon = icondir .. "volume" + if volume_level < 1 then + icon = icon .. "-mute" + elseif volume_level >= 1 and volume_level < 34 then + icon = icon .. "-low" + elseif volume_level >= 34 and volume_level < 67 then + icon = icon .. "-medium" + elseif volume_level >= 67 then + icon = icon .. "-high" + end + volume_osd_widget:get_children_by_id("icon")[1]:set_image(gears.color.recolor_image(icon .. ".svg", + Theme_config.volume_osd.icon_color)) + end + ) end - ) end - end ) end - -- Signals - awesome.connect_signal( - "module::slider:update", - function() - update_slider() - end - ) - - awesome.connect_signal( - "widget::volume:update", - function(value) - volume_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.volume_slider:set_value(tonumber(value)) - end - ) - update_slider() local volume_container = awful.popup { - widget = wibox.container.background, + widget = {}, ontop = true, - bg = color["Grey900"] .. "00", stretch = false, visible = false, screen = s, - placement = function(c) awful.placement.centered(c, { margins = { top = dpi(200) } }) end, + placement = function(c) awful.placement.bottom_left(c, { margins = dpi(20) }) end, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 15) + gears.shape.rounded_rect(cr, width, height, dpi(14)) end } @@ -205,39 +132,17 @@ return function(s) layout = wibox.layout.fixed.horizontal } - awesome.connect_signal( - "module::volume_osd:show", - function() - if s == mouse.screen then - volume_container.visible = true - end - end - ) - - volume_container:connect_signal( - "mouse::enter", - function() - volume_container.visible = true - hide_volume_osd:stop() - end - ) - - volume_container:connect_signal( - "mouse::leave", - function() - volume_container.visible = true - hide_volume_osd:again() - end - ) - awesome.connect_signal( "widget::volume_osd:rerun", function() - if hide_volume_osd.started then - hide_volume_osd:again() - else - hide_volume_osd:start() + volume_container.visible = true + if hide_volume_osd.started then + hide_volume_osd:again() + update_slider() + else + hide_volume_osd:start() + update_slider() + end end - end ) end diff --git a/awesome/src/modules/window_switcher/init.lua b/awesome/src/modules/window_switcher/init.lua new file mode 100644 index 0000000..a6f31d9 --- /dev/null +++ b/awesome/src/modules/window_switcher/init.lua @@ -0,0 +1,153 @@ +--------------------------------- +-- This is the window_switcher -- +--------------------------------- + +-- Awesome Libs +local awful = require("awful") +local color = require("src.theme.colors") +local dpi = require("beautiful").xresources.apply_dpi +local gears = require("gears") +local wibox = require("wibox") + +-- Icon directory path +local icondir = awful.util.getdir("config") .. "src/assets/icons/window_switcher/" + +return function(s) + + local list_update = function(widget, buttons, label, _, objects) + widget:reset() + for _, object in ipairs(objects) do + local window_element = wibox.widget { + { + { + { -- Icon + { + id = "icon", + image = object.icon, + valign = "center", + halign = "center", + widget = wibox.widget.imagebox + }, + width = dpi(100), + height = dpi(100), + id = "icon_const", + strategy = "exact", + widget = wibox.container.constraint + }, + { + text = "Application", + id = "label", + valign = "center", + align = "center", + widget = wibox.widget.textbox + }, + id = "layout1", + spacing = dpi(10), + layout = wibox.layout.fixed.vertical + }, + id = "margin", + margins = dpi(20), + widget = wibox.container.margin + }, + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, dpi(12)) + end, + bg = Theme_config.window_switcher.element_bg, + fg = Theme_config.window_switcher.element_fg, + widget = wibox.container.background + } + + local function create_buttons(buttons_t, object_t) + if buttons_t then + local btns = {} + for _, b in ipairs(buttons_t) do + local btn = awful.button { + modifiers = b.modifiers, + button = b.button, + on_press = function() + b:emit_signal('press', object_t) + end, + on_release = function() + b:emit_signal('release', object_t) + end + } + btns[#btns + 1] = btn + end + return btns + end + end + + window_element:buttons(create_buttons(buttons, object)) + + local text, _ = label(object, window_element.margin.layout1.label) + + if object == client.focus then + if text == nil or text == "" then + window_element:get_children_by_id("label")[1].text = "Application" + else + local text_full = text:match(">(.-)<") + if text_full then + if object.class == nil then + text = object.name + else + text = object.class:sub(1, 20) + end + end + window_element:get_children_by_id("label")[1].text = text + end + else + + end + + window_element:get_children_by_id("icon")[1]:set_image(xdg_icon_lookup:find_icon(object.class, 64)) + + widget:add(window_element) + widget:set_spacing(dpi(6)) + end + return widget + end + + local window_switcher = awful.widget.tasklist( + s, + awful.widget.tasklist.filter.allscreen, + awful.util.table.join( + awful.button( + {}, + 1, + function(c) + if c == client.focus then + c.minimized = true + else + c.minimized = false + if not c:isvisible() and c.first_tag then + c.first_tag:view_only() + end + c:emit_signal('request::activate') + c:raise() + end + end + ) + ), + {}, + list_update, + wibox.layout.fixed.horizontal() + ) + + local window_switcher_container = awful.popup { + ontop = true, + visible = false, + screen = s, + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, dpi(12)) + end, + widget = { window_switcher }, + placement = awful.placement.centered, + bg = Theme_config.window_switcher.bg, + border_color = Theme_config.window_switcher.border_color, + border_width = Theme_config.window_switcher.border_width + } + + window_switcher_container:setup { + layout = wibox.layout.fixed.vertical + } +end diff --git a/awesome/src/scripts/bt.sh b/awesome/src/scripts/bt.sh deleted file mode 100755 index d9ddf61..0000000 --- a/awesome/src/scripts/bt.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -DEVICES=$(bluetoothctl paired-devices | cut -f2 -d' '| - while read -r uuid - do - info=`bluetoothctl info $uuid` - if echo "$info" | grep -q "Connected: yes"; then - echo "$info" | head -n 1 | grep "Device" | awk '{print $2}' - fi - done) -NAMES=$(bluetoothctl paired-devices | cut -f2 -d' '| - while read -r uuid - do - info=`bluetoothctl info $uuid` - if echo "$info" | grep -q "Connected: yes"; then - echo "$info" | grep "Name" | awk '{for (i=2; i + + ]] -- + file_manager = "thunar", + + --[[ + The font that will be used on all widgets/modules etc. + First is the regular font, second is the bold font and third the extra bold font. + Specify is used when I needed a custom font size/weight. + Example: + font = { + regular = "JetBrainsMono Nerd Font, 14", + bold = "JetBrainsMono Nerd Font, bold 14", + extrabold = "JetBrainsMono Nerd Font, ExtraBold 14", + specify = "JetBrainsMono Nerd Font" + } + ]] font = { + regular = "JetBrainsMono Nerd Font, 14", + bold = "JetBrainsMono Nerd Font, bold 14", + extrabold = "JetBrainsMono Nerd Font, ExtraBold 14", + specify = "JetBrainsMono Nerd Font" + }, + + --[[ + The icon theme name must be exactly as the folder is called + The folder can be in any $XDG_DATA_DIRS/icons/[icon_theme_name] + ]] -- + icon_theme = "Papirus-Dark", + + -- List every Keyboard layout you use here comma seperated. (run localectl list-keymaps to list all averiable keymaps) + --[[ + Keyboard layouts for the keyboard widget. + Specify every layout you want to use or leave it as is. + Example: + kblayout = { "de", "ru", "us" } + ]] -- + kblayout = { "de", "ru" }, + + --[[ + This is a list of every layout you can use. + Remove every that you don't want to use. + ]] -- + layouts = { + awful.layout.suit.tile, + awful.layout.suit.tile.left, + awful.layout.suit.tile.bottom, + awful.layout.suit.tile.top, + awful.layout.suit.floating, + awful.layout.suit.fair, + awful.layout.suit.fair.horizontal, + awful.layout.suit.corner.nw, + awful.layout.suit.corner.ne, + awful.layout.suit.corner.sw, + awful.layout.suit.corner.se, + awful.layout.suit.magnifier, + awful.layout.suit.max, + awful.layout.suit.max.fullscreen, + awful.layout.suit.spiral.dwindle, + }, + + --[[ + The modkey is ( or ) default + Run xmodmap -pm to see a list of all possible keys. + Example: + "mod1" <-- Is Alt_L + "mod2" <-- is Numlock + "mod3" <-- Nothing on my system + "mod4" <-- for the super/windows key + "mod5" <-- for the shift key + ]] -- + modkey = "Mod4", + + --[[ + This is the naming sheme used for the powermenu and maybe some other places in the future. + Example: + "userhost" <-- Will display "username@hostname" + "fullname" <-- Will display "Firstname Surname" + "?" <-- Will display "?" + ]] -- + namestyle = "userhost", + + --[[ + This is used to identify your network adapters. + Use this command `ip a` to get your lan or wlan name. + Example: + wlan = "wlo1", + ethernet = "eno1" + ]] -- + network = { + wlan = "wlo1", + ethernet = "eno1" + }, + + --[[ + This is the program that will be executed when hitting the print key. + ]] -- + screenshot_program = "flameshot gui", + + --[[ + These are the status bar widgets which are to be found in the notification-center. + You can add or remove them to your linking, here is a full list: + "cpu_usage" + "cpu_temp" + "ram_usage" + "microphone" + "volume" + "gpu_temp" + "gpu_usage" + "battery" + "backlight" + ]] -- + status_bar_widgets = { + "cpu_usage", + "cpu_temp", + "ram_usage", + "microphone", + "volume", + "gpu_temp", + "gpu_usage" + }, + + --[[ + This is the default terminal, Alacritty is the default. + ]] -- + terminal = "alacritty", + + --[[ + Add every client that should get no titlebar. + Use xprop WM_ClASS to get the class of the window. + !Always use the right(second) string! + Example: + titlebar_exception = { + "firefox", + "discord", + "Spotify" + } + ]] -- + titlebar_exception = {}, + + --[[ + This is the path to your wallpaper. + home is $HOME, you can also use an absolute path. + ]] -- + wallpaper = home .. "/.config/awesome/src/assets/fuji.jpg", + + --[[ + This is the weather widget. + You can use the openweather api to get your city ID. https://home.openweathermap.org/api_keys + Example: + weather_api_key = "your_api_key", + weather_city_id = "your_city_id", + unit = "metric" or "imperial" + ]] weather_secrets = { + key = "e71b00168ca7219563dde4514a425b14", + city_id = "2864118", + unit = "metric" + }, + + --[[ + You can configure your bar's here, if you leave it empty the bar will not be shown. + If you have multiple monitors you can add [N] where N is to the table below to get a per screen configuration. + Here is a full list of every widget you can use: + Widgets: + "Audio" <-- Displays the volume and can show the Audio Menu + "Battery" <-- Displays the battery percentage + "Bluetooth" <-- Displays the bluetooth status and can open the Bluetooth Menu + "Clock" <-- Displays a clock + "Cpu Frequency" <-- Shows the CPU Frequency in MHz + "Cpu Temperature" <-- Shows the CPU Temperature in Celsius + "Cpu Usage" <-- Shows the CPU Usage in % + "Date" <-- Displays the current date + "Gpu Temperature" <-- Shows the GPU Temperature in Celsius + "Gpu Usage" <-- Shows the GPU Usage in % + "Keyboard Layout" <-- Shows the current keyboard layout and can open the Keyboard Menu + "Tiling Layout" <-- Shows the current tiling layout + "Network" <-- Shows the current network connection and strength and can open the Network Menu + "Power Button" <-- Opens the Session menu + "Ram Usage" <-- Shows the RAM Usage in x/y GB + "Systray" <-- Shows the systray + "Taglist" <-- Shows all tags per screen and their open programs + "Tasklist" <-- Shows all programs per tag + !The order goes from left to right! + ]] + widgets = { + [1] = { + left_bar = { + "Tiling Layout", + "Systray", + "Taglist" + }, + center_bar = { + "Tasklist" + }, + right_bar = { + "Gpu Usage", + "Gpu Temperature", + "Cpu Usage", + "Cpu Temperature", + "Audio", + "Keyboard Layout", + "Date", + "Clock", + "Power Button" + } + }, + [2] = { + left_bar = { + "Tiling Layout", + "Taglist" + }, + center_bar = { + "Tasklist" + }, + right_bar = { + "Ram Usage", + "Audio", + "Keyboard Layout", + "Network", + "Date", + "Clock", + "Power Button" + } + } + } +} diff --git a/awesome/src/theme/user_variables.lua b/awesome/src/theme/user_variables.lua deleted file mode 100644 index 359b61c..0000000 --- a/awesome/src/theme/user_variables.lua +++ /dev/null @@ -1,138 +0,0 @@ -------------------------------------------- --- Uservariables are stored in this file -- -------------------------------------------- -local awful = require("awful") -local dpi = require("beautiful").xresources.apply_dpi -local home = os.getenv("HOME") - --- If you want different default programs, wallpaper path or modkey; edit this file. -user_vars = { - - -- The battery that should be displayed in the battery widget. - --[[ - You can choose from one of these values (default is internal battery): - "UNKNOWN" - "LINE_POWER" - "TABLET" - "COMPUTER" - "GAMING_INPUT" - "LAST" - "BATTERY" - "UPS" - "MONITOR" - "MOUSE" - "KEYBOARD" - "PDA" - "PHONE" - "MEDIA_PLAYER" - More information at: https://lazka.github.io/pgi-docs/UPowerGlib-1.0/enums.html#UPowerGlib.DeviceKind.KEYBOARD - ]] - battery_kind = "BATTERY", - - -- Here you can specify a battery to use. e.g. "/org/freedesktop/UPower/devices/battery_BAT0" - -- Default is nil (use the internal battery) - battery_path = nil, - - -- This is opened when clicked on the battery icon, set it to whatever you like - energy_manager = "xfce4-power-manager-settings", - - -- Uses the openweather api https://home.openweathermap.org/api_keys - -- City ID is also from there - weather_secrets = { - key = "", - city_id = "", - unit = "metric" -- "metric" or "imperial" - }, - - -- Do not Disturb will turn off all notifications but keep the notification-list in the notification-center - dnd = false, - - -- Autotiling layouts - layouts = { - awful.layout.suit.tile, - awful.layout.suit.tile.left, - awful.layout.suit.tile.bottom, - awful.layout.suit.tile.top, - awful.layout.suit.floating, - awful.layout.suit.fair, - awful.layout.suit.fair.horizontal, - awful.layout.suit.corner.nw, - awful.layout.suit.corner.ne, - awful.layout.suit.corner.sw, - awful.layout.suit.corner.se, - awful.layout.suit.magnifier, - awful.layout.suit.max, - awful.layout.suit.max.fullscreen, - awful.layout.suit.spiral.dwindle, - }, - - -- Icon theme from /usr/share/icons - icon_theme = "Papirus-Dark", - - -- Write the terminal command to start anything here - autostart = { - "", - }, - - -- Type 'ip a' and check your wlan and ethernet name - network = { - wlan = "wlo1", - ethernet = "eno1" - }, - - -- Set your font with this format: - font = { - regular = "JetBrainsMono Nerd Font, 14", - bold = "JetBrainsMono Nerd Font, bold 14", - extrabold = "JetBrainsMono Nerd Font, ExtraBold 14", - specify = "JetBrainsMono Nerd Font" - }, - - -- This is your default Terminal - terminal = "alacritty", - - -- This is the modkey 'mod4' = Super/Mod/WindowsKey, 'mod3' = alt... - modkey = "Mod4", - - -- place your wallpaper at this path with this name, you could also try to change the path - wallpaper = home .. "/.config/awesome/src/assets/fuji.jpg", - - -- Naming scheme for the powermenu, userhost = "user@hostname", fullname = "Firstname Surname", something else ... - namestyle = "userhost", - - -- List every Keyboard layout you use here comma seperated. (run localectl list-keymaps to list all averiable keymaps) - kblayout = { "de", "ru" }, - - -- Your filemanager that opens with super+e - file_manager = "thunar", - - -- Screenshot program to make a screenshot when print is hit - screenshot_program = "flameshot gui", - - -- If you use the dock here is how you control its size - dock_icon_size = dpi(50), - - -- Add your programs exactly like in this example. - -- First entry has to be how you would start the program in the terminal (just try it if you dont know yahoo it) - -- Second can be what ever the fuck you want it to be (will be the displayed name if you hover over it) - -- For steam games please use this format (look in .local/share/applications for the .desktop file, that will contain the number you need) - -- {"394360", "Name", true} true will tell the func that it's a steam game - -- Use xprop | grep WM_CLASS and use the *SECOND* string - -- { WM_CLASS, program, name, user_icon, isSteam } - dock_programs = { - { "Alacritty", "alacritty", "Alacritty" }, - { "firefox", "firefox", "Firefox" }, - { "discord", "discord", "Discord" }, - { "Spotify", "flatpak run com.spotify.Client", "Spotify" }, - { "Code", "code", "Visual Studio Code" }, - { "processing-app-Base", "arduino", "Arduino IDE" }, - { "Zoom", "flatpak run us.zoom.Zoom", "Zoom" }, - { "Thunderbird", "thunderbird", "Thunderbird" }, - { "Mattermost", "mattermost-desktop", "Mattermost" }, - { "Blender", "blender", "Blender" }, - { "Steam", "steam", "Steam" }, - { "FreeCAD", "freecad", "FreeCAD" }, - { "Thunar", "thunar", "Dateien" }, - { "Windows", "virsh start Windows_11", "Windows 11", "/home/crylia/Bilder/windows.png", false, 50 } - } -} diff --git a/awesome/src/tools/desktop_parser.lua b/awesome/src/tools/desktop_parser.lua new file mode 100644 index 0000000..48e8967 --- /dev/null +++ b/awesome/src/tools/desktop_parser.lua @@ -0,0 +1,74 @@ +local gears = require("gears") +local GLib = require("lgi").GLib + +---Will return every $XDG_DATA_DIRS +---@return table +local function get_paths() + local dirs = {} + + local dir + for _, value in ipairs(GLib.get_system_data_dirs()) do + dir = GLib.build_filenamev({ value, "applications" }) + if gears.filesystem.dir_readable(dir) then table.insert(dirs, dir) end + end + + dir = GLib.build_filenamev({ GLib.get_user_data_dir(), "applications" }) + if gears.filesystem.dir_readable(dir) then table.insert(dirs, dir) end + + return dirs +end + +---Returns every .desktop file into a table +---@param file table .desktop files +---@return table +return function(file) + + if not file or file == "" then + return + end + + local handler = nil + + for _, dir in ipairs(get_paths()) do + handler = io.open(dir .. "/" .. file, "r") + if handler then + break + end + end + + if not handler then + return + end + + local desktop_table = {} + while true do + local line = handler:read() + + if not line then + break + end + + if line:match("[Desktop Entry]") then + while true do + local property = handler:read() + if not property then + break + end + + if property:match("^%[(.+)%]") then + return desktop_table + end + + if property:match("^Name=") then + desktop_table["Name"] = property:match("Name=(.+)") + elseif property:match("^Exec") then + -- Second match is to remove the %u and %F some applications use to open a URI. It's not needed here + desktop_table["Exec"] = property:match("Exec=(.+)"):gsub("%%u", ""):gsub("%%F", "") + elseif property:match("^Icon=") then + desktop_table["Icon"] = property:match("Icon=(.+)") + end + end + end + end + return desktop_table +end diff --git a/awesome/src/tools/icon_handler.lua b/awesome/src/tools/icon_handler.lua deleted file mode 100644 index 89ffd32..0000000 --- a/awesome/src/tools/icon_handler.lua +++ /dev/null @@ -1,95 +0,0 @@ ------------------------------------------------------ --- Helper to get icons from a program/program name -- ------------------------------------------------------ -local icon_cache = {} - --- tries to find a matching file name in /usr/share/icons/THEME/RESOLUTION/apps/ and if not found tried with first letter --- as uppercase, this should get almost all icons to work with the papirus theme atleast --- TODO: try with more icon themes -function Get_icon(theme, client, program_string, class_string, is_steam) - - client = client or nil - program_string = program_string or nil - class_string = class_string or nil - is_steam = is_steam or nil - - if theme and (client or program_string or class_string) then - local clientName - if is_steam then - clientName = "steam_icon_" .. tostring(client) .. ".svg" - elseif client then - if client.class then - clientName = string.lower(client.class:gsub(" ", "")) .. ".svg" - elseif client.name then - clientName = string.lower(client.name:gsub(" ", "")) .. ".svg" - else - if client.icon then - return client.icon - else - return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg" - end - end - else - if program_string then - clientName = program_string .. ".svg" - else - clientName = class_string .. ".svg" - end - end - - for _, icon in ipairs(icon_cache) do - if icon:match(clientName) then - return icon - end - end - - local resolutions = { "128x128", "96x96", "64x64", "48x48", "42x42", "32x32", "24x24", "16x16" } - for _, res in ipairs(resolutions) do - local iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/" - local ioStream = io.open(iconDir .. clientName, "r") - if ioStream ~= nil then - icon_cache[#icon_cache + 1] = iconDir .. clientName - return iconDir .. clientName - else - clientName = clientName:gsub("^%l", string.upper) - iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/" - ioStream = io.open(iconDir .. clientName, "r") - if ioStream ~= nil then - icon_cache[#icon_cache + 1] = iconDir .. clientName - return iconDir .. clientName - elseif not class_string then - return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg" - else - clientName = class_string .. ".svg" - iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/" - ioStream = io.open(iconDir .. clientName, "r") - if ioStream ~= nil then - icon_cache[#icon_cache + 1] = iconDir .. clientName - return iconDir .. clientName - else - return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg" - end - end - end - end - if client then - return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg" - end - end -end - ---———————————No swiches?——————————— ---⠀⣞⢽⢪⢣⢣⢣⢫⡺⡵⣝⡮⣗⢷⢽⢽⢽⣮⡷⡽⣜⣜⢮⢺⣜⢷⢽⢝⡽⣝ ---⠸⡸⠜⠕⠕⠁⢁⢇⢏⢽⢺⣪⡳⡝⣎⣏⢯⢞⡿⣟⣷⣳⢯⡷⣽⢽⢯⣳⣫⠇ ---⠀⠀⢀⢀⢄⢬⢪⡪⡎⣆⡈⠚⠜⠕⠇⠗⠝⢕⢯⢫⣞⣯⣿⣻⡽⣏⢗⣗⠏⠀ ---⠀⠪⡪⡪⣪⢪⢺⢸⢢⢓⢆⢤⢀⠀⠀⠀⠀⠈⢊⢞⡾⣿⡯⣏⢮⠷⠁⠀⠀ ---⠀⠀⠀⠈⠊⠆⡃⠕⢕⢇⢇⢇⢇⢇⢏⢎⢎⢆⢄⠀⢑⣽⣿⢝⠲⠉⠀⠀⠀⠀ ---⠀⠀⠀⠀⠀⡿⠂⠠⠀⡇⢇⠕⢈⣀⠀⠁⠡⠣⡣⡫⣂⣿⠯⢪⠰⠂⠀⠀⠀⠀ ---⠀⠀⠀⠀⡦⡙⡂⢀⢤⢣⠣⡈⣾⡃⠠⠄⠀⡄⢱⣌⣶⢏⢊⠂⠀⠀⠀⠀⠀⠀ ---⠀⠀⠀⠀⢝⡲⣜⡮⡏⢎⢌⢂⠙⠢⠐⢀⢘⢵⣽⣿⡿⠁⠁⠀⠀⠀⠀⠀⠀⠀ ---⠀⠀⠀⠀⠨⣺⡺⡕⡕⡱⡑⡆⡕⡅⡕⡜⡼⢽⡻⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ---⠀⠀⠀⠀⣼⣳⣫⣾⣵⣗⡵⡱⡡⢣⢑⢕⢜⢕⡝⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ---⠀⠀⠀⣴⣿⣾⣿⣿⣿⡿⡽⡑⢌⠪⡢⡣⣣⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ---⠀⠀⠀⡟⡾⣿⢿⢿⢵⣽⣾⣼⣘⢸⢸⣞⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ---⠀⠀⠀⠀⠁⠇⠡⠩⡫⢿⣝⡻⡮⣒⢽⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ---————————————————————————————— diff --git a/awesome/src/tools/theme_index.lua b/awesome/src/tools/theme_index.lua new file mode 100644 index 0000000..95aa11b --- /dev/null +++ b/awesome/src/tools/theme_index.lua @@ -0,0 +1,106 @@ +local theme_index = { mt = {} } + +theme_index.new = function(cls, theme, basedirs) + local self = {} + setmetatable(self, { __index = cls }) + + self.icon_theme_name = theme or User_config.icon_theme + self.base_dir = nil + self["Directories"] = {} + self["Inherits"] = {} + self.per_directory_keys = {} + + local basedir, handler = nil, nil + for _, dir in ipairs(basedirs) do + basedir = dir .. "/" .. self.icon_theme_name + handler = io.open(basedir .. "/index.theme", "r") + if handler then + break + end + end + + if not handler then + return self + end + self.base_dir = basedir + + while true do + local line = handler:read() + + if not line then + break + end + + local header = line:match("^%[(.+)%]$") + if header then + if header == "Icon Theme" then + while true do + local property = handler:read() + + if not property then + break + end + + if property:match("^%[(.+)%]$") then + handler:seek("cur", -string.len(property) - 1) + break + end + + local key, value = property:match("^(%w+)=(.*)$") + if key == "Directories" or key == "Inherits" then + string.gsub(value, "([^,]+),?", function(match) + table.insert(self[key], match) + end) + end + end + + else + local keys = {} + + while true do + local property = handler:read() + if not property then + break + end + + if property:match("^%[(.+)%]$") then + handler:seek("cur", -string.len(property) - 1) + break + end + + local key, value = property:match("^(%w+)=(%w+)$") + if key == "Size" or key == "MinSize" or key == "MaxSize" or key == "Threshold" then + keys[key] = tonumber(value) + elseif key == "Type" then + keys[key] = value + end + end + + if keys["Size"] then + if not keys["Type"] then keys["Type"] = "Threshold" end + if not keys["MinSize"] then keys["MinSize"] = keys["Size"] end + if not keys["MaxSize"] then keys["MaxSize"] = keys["Size"] end + if not keys["Threshold"] then keys["Threshold"] = 2 end + self.per_directory_keys[header] = keys + end + end + end + end + handler:close() + + return self +end + +theme_index.get_subdirectories = function(self) + return self["Directories"] +end + +theme_index.get_inherits = function(self) + return self["Inherits"] +end + +theme_index.mt.__call = function(cls, theme, basedirs) + return theme_index.new(cls, theme, basedirs) +end + +return setmetatable(theme_index, theme_index.mt) diff --git a/awesome/src/tools/xdg_icon_lookup.lua b/awesome/src/tools/xdg_icon_lookup.lua new file mode 100644 index 0000000..3f3de6c --- /dev/null +++ b/awesome/src/tools/xdg_icon_lookup.lua @@ -0,0 +1,236 @@ +----------------------------------------------------- +-- Helper to get icons from a program/program name -- +----------------------------------------------------- + +local gears = require("gears") +local GLib = require("lgi").GLib + +local theme_index = require("src.tools.theme_index") + +local function get_basedir() + local dirs = {} + + local dir = GLib.build_filenamev({ GLib.get_home_dir(), ".icons" }) + if gears.filesystem.dir_readable(dir) then + table.insert(dirs, dir) + end + + dir = GLib.build_filenamev({ GLib.get_user_data_dir(), "icons" }) + if gears.filesystem.dir_readable(dir) then table.insert(dirs, dir) end + + for _, value in ipairs(GLib.get_system_data_dirs()) do + dir = GLib.build_filenamev({ value, ".icons" }) + if gears.filesystem.dir_readable(dir) then table.insert(dirs, dir) end + end + + local need_usr_share_pixmaps = true + for _, value in ipairs(GLib.get_system_data_dirs()) do + dir = GLib.build_filenamev({ value, ".icons" }) + if gears.filesystem.dir_readable(dir) then table.insert(dirs, dir) end + if dir == "/usr/share/pixmaps" then + need_usr_share_pixmaps = false + end + end + + dir = "/usr/share/pixmaps" + if gears.filesystem.dir_readable(dir) then table.insert(dirs, dir) end + if need_usr_share_pixmaps and gears.filesystem.dir_readable(dir) then + table.insert(dirs, dir) + end + + table.insert(dirs, "/usr/share/icons") + + return dirs +end + +local xdg_icon_lookup = { mt = {} } + +local icon_cache = {} + +xdg_icon_lookup.new = function(theme, base_dirs) + local self = {} + + self.icon_theme = theme or User_config.icon_theme + self.base_directories = base_dirs or get_basedir() + self.file_extension = { "svg", "png", "xpm" } + + if not icon_cache[self.icon_theme] then + icon_cache[self.icon_theme] = {} + end + + local cache_key = table.concat(self.base_directories, ":") + if not icon_cache[self.icon_theme][cache_key] then + icon_cache[self.icon_theme][cache_key] = theme_index(self.icon_theme, self.base_directories) + end + self.theme_index = icon_cache[self.icon_theme][cache_key] + + return setmetatable(self, { __index = xdg_icon_lookup }) +end + +---Look for an fallback icon +---@param iconname any +---@return string +local function lookup_fallback_icon(self, iconname) + for _, dir in ipairs(self.base_directories) do + for _, ext in ipairs(self.file_extension) do + local filename = string.format("%s/%s.%s", dir, iconname, ext) + if gears.filesystem.file_readable(filename) then + return filename + end + end + end +end + +---Checkes if the size equals the actual icon size +---@param subdir any +---@param iconsize any +---@return boolean +local function directory_matches_size(self, subdir, iconsize) + local type, size, min_size, max_size, threshold = self.theme_index.per_directory_keys[subdir]["Type"], + self.theme_index.per_directory_keys[subdir]["Size"], self.theme_index.per_directory_keys[subdir]["MinSize"], + self.theme_index.per_directory_keys[subdir]["MaxSize"], self.theme_index.per_directory_keys[subdir]["Threshold"] + + if type == "Fixed" then + return iconsize == size + elseif type == "Scalable" then + return iconsize >= min_size and iconsize <= max_size + elseif type == "Threshold" then + return iconsize >= size - threshold and iconsize <= size + threshold + end + + return false +end + +---Returns how far off the size is from the actual icon size +---@param subdir table +---@param iconsize number +---@return number +local function directory_size_distance(self, subdir, iconsize) + local type, size, min_size, max_size, threshold = self.theme_index.per_directory_keys[subdir]["Type"], + self.theme_index.per_directory_keys[subdir]["Size"], self.theme_index.per_directory_keys[subdir]["MinSize"], + self.theme_index.per_directory_keys[subdir]["MaxSize"], self.theme_index.per_directory_keys[subdir]["Threshold"] + + if type and min_size and max_size and threshold then + if type == "Fixed" then + return math.abs(size - iconsize) + elseif type == "Scalable" then + if iconsize < min_size then + return min_size - iconsize + elseif iconsize > max_size then + return iconsize - max_size + end + return 0 + elseif type == "Threshold" then + if iconsize < size - threshold then + return min_size - iconsize + elseif iconsize > size + threshold then + return iconsize - max_size + end + return 0 + end + end + return 0xffffffff +end + +---Checks each and every sub directory for an icon +---@param iconname any +---@param size any +---@return string path_to_icon +local function lookup_icon(self, iconname, size) + local already_checked = {} + for _, subdir in ipairs(self.theme_index:get_subdirectories()) do + for _, dir in ipairs(self.base_directories) do + for _, ext in ipairs(self.file_extension) do + if directory_matches_size(self, subdir, size) then + local filename = string.format("%s/%s/%s/%s.%s", dir, self.icon_theme, subdir, iconname, ext) + if gears.filesystem.file_readable(filename) then + return filename + else + already_checked[filename] = true + end + end + end + end + end + local min_size = 0xffffffff + local closest_filename = nil + for _, subdir in ipairs(self.theme_index:get_subdirectories()) do + local dist = directory_size_distance(self, subdir, size) + if dist < min_size then + for _, dir in ipairs(self.base_directories) do + for _, ext in ipairs(self.file_extension) do + local filename = string.format("%s/%s/%s/%s.%s", dir, self.icon_theme, subdir, iconname, ext) + if not already_checked[filename] then + if gears.filesystem.file_readable(filename) then + closest_filename = filename + min_size = dist + end + end + end + end + end + end + return closest_filename or nil +end + +---Check if the icon inherits from another icon theme and search that for an icon +---@param icon any +---@param size any +---@param self any +---@return string path_to_icon +local function find_icon_helper(self, icon, size) + local filename = lookup_icon(self, icon, size) + if filename then return filename end + + filename = lookup_icon(self, icon:lower(), size) + if filename then return filename end + + for _, parent in ipairs(self.theme_index:get_inherits()) do + filename = find_icon_helper(xdg_icon_lookup(parent, self.base_directories), icon, size) + if filename then return filename end + end + + return nil +end + +local iconcache = {} +---Takes an icon and its props and theme to search for it inside the theme +---@param icon any +---@param size any +---@return string path_to_icon +function xdg_icon_lookup:find_icon(icon, size) + if iconcache[icon] then + return iconcache[icon] + end + size = size or 64 + if not icon or icon == "" then return nil end + + local filename = find_icon_helper(self, icon, size) + if filename then + iconcache[icon] = filename + return filename + end + + filename = find_icon_helper(xdg_icon_lookup("hicolor", self.base_directories), icon, size) + if filename then + iconcache[icon] = filename + return filename + end + + filename = lookup_fallback_icon(self, icon) + if filename then + iconcache[icon] = filename + return filename + end + + local fallback = gears.color.recolor_image(require("awful").util.getdir("config") .. "src/assets/icons/fallback.svg", + "#ffffff") + iconcache[icon] = fallback + return fallback +end + +xdg_icon_lookup.mt.__call = function(_, ...) + return xdg_icon_lookup.new(...) +end + +return setmetatable(xdg_icon_lookup, xdg_icon_lookup.mt) diff --git a/awesome/src/widgets/audio.lua b/awesome/src/widgets/audio.lua index 09dc3f6..3b95a3c 100644 --- a/awesome/src/widgets/audio.lua +++ b/awesome/src/widgets/audio.lua @@ -3,11 +3,9 @@ ------------------------------ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") -require("src.core.signals") -- Icon directory path local icondir = awful.util.getdir("config") .. "src/assets/icons/audio/" @@ -23,6 +21,8 @@ return function(s) { id = "icon", widget = wibox.widget.imagebox, + valign = "center", + halign = "center", resize = false }, id = "icon_layout", @@ -47,10 +47,10 @@ return function(s) right = dpi(8), widget = wibox.container.margin }, - bg = color["Yellow200"], - fg = color["Grey900"], + bg = Theme_config.audio.bg, + fg = Theme_config.audio.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } @@ -77,7 +77,7 @@ return function(s) end audio_widget.container.audio_layout.label:set_text(volume .. "%") audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image( - gears.color.recolor_image(icon .. ".svg", color["Grey900"])) + gears.color.recolor_image(icon .. ".svg", Theme_config.audio.fg)) awesome.emit_signal("get::volume", volume) awesome.emit_signal("update::volume_widget", volume, icon .. ".svg") end @@ -90,9 +90,8 @@ return function(s) function(stdout) if stdout:match("yes") then audio_widget.container.audio_layout.label.visible = false - audio_widget.container:set_right(0) audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image( - gears.color.recolor_image(icondir .. "volume-mute" .. ".svg", color["Grey900"])) + gears.color.recolor_image(icondir .. "volume-mute" .. ".svg", Theme_config.audio.fg)) awesome.emit_signal("get::volume_mute", true) else audio_widget.container:set_right(10) @@ -104,13 +103,12 @@ return function(s) end -- Signals - Hover_signal(audio_widget, color["Yellow200"], color["Grey900"]) + Hover_signal(audio_widget, Theme_config.audio.bg, Theme_config.audio.fg) audio_widget:connect_signal( "button::press", function() awesome.emit_signal("module::slider:update") - awesome.emit_signal("widget::volume_osd:rerun") awesome.emit_signal("volume_controller::toggle", s) awesome.emit_signal("volume_controller::toggle:keygrabber") end diff --git a/awesome/src/widgets/battery.lua b/awesome/src/widgets/battery.lua index 909955e..5687271 100644 --- a/awesome/src/widgets/battery.lua +++ b/awesome/src/widgets/battery.lua @@ -5,7 +5,6 @@ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local lgi = require("lgi") @@ -30,8 +29,10 @@ return function(battery_kind) { { id = "icon", - image = gears.color.recolor_image(icondir .. "battery-unknown.svg", "#212121"), + image = gears.color.recolor_image(icondir .. "battery-unknown.svg", Theme_config.battery.fg), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", resize = false }, id = "icon_layout", @@ -57,22 +58,22 @@ return function(battery_kind) right = dpi(8), widget = wibox.container.margin }, - bg = color["Purple200"], - fg = color["Grey900"], + bg = Theme_config.battery.bg, + fg = Theme_config.battery.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } -- Color change on mouse over - Hover_signal(battery_widget, color["Purple200"], color["Grey900"]) + Hover_signal(battery_widget, Theme_config.battery.bg, Theme_config.battery.fg) -- Open an energy manager on click battery_widget:connect_signal( 'button::press', function() - awful.spawn(user_vars.energy_manager) + awful.spawn(User_config.energy_manager) end ) @@ -153,7 +154,8 @@ return function(battery_kind) icon = icondir .. icon, timeout = 5 } - battery_widget:get_children_by_id("icon")[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon, "#212121")) + battery_widget:get_children_by_id("icon")[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir + .. icon, Theme_config.battery.fg)) return elseif battery_percentage > 0 and battery_percentage < 10 and battery_status == 'discharging' then icon = icon .. '-' .. 'alert.svg' @@ -164,7 +166,8 @@ return function(battery_kind) icon = icondir .. icon, timeout = 60 } - battery_widget:get_children_by_id("icon")[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon, "#212121")) + battery_widget:get_children_by_id("icon")[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir + .. icon, Theme_config.battery.fg)) return end @@ -190,7 +193,8 @@ return function(battery_kind) icon = icon .. '-' .. battery_status .. '-' .. '90' end - battery_widget:get_children_by_id("icon")[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121")) + battery_widget:get_children_by_id("icon")[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir .. + icon .. '.svg', Theme_config.battery.fg)) awesome.emit_signal("update::battery_widget", battery_percentage, icondir .. icon .. ".svg") end @@ -202,7 +206,7 @@ return function(battery_kind) ---Will report to the bluetooth widget. ---@param path string device path /org/freedesktop/... local function attach_to_device(path) - local device_path = user_vars.battery_path or path or "" + local device_path = User_config.battery_path or path or "" battery_widget.device = get_device_from_path(device_path) or upower_glib.Client():get_display_device() @@ -226,7 +230,7 @@ return function(battery_kind) battery_widget:connect_signal( "upower::update", - function(widget, device) + function(_, device) if upower_glib.DeviceKind[battery_widget.device.kind] == battery_kind then set_battery(device) end diff --git a/awesome/src/widgets/bluetooth.lua b/awesome/src/widgets/bluetooth.lua index b64d9bd..4681be4 100644 --- a/awesome/src/widgets/bluetooth.lua +++ b/awesome/src/widgets/bluetooth.lua @@ -4,10 +4,8 @@ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") -local naughty = require("naughty") local wibox = require("wibox") -- Icon directory path @@ -20,8 +18,10 @@ return function(s) { { id = "icon", - image = gears.color.recolor_image(icondir .. "bluetooth-off.svg"), + image = gears.color.recolor_image(icondir .. "bluetooth-off.svg", Theme_config.bluetooth.fg), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", resize = false }, id = "icon_layout", @@ -32,27 +32,29 @@ return function(s) right = dpi(8), widget = wibox.container.margin }, - bg = color["Blue200"], - fg = color["Grey900"], + bg = Theme_config.bluetooth.bg, + fg = Theme_config.bluetooth.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } -- Hover signal to change color when mouse is over - Hover_signal(bluetooth_widget, color["Blue200"], color["Grey900"]) + Hover_signal(bluetooth_widget, Theme_config.bluetooth.bg, Theme_config.bluetooth.fg) awesome.connect_signal("state", function(state) if state then - bluetooth_widget:get_children_by_id("icon")[1]:set_image(gears.color.recolor_image(icondir .. "bluetooth-on.svg", color["Grey900"])) + bluetooth_widget:get_children_by_id("icon")[1]:set_image(gears.color.recolor_image(icondir .. "bluetooth-on.svg", + Theme_config.bluetooth.fg)) else - bluetooth_widget:get_children_by_id("icon")[1]:set_image(gears.color.recolor_image(icondir .. "bluetooth-off.svg", color["Grey900"])) + bluetooth_widget:get_children_by_id("icon")[1]:set_image(gears.color.recolor_image(icondir .. "bluetooth-off.svg", + Theme_config.bluetooth.fg)) end end) bluetooth_widget:connect_signal( "button::press", - function(c, d, e, key) + function(_, _, _, key) if key == 1 then awesome.emit_signal("bluetooth_controller::toggle", s) else diff --git a/awesome/src/widgets/clock.lua b/awesome/src/widgets/clock.lua index bf9b4f5..5129755 100644 --- a/awesome/src/widgets/clock.lua +++ b/awesome/src/widgets/clock.lua @@ -4,11 +4,9 @@ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") -require("src.core.signals") -- Icon directory path local icondir = awful.util.getdir("config") .. "src/assets/icons/clock/" @@ -23,8 +21,10 @@ return function() { { id = "icon", - image = gears.color.recolor_image(icondir .. "clock.svg", color["Grey900"]), + image = gears.color.recolor_image(icondir .. "clock.svg", Theme_config.clock.fg), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", resize = false }, id = "icon_layout", @@ -50,15 +50,15 @@ return function() right = dpi(8), widget = wibox.container.margin }, - bg = color["Orange200"], - fg = color["Grey900"], + bg = Theme_config.clock.bg, + fg = Theme_config.clock.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } - Hover_signal(clock_widget, color["Orange200"], color["Grey900"]) + Hover_signal(clock_widget, Theme_config.clock.bg, Theme_config.clock.fg) return clock_widget end diff --git a/awesome/src/widgets/cpu_info.lua b/awesome/src/widgets/cpu_info.lua index 1a5df70..d4be074 100644 --- a/awesome/src/widgets/cpu_info.lua +++ b/awesome/src/widgets/cpu_info.lua @@ -9,7 +9,6 @@ local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local watch = awful.widget.watch local wibox = require("wibox") -require("src.core.signals") local icon_dir = awful.util.getdir("config") .. "src/assets/icons/cpu/" @@ -24,7 +23,9 @@ return function(widget, clock_mode) { id = "icon", widget = wibox.widget.imagebox, - image = gears.color.recolor_image(icon_dir .. "cpu.svg", color["Grey900"]), + valign = "center", + halign = "center", + image = gears.color.recolor_image(icon_dir .. "cpu.svg", Theme_config.cpu_usage.fg), resize = false }, id = "icon_layout", @@ -49,10 +50,10 @@ return function(widget, clock_mode) right = dpi(8), widget = wibox.container.margin }, - bg = color["Blue200"], - fg = color["Grey900"], + bg = Theme_config.cpu_usage.bg, + fg = Theme_config.cpu_usage.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } @@ -64,7 +65,10 @@ return function(widget, clock_mode) { { id = "icon", + image = gears.color.recolor_image(icon_dir .. "thermometer.svg", Theme_config.cpu_temp.fg), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", resize = false }, id = "icon_layout", @@ -90,9 +94,9 @@ return function(widget, clock_mode) widget = wibox.container.margin }, bg = color["Green200"], - fg = color["Grey900"], + fg = Theme_config.cpu_temp.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } @@ -105,7 +109,9 @@ return function(widget, clock_mode) { id = "icon", widget = wibox.widget.imagebox, - image = icon_dir .. "cpu.svg", + valign = "center", + halign = "center", + image = gears.color.recolor_image(icon_dir .. "cpu.svg", Theme_config.cpu_freq.fg), resize = false }, id = "icon_layout", @@ -130,10 +136,10 @@ return function(widget, clock_mode) right = dpi(8), widget = wibox.container.margin }, - bg = color["Purple200"], - fg = color["Grey900"], + bg = Theme_config.cpu_freq.bg, + fg = Theme_config.cpu_freq.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } @@ -182,7 +188,7 @@ return function(widget, clock_mode) temp_color = color["Red200"] temp_icon = icon_dir .. "thermometer-high.svg" end - Hover_signal(cpu_temp, temp_color, color["Grey900"]) + Hover_signal(cpu_temp, temp_color, Theme_config.cpu_temp.fg) cpu_temp.container.cpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon) cpu_temp:set_bg(temp_color) cpu_temp.container.cpu_layout.label.text = math.floor(temp_num) .. "°C" @@ -214,8 +220,8 @@ return function(widget, clock_mode) end ) - Hover_signal(cpu_usage_widget, color["Blue200"], color["Grey900"]) - Hover_signal(cpu_clock, color["Purple200"], color["Grey900"]) + Hover_signal(cpu_usage_widget, Theme_config.cpu_usage.bg, Theme_config.cpu_usage.fg) + Hover_signal(cpu_clock, Theme_config.cpu_freq.bg, Theme_config.cpu_freq.bg) if widget == "usage" then return cpu_usage_widget diff --git a/awesome/src/widgets/date.lua b/awesome/src/widgets/date.lua index 4643a33..0512b57 100644 --- a/awesome/src/widgets/date.lua +++ b/awesome/src/widgets/date.lua @@ -4,7 +4,6 @@ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") @@ -23,8 +22,10 @@ return function() { { id = "icon", - image = gears.color.recolor_image(icondir .. "calendar.svg", color["Grey900"]), + image = gears.color.recolor_image(icondir .. "calendar.svg", Theme_config.date.fg), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", resize = false }, id = "icon_layout", @@ -49,10 +50,10 @@ return function() right = dpi(8), widget = wibox.container.margin }, - bg = color["Teal200"], - fg = color["Grey900"], + bg = Theme_config.date.bg, + fg = Theme_config.date.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } @@ -72,7 +73,7 @@ return function() } -- Signals - Hover_signal(date_widget, color["Teal200"], color["Grey900"]) + Hover_signal(date_widget, Theme_config.date.bg, Theme_config.date.fg) date_widget:connect_signal( "mouse::enter", diff --git a/awesome/src/widgets/gpu_info.lua b/awesome/src/widgets/gpu_info.lua index 16608d0..a81947e 100644 --- a/awesome/src/widgets/gpu_info.lua +++ b/awesome/src/widgets/gpu_info.lua @@ -9,7 +9,6 @@ local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local watch = awful.widget.watch local wibox = require("wibox") -require("src.core.signals") local icon_dir = awful.util.getdir("config") .. "src/assets/icons/cpu/" @@ -22,7 +21,53 @@ return function(widget) { id = "icon", widget = wibox.widget.imagebox, - image = gears.color.recolor_image(icon_dir .. "gpu.svg", color["Grey900"]), + valign = "center", + halign = "center", + image = gears.color.recolor_image(icon_dir .. "gpu.svg", Theme_config.gpu_usage.fg), + resize = false + }, + id = "icon_layout", + widget = wibox.container.place + }, + top = dpi(2), + widget = wibox.container.margin, + id = "icon_margin" + }, + spacing = dpi(10), + { + id = "label", + align = "center", + valign = "center", + widget = wibox.widget.textbox + }, + id = "gpu_layout", + layout = wibox.layout.fixed.horizontal + }, + id = "container", + left = dpi(8), + right = dpi(8), + widget = wibox.container.margin + }, + bg = Theme_config.gpu_usage.bg, + fg = Theme_config.gpu_usage.fg, + shape = function(cr, width, height) + gears.shape.rounded_rect(cr, width, height, dpi(6)) + end, + widget = wibox.container.background + } + Hover_signal(gpu_usage_widget, Theme_config.gpu_usage.bg, Theme_config.gpu_usage.fg) + + local gpu_temp_widget = wibox.widget { + { + { + { + { + { + id = "icon", + widget = wibox.widget.imagebox, + valign = "center", + halign = "center", + image = gears.color.recolor_image(icon_dir .. "cpu.svg", Theme_config.gpu_temp.fg), resize = false }, id = "icon_layout", @@ -48,51 +93,9 @@ return function(widget) widget = wibox.container.margin }, bg = color["Green200"], - fg = color["Grey900"], + fg = Theme_config.gpu_temp.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) - end, - widget = wibox.container.background - } - Hover_signal(gpu_usage_widget, color["Green200"], color["Grey900"]) - - local gpu_temp_widget = wibox.widget { - { - { - { - { - { - id = "icon", - widget = wibox.widget.imagebox, - image = gears.color.recolor_image(icon_dir .. "cpu.svg", color["Grey900"]), - resize = false - }, - id = "icon_layout", - widget = wibox.container.place - }, - top = dpi(2), - widget = wibox.container.margin, - id = "icon_margin" - }, - spacing = dpi(10), - { - id = "label", - align = "center", - valign = "center", - widget = wibox.widget.textbox - }, - id = "gpu_layout", - layout = wibox.layout.fixed.horizontal - }, - id = "container", - left = dpi(8), - right = dpi(8), - widget = wibox.container.margin - }, - bg = color["Blue200"], - fg = color["Grey900"], - shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } @@ -117,22 +120,29 @@ return function(widget) local temp_color local temp_num = tonumber(stdout) - if temp_num < 50 then + if temp_num then + + if temp_num < 50 then + temp_color = color["Green200"] + temp_icon = icon_dir .. "thermometer-low.svg" + elseif temp_num >= 50 and temp_num < 80 then + temp_color = color["Orange200"] + temp_icon = icon_dir .. "thermometer.svg" + elseif temp_num >= 80 then + temp_color = color["Red200"] + temp_icon = icon_dir .. "thermometer-high.svg" + end + else + temp_num = "NaN" temp_color = color["Green200"] temp_icon = icon_dir .. "thermometer-low.svg" - elseif temp_num >= 50 and temp_num < 80 then - temp_color = color["Orange200"] - temp_icon = icon_dir .. "thermometer.svg" - elseif temp_num >= 80 then - temp_color = color["Red200"] - temp_icon = icon_dir .. "thermometer-high.svg" end - - Hover_signal(gpu_temp_widget, temp_color, color["Grey900"]) + Hover_signal(gpu_temp_widget, temp_color, Theme_config.gpu_temp.fg) gpu_temp_widget.container.gpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon) gpu_temp_widget:set_bg(temp_color) gpu_temp_widget.container.gpu_layout.label.text = tostring(temp_num) .. "°C" awesome.emit_signal("update::gpu_temp_widget", temp_num, temp_icon) + end ) diff --git a/awesome/src/widgets/kblayout.lua b/awesome/src/widgets/kblayout.lua index 428ee72..4de7d3a 100644 --- a/awesome/src/widgets/kblayout.lua +++ b/awesome/src/widgets/kblayout.lua @@ -4,11 +4,9 @@ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") -require("src.core.signals") -- Icon directory path local icondir = awful.util.getdir("config") .. "src/assets/icons/kblayout/" @@ -23,7 +21,9 @@ return function(s) id = "icon", widget = wibox.widget.imagebox, resize = false, - image = gears.color.recolor_image(icondir .. "keyboard.svg", color["Grey900"]) + valign = "center", + halign = "center", + image = gears.color.recolor_image(icondir .. "keyboard.svg", Theme_config.kblayout.fg) }, id = "icon_layout", widget = wibox.container.place @@ -47,10 +47,10 @@ return function(s) right = dpi(8), widget = wibox.container.margin }, - bg = color["Green200"], - fg = color["Grey900"], + bg = Theme_config.kblayout.bg, + fg = Theme_config.kblayout.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } @@ -179,10 +179,10 @@ return function(s) { text = shortname, widget = wibox.widget.textbox, - font = user_vars.font.extrabold, + font = User_config.font.extrabold, id = "shortname" }, - fg = color["Red200"], + fg = Theme_config.kblayout.item.fg_short, widget = wibox.container.background, id = "background2" }, @@ -190,10 +190,10 @@ return function(s) { text = longname, widget = wibox.widget.textbox, - font = user_vars.font.bold, + font = User_config.font.bold, id = "longname", }, - fg = color["Purple200"], + fg = Theme_config.kblayout.item.fg_long, widget = wibox.container.background, id = "background1" }, @@ -206,10 +206,9 @@ return function(s) id = "margin" }, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 8) + gears.shape.rounded_rect(cr, width, height, dpi(8)) end, - bg = color["Grey800"], - fg = color["White"], + bg = Theme_config.kblayout.item.bg, widget = wibox.container.background, id = "background", keymap = keymap @@ -224,13 +223,13 @@ return function(s) function(stdout) local layout = stdout:gsub("\n", "") if kb_layout_item.keymap == layout then - kb_layout_item.bg = color["DeepPurple200"] - kb_layout_item:get_children_by_id("background2")[1].fg = color["Grey900"] - kb_layout_item:get_children_by_id("background1")[1].fg = color["Grey900"] + kb_layout_item.bg = Theme_config.kblayout.item.bg_selected + kb_layout_item:get_children_by_id("background2")[1].fg = Theme_config.kblayout.item.fg_selected + kb_layout_item:get_children_by_id("background1")[1].fg = Theme_config.kblayout.item.fg_selected else - kb_layout_item.bg = color["Grey800"] - kb_layout_item:get_children_by_id("background2")[1].fg = color["Red200"] - kb_layout_item:get_children_by_id("background1")[1].fg = color["Purple200"] + kb_layout_item.bg = Theme_config.kblayout.item.bg + kb_layout_item:get_children_by_id("background2")[1].fg = Theme_config.kblayout.item.fg_short + kb_layout_item:get_children_by_id("background1")[1].fg = Theme_config.kblayout.item.fg_long end end ) @@ -260,7 +259,7 @@ return function(s) layout = wibox.layout.fixed.vertical, spacing = dpi(10) } - for i, keymap in pairs(user_vars.kblayout) do + for i, keymap in pairs(User_config.kblayout) do kb_layout_items[i] = create_kb_layout_item(keymap) end local cont = { @@ -277,18 +276,19 @@ return function(s) local kb_menu_widget = awful.popup { screen = s, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 12) + gears.shape.rounded_rect(cr, width, height, dpi(12)) end, widget = wibox.container.background, - bg = color["Grey900"], - fg = color["White"], + bg = Theme_config.kblayout.bg_container, border_width = dpi(4), - border_color = color["Grey800"], + border_color = Theme_config.kblayout.border_color_container, width = dpi(100), max_height = dpi(600), visible = false, ontop = true, - placement = function(c) awful.placement.align(c, { position = "top_right", margins = { right = dpi(255), top = dpi(60) } }) end + placement = function(c) awful.placement.align(c, + { position = "top_right", margins = { right = dpi(255), top = dpi(60) } }) + end } kb_menu_widget:connect_signal( @@ -296,7 +296,7 @@ return function(s) function() mousegrabber.run( function() - kblayout_widget.bg = color["Green200"] + kblayout_widget.bg = Theme_config.kblayout.bg awesome.emit_signal("kblayout::hide:kbmenu") mousegrabber.stop() return true @@ -321,18 +321,18 @@ return function(s) awful.spawn.easy_async_with_shell( "setxkbmap -query | grep layout: | awk '{print $2}'", function(stdout) - for j, n in ipairs(user_vars.kblayout) do + for j, n in ipairs(User_config.kblayout) do if stdout:match(n) then - if j == #user_vars.kblayout then + if j == #User_config.kblayout then awful.spawn.easy_async_with_shell( - "setxkbmap " .. user_vars.kblayout[1], + "setxkbmap " .. User_config.kblayout[1], function() get_kblayout() end ) else awful.spawn.easy_async_with_shell( - "setxkbmap " .. user_vars.kblayout[j + 1], + "setxkbmap " .. User_config.kblayout[j + 1], function() get_kblayout() end @@ -352,7 +352,7 @@ return function(s) ) -- Signals - Hover_signal(kblayout_widget, color["Green200"], color["Grey900"]) + Hover_signal(kblayout_widget, Theme_config.kblayout.bg, Theme_config.kblayout.fg) local kblayout_keygrabber = awful.keygrabber { autostart = false, diff --git a/awesome/src/widgets/layout_list.lua b/awesome/src/widgets/layout_list.lua index bb28d1c..b22338a 100644 --- a/awesome/src/widgets/layout_list.lua +++ b/awesome/src/widgets/layout_list.lua @@ -4,11 +4,25 @@ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") -require("src.core.signals") + +--#region Layout icons +local layout_path = Theme_path .. "../assets/layout/" + +Theme.layout_floating = layout_path .. "floating.svg" +Theme.layout_tile = layout_path .. "tile.svg" +Theme.layout_dwindle = layout_path .. "dwindle.svg" +Theme.layout_fairh = layout_path .. "fairh.svg" +Theme.layout_fairv = layout_path .. "fairv.svg" +Theme.layout_fullscreen = layout_path .. "fullscreen.svg" +Theme.layout_max = layout_path .. "max.svg" +Theme.layout_cornerne = layout_path .. "cornerne.svg" +Theme.layout_cornernw = layout_path .. "cornernw.svg" +Theme.layout_cornerse = layout_path .. "cornerse.svg" +Theme.layout_cornersw = layout_path .. "cornersw.svg" +--#endregion -- Returns the layoutbox widget return function() @@ -25,15 +39,15 @@ return function() forced_width = dpi(40), widget = wibox.container.margin }, - bg = color["LightBlue200"], + bg = Theme_config.layout_list.bg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } -- Signals - Hover_signal(layout, color["LightBlue200"], color["Grey900"]) + Hover_signal(layout, Theme_config.layout_list.bg, Theme_config.layout_list.fg) layout:connect_signal( "button::press", diff --git a/awesome/src/widgets/network.lua b/awesome/src/widgets/network.lua index 60f2db3..0b2eb7f 100644 --- a/awesome/src/widgets/network.lua +++ b/awesome/src/widgets/network.lua @@ -4,20 +4,18 @@ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local naughty = require("naughty") local wibox = require("wibox") -require("src.core.signals") -- Icon directory path local icondir = awful.util.getdir("config") .. "src/assets/icons/network/" -- Insert your interfaces here, get the from ip a local interfaces = { - wlan_interface = user_vars.network.wlan, - lan_interface = user_vars.network.ethernet + wlan_interface = User_config.network.wlan, + lan_interface = User_config.network.ethernet } local network_mode = nil @@ -34,8 +32,10 @@ return function() { { id = 'icon', - image = gears.color.recolor_image(icondir .. "no-internet" .. ".svg", color["Grey900"]), + image = gears.color.recolor_image(icondir .. "no-internet" .. ".svg", Theme_config.network.fg), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", resize = false }, id = "icon_layout", @@ -61,10 +61,10 @@ return function() right = dpi(8), widget = wibox.container.margin }, - bg = color["Red200"], - fg = color["Grey900"], + bg = Theme_config.network.bg, + fg = Theme_config.network.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } @@ -111,7 +111,7 @@ return function() text = message, title = title, app_name = app_name, - icon = gears.color.recolor_image(icon, color["White"]), + icon = gears.color.recolor_image(icon, Theme_config.network.notify_icon_color), timeout = 3 } end @@ -133,7 +133,10 @@ return function() function(stdout) local essid = stdout:match("SSID: (.-)\n") or "N/A" local bitrate = stdout:match("tx bitrate: (.+/s)") or "N/A" - local message = "Connected to " .. essid .. "\nSignal strength " .. tostring(wifi_strength) .. "%\n" .. "Bit rate " .. tostring(bitrate) .. "" + local message = "Connected to " .. + essid .. + "\nSignal strength " .. + tostring(wifi_strength) .. "%\n" .. "Bit rate " .. tostring(bitrate) .. "" if healthy then update_tooltip(message) @@ -165,7 +168,8 @@ return function() update_wireless_data(false) end network_widget.container.network_layout.spacing = dpi(8) - network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. icon .. ".svg", color["Grey900"])) + network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir + .. icon .. ".svg", Theme_config.network.fg)) end ) end @@ -222,7 +226,7 @@ return function() update_reconnect_startup(false) end network_widget.container.network_layout.label.visible = false - network_widget.container.network_layout.spacing = dpi(0) + network_widget.container.network_layout.spacing = 0 network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(icondir .. icon .. ".svg") end ) @@ -230,14 +234,14 @@ return function() end local update_disconnected = function() - local notify_wireless_disconnected = function(essid) + local notify_wireless_disconnected = function() local message = "WiFi has been disconnected" local title = "Connection lost" local app_name = "System Notification" local icon = icondir .. "wifi-strength-off-outline.svg" network_notify(message, title, app_name, icon) end - local notify_wired_disconnected = function(essid) + local notify_wired_disconnected = function() local message = "Ethernet has been unplugged" local title = "Connection lost" local app_name = "System Notification" @@ -260,8 +264,9 @@ return function() end network_widget.container.network_layout.label.visible = false update_tooltip("Network unreachable") - network_widget.container.network_layout.spacing = dpi(0) - network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. icon .. ".svg", color["Grey900"])) + network_widget.container.network_layout.spacing = 0 + network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. + icon .. ".svg", Theme_config.network.fg)) end local check_network_mode = function() @@ -302,7 +307,6 @@ return function() print_network_mode ]=], function(stdout) - local mode = stdout:gsub("%\n", "") if stdout:match("No internet connected") then update_disconnected() elseif stdout:match("wireless") then @@ -324,7 +328,7 @@ return function() } -- Signals - Hover_signal(network_widget, color["Red200"], color["Grey900"]) + Hover_signal(network_widget, Theme_config.network.bg, Theme_config.network.fg) network_widget:connect_signal( "button::press", diff --git a/awesome/src/widgets/power.lua b/awesome/src/widgets/power.lua index 95812ab..89d2251 100644 --- a/awesome/src/widgets/power.lua +++ b/awesome/src/widgets/power.lua @@ -4,11 +4,9 @@ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") -require("src.core.signals") -- Icon directory path local icondir = awful.util.getdir("config") .. "src/assets/icons/power/" @@ -22,8 +20,10 @@ return function() { { id = "icon", - image = gears.color.recolor_image(icondir .. "power.svg", color["Grey900"]), + image = gears.color.recolor_image(icondir .. "power.svg", Theme_config.power_button.fg), widget = wibox.widget.imagebox, + valign = "center", + halign = "center", resize = false }, id = "icon_layout", @@ -41,16 +41,16 @@ return function() right = dpi(8), widget = wibox.container.margin }, - bg = color["Red200"], - fg = color["Grey800"], + bg = Theme_config.power_button.bg, + fg = Theme_config.power_button.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } -- Signals - Hover_signal(power_widget, color["Red200"], color["Grey900"]) + Hover_signal(power_widget, Theme_config.power_button.bg, Theme_config.power_button.fg) power_widget:connect_signal( "button::release", diff --git a/awesome/src/widgets/ram_info.lua b/awesome/src/widgets/ram_info.lua index 14e8c74..4fe2657 100644 --- a/awesome/src/widgets/ram_info.lua +++ b/awesome/src/widgets/ram_info.lua @@ -4,12 +4,10 @@ -- Awesome Libs local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local watch = awful.widget.watch local wibox = require("wibox") -require("src.core.signals") local icon_dir = awful.util.getdir("config") .. "src/assets/icons/cpu/" @@ -22,7 +20,9 @@ return function() { id = "icon", widget = wibox.widget.imagebox, - image = gears.color.recolor_image(icon_dir .. "ram.svg", color["Grey900"]), + valign = "center", + halign = "center", + image = gears.color.recolor_image(icon_dir .. "ram.svg", Theme_config.ram_info.fg), resize = false }, id = "icon_layout", @@ -47,15 +47,15 @@ return function() right = dpi(8), widget = wibox.container.margin }, - bg = color["Red200"], - fg = color["Grey900"], + bg = Theme_config.ram_info.bg, + fg = Theme_config.ram_info.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } - Hover_signal(ram_widget, color["Red200"], color["Grey900"]) + Hover_signal(ram_widget, Theme_config.ram_info.bg, Theme_config.ram_info.fg) watch( [[ bash -c "cat /proc/meminfo| grep Mem | awk '{print $2}'" ]], @@ -64,7 +64,8 @@ return function() local MemTotal, MemFree, MemAvailable = stdout:match("(%d+)\n(%d+)\n(%d+)\n") - local ram_string = tostring(string.format("%.1f", ((MemTotal - MemAvailable) / 1024 / 1024)) .. "/" .. string.format("%.1f", (MemTotal / 1024 / 1024)) .. "GB"):gsub(",", ".") + local ram_string = tostring(string.format("%.1f", ((MemTotal - MemAvailable) / 1024 / 1024)) .. + "/" .. string.format("%.1f", (MemTotal / 1024 / 1024)) .. "GB"):gsub(",", ".") ram_widget.container.ram_layout.label.text = ram_string awesome.emit_signal("update::ram_widget", math.floor(((MemTotal - MemAvailable) / MemTotal * 100) + 0.5)) diff --git a/awesome/src/widgets/systray.lua b/awesome/src/widgets/systray.lua index 41945f4..ee85a61 100644 --- a/awesome/src/widgets/systray.lua +++ b/awesome/src/widgets/systray.lua @@ -3,13 +3,12 @@ -------------------------------- -- Awesome Libs -local awful = require("awful") -local color = require("src.theme.colors") local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") -require("src.core.signals") +Theme.bg_systray = Theme_config.systray.bg +Theme.systray_icon_spacing = dpi(10) return function(s) local systray = wibox.widget { @@ -25,12 +24,12 @@ return function(s) }, widget = wibox.container.background, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, - bg = color["BlueGrey800"] + bg = Theme_config.systray.bg } -- Signals - Hover_signal(systray.container, color["Red200"], color["Grey900"]) + Hover_signal(systray.container, Theme_config.systray.bg, Theme_config.systray.bg) awesome.connect_signal("systray::update", function() local num_entries = awesome.systray() @@ -42,7 +41,7 @@ return function(s) end end) - systray.container.st.widget:set_base_size(dpi(20)) + systray.container.st.widget:set_base_size(dpi(24)) return systray end diff --git a/awesome/src/widgets/taglist.lua b/awesome/src/widgets/taglist.lua index 97798bd..6b73a92 100644 --- a/awesome/src/widgets/taglist.lua +++ b/awesome/src/widgets/taglist.lua @@ -7,10 +7,8 @@ local wibox = require("wibox") local awful = require("awful") local gears = require("gears") local dpi = require("beautiful").xresources.apply_dpi -local color = require("src.theme.colors") -require("src.tools.icon_handler") -local list_update = function(widget, buttons, label, data, objects) +local list_update = function(widget, buttons, _, _, objects) widget:reset() for _, object in ipairs(objects) do @@ -23,7 +21,7 @@ local list_update = function(widget, buttons, label, data, objects) align = "center", valign = "center", visible = true, - font = user_vars.font.extrabold, + font = User_config.font.extrabold, forced_width = dpi(25), id = "label", widget = wibox.widget.textbox @@ -36,25 +34,25 @@ local list_update = function(widget, buttons, label, data, objects) id = "container", layout = wibox.layout.fixed.horizontal }, - fg = color["White"], + fg = Theme_config.taglist.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } - local function create_buttons(buttons, object) - if buttons then + local function create_buttons(buttons_t, object_t) + if buttons_t then local btns = {} - for _, b in ipairs(buttons) do + for _, b in ipairs(buttons_t) do local btn = awful.button { modifiers = b.modifiers, button = b.button, on_press = function() - b:emit_signal('press', object) + b:emit_signal('press', object_t) end, on_release = function() - b:emit_signal('release', object) + b:emit_signal('release', object_t) end } btns[#btns + 1] = btn @@ -67,13 +65,13 @@ local list_update = function(widget, buttons, label, data, objects) tag_widget.container.margin.label:set_text(object.index) if object.urgent == true then - tag_widget:set_bg(color["RedA200"]) - tag_widget:set_fg(color["Grey900"]) + tag_widget:set_bg(Theme_config.taglist.bg_urgent) + tag_widget:set_fg(Theme_config.taglist.fg_urgent) elseif object == awful.screen.focused().selected_tag then - tag_widget:set_bg(color["White"]) - tag_widget:set_fg(color["Grey900"]) + tag_widget:set_bg(Theme_config.taglist.bg_focus) + tag_widget:set_fg(Theme_config.taglist.fg_focus) else - tag_widget:set_bg("#3A475C") + tag_widget:set_bg(Theme_config.taglist.bg) end -- Set the icon for each client @@ -85,6 +83,8 @@ local list_update = function(widget, buttons, label, data, objects) { id = "icon", resize = true, + valign = "center", + halign = "center", widget = wibox.widget.imagebox }, widget = wibox.container.place @@ -93,7 +93,9 @@ local list_update = function(widget, buttons, label, data, objects) margins = dpi(6), widget = wibox.container.margin } - icon.icon_container.icon:set_image(Get_icon(user_vars.icon_theme, client)) + + icon.icon_container.icon:set_image(xdg_icon_lookup:find_icon(client.class, 64)) + tag_widget.container:setup({ icon, strategy = "exact", @@ -102,15 +104,14 @@ local list_update = function(widget, buttons, label, data, objects) end --#region Hover_signal - local old_wibox, old_cursor, old_bg + local old_wibox, old_cursor tag_widget:connect_signal( "mouse::enter", function() - old_bg = tag_widget.bg if object == awful.screen.focused().selected_tag then - tag_widget.bg = '#dddddd' .. 'dd' + tag_widget.bg = Theme_config.taglist.bg_focus_hover .. 'dd' else - tag_widget.bg = '#3A475C' .. 'dd' + tag_widget.bg = Theme_config.taglist.bg .. 'dd' end local w = mouse.current_wibox if w then @@ -124,9 +125,9 @@ local list_update = function(widget, buttons, label, data, objects) "button::press", function() if object == awful.screen.focused().selected_tag then - tag_widget.bg = '#bbbbbb' .. 'dd' + tag_widget.bg = Theme_config.taglist.bg_focus_pressed .. 'dd' else - tag_widget.bg = '#3A475C' .. 'dd' + tag_widget.bg = Theme_config.taglist.bg .. 'dd' end end ) @@ -135,9 +136,9 @@ local list_update = function(widget, buttons, label, data, objects) "button::release", function() if object == awful.screen.focused().selected_tag then - tag_widget.bg = '#dddddd' .. 'dd' + tag_widget.bg = Theme_config.taglist.bg_focus_hover .. 'dd' else - tag_widget.bg = '#3A475C' .. 'dd' + tag_widget.bg = Theme_config.taglist.bg .. 'dd' end end ) @@ -145,7 +146,11 @@ local list_update = function(widget, buttons, label, data, objects) tag_widget:connect_signal( "mouse::leave", function() - tag_widget.bg = old_bg + if object == awful.screen.focused().selected_tag then + tag_widget.bg = Theme_config.taglist.bg_focus + else + tag_widget.bg = Theme_config.taglist.bg + end if old_wibox then old_wibox.cursor = old_cursor old_wibox = nil diff --git a/awesome/src/widgets/tasklist.lua b/awesome/src/widgets/tasklist.lua index fdc219a..57b6e3b 100644 --- a/awesome/src/widgets/tasklist.lua +++ b/awesome/src/widgets/tasklist.lua @@ -7,9 +7,8 @@ local awful = require('awful') local wibox = require('wibox') local dpi = require('beautiful').xresources.apply_dpi local gears = require('gears') -local color = require('src.theme.colors') -local list_update = function(widget, buttons, label, data, objects) +local list_update = function(widget, buttons, label, _, objects) widget:reset() for _, object in ipairs(objects) do local task_widget = wibox.widget { @@ -20,6 +19,8 @@ local list_update = function(widget, buttons, label, data, objects) nil, { id = "icon", + valign = "center", + halign = "center", resize = true, widget = wibox.widget.imagebox }, @@ -48,10 +49,9 @@ local list_update = function(widget, buttons, label, data, objects) widget = wibox.container.margin, id = "container" }, - bg = color["White"], - fg = color["Grey900"], + fg = Theme_config.tasklist.fg, shape = function(cr, width, height) - gears.shape.rounded_rect(cr, width, height, 5) + gears.shape.rounded_rect(cr, width, height, dpi(6)) end, widget = wibox.container.background } @@ -66,18 +66,18 @@ local list_update = function(widget, buttons, label, data, objects) delay_show = 1 } - local function create_buttons(buttons, object) - if buttons then + local function create_buttons(buttons_t, object_t) + if buttons_t then local btns = {} - for _, b in ipairs(buttons) do + for _, b in ipairs(buttons_t) do local btn = awful.button { modifiers = b.modifiers, button = b.button, on_press = function() - b:emit_signal('press', object) + b:emit_signal('press', object_t) end, on_release = function() - b:emit_signal('release', object) + b:emit_signal('release', object_t) end } btns[#btns + 1] = btn @@ -106,27 +106,26 @@ local list_update = function(widget, buttons, label, data, objects) task_tool_tip:remove_from_object(task_widget) end end - task_widget:set_bg(color["White"]) - task_widget:set_fg(color["Grey900"]) + task_widget:set_bg(Theme_config.tasklist.bg_focus) + task_widget:set_fg(Theme_config.tasklist.fg_focus) task_widget.container.layout_it.title:set_text(text) else - task_widget:set_bg("#3A475C") + task_widget:set_bg(Theme_config.tasklist.bg) task_widget.container.layout_it.title:set_text('') end - task_widget.container.layout_it.margin.layout_icon.icon:set_image(Get_icon(user_vars.icon_theme, object)) + task_widget.container.layout_it.margin.layout_icon.icon:set_image(xdg_icon_lookup:find_icon(object.class, 64)) widget:add(task_widget) widget:set_spacing(dpi(6)) --#region Hover_signal - local old_wibox, old_cursor, old_bg + local old_wibox, old_cursor task_widget:connect_signal( "mouse::enter", function() - old_bg = task_widget.bg if object == client.focus then - task_widget.bg = '#dddddddd' + task_widget.bg = Theme_config.tasklist.bg_focus_hover .. "dd" else - task_widget.bg = '#3A475Cdd' + task_widget.bg = Theme_config.tasklist.bg .. 'dd' end local w = mouse.current_wibox if w then @@ -140,9 +139,9 @@ local list_update = function(widget, buttons, label, data, objects) "button::press", function() if object == client.focus then - task_widget.bg = "#ffffffaa" + task_widget.bg = Theme_config.tasklist.bg_focus_pressed .. "dd" else - task_widget.bg = '#3A475Caa' + task_widget.bg = Theme_config.tasklist.bg .. "dd" end end ) @@ -151,9 +150,9 @@ local list_update = function(widget, buttons, label, data, objects) "button::release", function() if object == client.focus then - task_widget.bg = "#ffffffdd" + task_widget.bg = Theme_config.tasklist.bg_focus_hover .. "dd" else - task_widget.bg = '#3A475Cdd' + task_widget.bg = Theme_config.tasklist.bg .. "dd" end end ) @@ -161,7 +160,11 @@ local list_update = function(widget, buttons, label, data, objects) task_widget:connect_signal( "mouse::leave", function() - task_widget.bg = old_bg + if object == client.focus then + task_widget.bg = Theme_config.tasklist.bg_focus + else + task_widget.bg = Theme_config.tasklist.bg + end if old_wibox then old_wibox.cursor = old_cursor old_wibox = nil