diff --git a/.gitmodules b/.gitmodules index 8da36a8..1a3d6b5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,9 @@ [submodule "awesome/src/lib/rubato"] path = awesome/src/lib/rubato url = https://github.com/andOrlando/rubato +[submodule "awesome/src/lib/awesome/src/lib/color"] + path = awesome/src/lib/awesome/src/lib/color + url = https://github.com/andOrlando/color +[submodule "awesome/src/lib/color"] + path = awesome/src/lib/color + url = https://github.com/andOrlando/color diff --git a/awesome/rc.lua b/awesome/rc.lua index 8e70a3e..9e4020d 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -12,6 +12,7 @@ require("src.theme.theme_config") require("src.tools.gio_icon_lookup") require("src.theme.init") require("src.core.error_handling") +require("src.tools.hex_to_rgba") require("src.core.signals") require("src.core.notifications") require("src.core.rules") @@ -19,6 +20,5 @@ require("src.bindings.global_buttons") require("src.bindings.bind_to_tags") require("src.modules.init") require("src.tools.helpers.init") -require("src.tools.hex_to_rgba") require("src.tools.auto_starter")(User_config.autostart) require("src.tools.dbus.bluetooth_dbus")() diff --git a/awesome/src/assets/icons/titlebar/maximize.svg b/awesome/src/assets/icons/titlebar/maximize.svg index 79a277d..f58a678 100644 --- a/awesome/src/assets/icons/titlebar/maximize.svg +++ b/awesome/src/assets/icons/titlebar/maximize.svg @@ -1,3 +1,3 @@ - + diff --git a/awesome/src/bindings/global_keys.lua b/awesome/src/bindings/global_keys.lua index 0abc925..40e30dc 100644 --- a/awesome/src/bindings/global_keys.lua +++ b/awesome/src/bindings/global_keys.lua @@ -4,6 +4,8 @@ local awful = require("awful") local hotkeys_popup = require("awful.hotkeys_popup") local ruled = require("ruled") +local json = require("src.lib.json-lua.json-lua") + local modkey = User_config.modkey awful.keygrabber { @@ -306,36 +308,54 @@ return gears.table.join( { modkey }, "#22", function() - awful.spawn.easy_async_with_shell( - [[xprop | grep WM_CLASS | awk '{gsub(/"/, "", $4); print $4}']], - function(stdout) - if stdout then + mousegrabber.run( + function(m) + if m.buttons[1] then + + local handler = io.open("/home/crylia/.config/awesome/src/config/floating.json", "r") + if not handler then return end + local data_table = json:decode(handler:read("a")) or {} + handler:close() + + if type(data_table) ~= "table" then return end + + local c = mouse.current_client + if not c then return end + + local client_data = { + WM_NAME = c.name, + WM_CLASS = c.class, + WM_INSTANCE = c.instance, + } + + -- Check if data_table already had the client then return + for _, v in ipairs(data_table) do + if v.WM_NAME == client_data.WM_NAME and + v.WM_CLASS == client_data.WM_CLASS and + v.WM_INSTANCE == client_data.WM_INSTANCE then + return + end + end + + table.insert(data_table, client_data) + ruled.client.append_rule { - rule = { class = stdout:gsub("\n", "") }, + rule = { class = c.class, instance = c.instance }, properties = { floating = true }, } - awful.spawn.easy_async_with_shell( - "cat ~/.config/awesome/src/assets/cache/rules.txt", - function(stdout2) - for class in stdout2:gmatch("%a+") do - if class:match(stdout:gsub("\n", "")) then - return - end - end - awful.spawn.with_shell("echo -n '" .. - stdout:gsub("\n", "") .. ";' >> ~/.config/awesome/src/assets/cache/rules.txt") - local c = mouse.screen.selected_tag:clients() - for _, client in ipairs(c) do - if client.class:match(stdout:gsub("\n", "")) then - client.floating = true - end - end - end - ) + c.floating = true + + handler = io.open("/home/crylia/.config/awesome/src/config/floating.json", "w") + if not handler then return end + handler:write(json:encode(data_table)) + handler:close() + mousegrabber.stop() end - end + return true + end, + "crosshair" ) end ), @@ -343,33 +363,51 @@ return gears.table.join( { modkey, "Shift" }, "#22", function() - awful.spawn.easy_async_with_shell( - [[xprop | grep WM_CLASS | awk '{gsub(/"/, "", $4); print $4}']], - function(stdout) - if stdout then - ruled.client.append_rule { - rule = { class = stdout:gsub("\n", "") }, - properties = { - floating = false - }, + mousegrabber.run( + function(m) + if m.buttons[1] then + + local handler = io.open("/home/crylia/.config/awesome/src/config/floating.json", "r") + if not handler then return end + local data_table = json:decode(handler:read("a")) or {} + handler:close() + + if type(data_table) ~= "table" then return end + + local c = mouse.current_client + if not c then return end + + local client_data = { + WM_NAME = c.name, + WM_CLASS = c.class, + WM_INSTANCE = c.instance, } - awful.spawn.easy_async_with_shell( - [[ - REMOVE="]] .. stdout:gsub("\n", "") .. [[;" - STR=$(cat ~/.config/awesome/src/assets/cache/rules.txt) - echo -n ${STR//$REMOVE/} > ~/.config/awesome/src/assets/cache/rules.txt - ]], - function() - local c = mouse.screen.selected_tag:clients() - for _, client in ipairs(c) do - if client.class:match(stdout:gsub("\n", "")) then - client.floating = false - end - end + + -- Remove client_data from data_table + for k, v in ipairs(data_table) do + if v.WM_CLASS == client_data.WM_CLASS and + v.WM_INSTANCE == client_data.WM_INSTANCE then + table.remove(data_table, k) + ruled.client.remove_rule { + rule = { class = c.class, instance = c.instance }, + properties = { + floating = true + }, + } + c.floating = false + break end - ) + end + + handler = io.open("/home/crylia/.config/awesome/src/config/floating.json", "w") + if not handler then return end + handler:write(json:encode(data_table)) + handler:close() + mousegrabber.stop() end - end + return true + end, + "crosshair" ) end ) diff --git a/awesome/src/config/dock.json b/awesome/src/config/dock.json index d53c8c4..1d118c6 100644 --- a/awesome/src/config/dock.json +++ b/awesome/src/config/dock.json @@ -1 +1 @@ -[{"actions":["New"],"categories":"System;TerminalEmulator;","comment":"A fast, cross-platform, OpenGL terminal emulator","desktop_file":"/usr/share/applications/com.alacritty.Alacritty.desktop","exec":"alacritty","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/com.alacritty.Alacritty.svg","keywords":"","name":"Alacritty","terminal":""},{"actions":["new-window","new-private-window"],"categories":"Network;WebBrowser;","comment":"Access the Internet","desktop_file":"/var/lib/flatpak/exports/share/applications/com.brave.Browser.desktop","exec":"/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=brave --file-forwarding com.brave.Browser @@u %U @@","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/com.brave.Browser.svg","keywords":"","name":"Brave","terminal":""},{"actions":["new-empty-window"],"categories":"TextEditor;Development;IDE;","comment":"Code Editing. Redefined.","desktop_file":"/usr/share/applications/code.desktop","exec":"/usr/share/code/code --unity-launch %F","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/com.visualstudio.code.svg","keywords":"vscode;","name":"Visual Studio Code","terminal":""},{"actions":[],"categories":"Audio;Music;Player;AudioVideo;","comment":"","desktop_file":"/usr/local/share/applications/spotify.desktop","exec":"spotify %U","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/spotify-client.svg","keywords":"","name":"Spotify","terminal":""},{"actions":[],"categories":"Network;InstantMessaging;","comment":"All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.","desktop_file":"/usr/share/applications/discord.desktop","exec":"/usr/share/discord/Discord","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/discord.svg","keywords":"","name":"Discord","terminal":""},{"actions":["Store","Community","Library","Servers","Screenshots","News","Settings","BigPicture","Friends"],"categories":"Network;FileTransfer;Game;","comment":"Application for managing and playing games on Steam","desktop_file":"/usr/share/applications/steam.desktop","exec":"/usr/games/steam %U","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/steam.svg","keywords":"Games","name":"Steam","terminal":""},{"actions":["Remove"],"categories":"Graphics;","comment":"Cura converts 3D models into paths for a 3D printer. It prepares your print for maximum accuracy, minimum printing time and good reliability with many extra features that make your print come out great.","desktop_file":"/home/crylia/.local/share/applications/appimagekit_5de59b772d786d6e98102a035c80e40c-Ultimaker_Cura.desktop","exec":"/home/crylia/Applications/Ultimaker-Cura-5.0.0-linux_07ecc3f54905e865167d2bcd7cfe459c.AppImage %F","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/appimagekit-cura-icon.svg","keywords":"3D;Printing;","name":"Ultimaker Cura (5.0.0)","terminal":""},{"actions":[],"categories":"Game;","comment":"video game preservation platform","desktop_file":"/usr/share/applications/net.lutris.Lutris.desktop","exec":"lutris %U","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/lutris.svg","keywords":"gaming;wine;emulator;","name":"Lutris","terminal":""},{"actions":[],"categories":"Graphics;Science;Engineering","comment":"Feature based Parametric Modeler","desktop_file":"/usr/share/applications/freecad.desktop","exec":"/usr/bin/freecad --single-instance %F","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/freecad.svg","keywords":"","name":"FreeCAD","terminal":""},{"actions":[],"categories":"Graphics;3DGraphics;","comment":"3D modeling, animation, rendering and post-production","desktop_file":"/usr/share/applications/blender.desktop","exec":"blender %f","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/blender.svg","keywords":"3d;cg;modeling;animation;painting;sculpting;texturing;video editing;video tracking;rendering;render engine;cycles;game engine;python;","name":"Blender","terminal":""},{"actions":[],"categories":"Game;","comment":"Play this game on Steam","desktop_file":"/home/crylia/.local/share/applications/The Witcher 3 Wild Hunt.desktop","exec":"steam steam://rungameid/292030","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/steam_icon_292030.svg","keywords":"","name":"The Witcher 3: Wild Hunt","terminal":""},{"actions":[],"categories":"Game;","comment":"Play this game on Steam","desktop_file":"/home/crylia/.local/share/applications/Hearts of Iron IV.desktop","exec":"steam steam://rungameid/394360","icon":"/home/crylia/.local/share/icons/hicolor/64x64/apps/steam_icon_394360.png","keywords":"","name":"Hearts of Iron IV","terminal":""}] \ No newline at end of file +[{"actions":["New"],"categories":"System;TerminalEmulator;","comment":"A fast, cross-platform, OpenGL terminal emulator","desktop_file":"/usr/share/applications/com.alacritty.Alacritty.desktop","exec":"alacritty","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/com.alacritty.Alacritty.svg","keywords":"","name":"Alacritty","terminal":""},{"actions":["new-window","new-private-window"],"categories":"Network;WebBrowser;","comment":"Access the Internet","desktop_file":"/var/lib/flatpak/exports/share/applications/com.brave.Browser.desktop","exec":"/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=brave --file-forwarding com.brave.Browser @@u %U @@","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/com.brave.Browser.svg","keywords":"","name":"Brave","terminal":""},{"actions":["new-empty-window"],"categories":"TextEditor;Development;IDE;","comment":"Code Editing. Redefined.","desktop_file":"/usr/share/applications/code.desktop","exec":"/usr/share/code/code --unity-launch %F","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/com.visualstudio.code.svg","keywords":"vscode;","name":"Visual Studio Code","terminal":""},{"actions":[],"categories":"Audio;Music;Player;AudioVideo;","comment":"","desktop_file":"/usr/local/share/applications/spotify.desktop","exec":"spotify %U","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/spotify-client.svg","keywords":"","name":"Spotify","terminal":""},{"actions":[],"categories":"Network;InstantMessaging;","comment":"All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.","desktop_file":"/usr/share/applications/discord.desktop","exec":"/usr/share/discord/Discord","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/discord.svg","keywords":"","name":"Discord","terminal":""},{"actions":["Store","Community","Library","Servers","Screenshots","News","Settings","BigPicture","Friends"],"categories":"Network;FileTransfer;Game;","comment":"Application for managing and playing games on Steam","desktop_file":"/usr/share/applications/steam.desktop","exec":"/usr/games/steam %U","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/steam.svg","keywords":"Games","name":"Steam","terminal":""},{"actions":["Remove"],"categories":"Graphics;","comment":"Cura converts 3D models into paths for a 3D printer. It prepares your print for maximum accuracy, minimum printing time and good reliability with many extra features that make your print come out great.","desktop_file":"/home/crylia/.local/share/applications/appimagekit_5de59b772d786d6e98102a035c80e40c-Ultimaker_Cura.desktop","exec":"/home/crylia/Applications/Ultimaker-Cura-5.0.0-linux_07ecc3f54905e865167d2bcd7cfe459c.AppImage %F","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/appimagekit-cura-icon.svg","keywords":"3D;Printing;","name":"Ultimaker Cura (5.0.0)","terminal":""},{"actions":[],"categories":"Game;","comment":"video game preservation platform","desktop_file":"/usr/share/applications/net.lutris.Lutris.desktop","exec":"lutris %U","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/lutris.svg","keywords":"gaming;wine;emulator;","name":"Lutris","terminal":""},{"actions":[],"categories":"Graphics;Science;Engineering","comment":"Feature based Parametric Modeler","desktop_file":"/usr/share/applications/freecad.desktop","exec":"/usr/bin/freecad --single-instance %F","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/freecad.svg","keywords":"","name":"FreeCAD","terminal":""},{"actions":[],"categories":"Graphics;3DGraphics;","comment":"3D modeling, animation, rendering and post-production","desktop_file":"/usr/share/applications/blender.desktop","exec":"blender %f","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/blender.svg","keywords":"3d;cg;modeling;animation;painting;sculpting;texturing;video editing;video tracking;rendering;render engine;cycles;game engine;python;","name":"Blender","terminal":""},{"actions":[],"categories":"Game;","comment":"Play this game on Steam","desktop_file":"/home/crylia/.local/share/applications/The Witcher 3 Wild Hunt.desktop","exec":"steam steam://rungameid/292030","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/steam_icon_292030.svg","keywords":"","name":"The Witcher 3: Wild Hunt","terminal":""},{"actions":[],"categories":"Game;","comment":"Play this game on Steam","desktop_file":"/home/crylia/.local/share/applications/Hearts of Iron IV.desktop","exec":"steam steam://rungameid/394360","icon":"/home/crylia/.local/share/icons/hicolor/64x64/apps/steam_icon_394360.png","keywords":"","name":"Hearts of Iron IV","terminal":""},{"actions":["Compose","Contacts"],"categories":"Application;Network;Email;","comment":"Send and receive mail with Thunderbird","desktop_file":"/usr/share/applications/thunderbird.desktop","exec":"thunderbird %u","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/thunderbird.svg","keywords":"Email;E-mail;Newsgroup;Feed;RSS","name":"Thunderbird-E-Mail und -Nachrichten","terminal":""}] \ No newline at end of file diff --git a/awesome/src/config/floating.json b/awesome/src/config/floating.json new file mode 100644 index 0000000..392b837 --- /dev/null +++ b/awesome/src/config/floating.json @@ -0,0 +1 @@ +[{"WM_CLASS":"Paradox Launcher","WM_INSTANCE":"paradox launcher","WM_NAME":"Paradox Launcher"},{"WM_CLASS":"Com.github.donadigo.eddy","WM_INSTANCE":"com.github.donadigo.eddy","WM_NAME":"Eddy"},{"WM_CLASS":"jamesdsp","WM_INSTANCE":"jamesdsp","WM_NAME":"JamesDSP for Linux"},{"WM_CLASS":"Gwe","WM_INSTANCE":"gwe","WM_NAME":"GWE"},{"WM_CLASS":"Steam","WM_INSTANCE":"Steam","WM_NAME":"Freundesliste"},{"WM_CLASS":"Thunderbird","WM_INSTANCE":"Calendar","WM_NAME":"New Event:"},{"WM_CLASS":"Thunderbird","WM_INSTANCE":"Mail","WM_NAME":"Calendar - Mozilla Thunderbird"},{"WM_CLASS":"Proton Mail Bridge","WM_INSTANCE":"proton-bridge","WM_NAME":"Proton Mail Bridge"}] \ No newline at end of file diff --git a/awesome/src/core/notifications.lua b/awesome/src/core/notifications.lua index 69c9041..f933042 100644 --- a/awesome/src/core/notifications.lua +++ b/awesome/src/core/notifications.lua @@ -354,24 +354,19 @@ naughty.connect_signal( rubato_timer.target = 0 - local last_position = n.timeout - w_template:connect_signal( "mouse::enter", function() n.timeout = 99999 - last_position = rubato_timer.pos - rubato_timer:abort() + rubato_timer.pause = true end ) w_template:connect_signal( "mouse::leave", function() - n.timeout = last_position - rubato_timer.pos = last_position - rubato_timer.duration = last_position - rubato_timer:reset() + n.timeout = rubato_timer.pos + rubato_timer.pause = false rubato_timer.target = 0 end ) diff --git a/awesome/src/core/rules.lua b/awesome/src/core/rules.lua index 393786a..36403c0 100644 --- a/awesome/src/core/rules.lua +++ b/awesome/src/core/rules.lua @@ -7,6 +7,8 @@ local awful = require("awful") local beautiful = require("beautiful") local ruled = require("ruled") +local json = require("src.lib.json-lua.json-lua") + awful.rules.rules = { { rule = {}, @@ -18,33 +20,8 @@ awful.rules.rules = { keys = require("src.bindings.client_keys"), buttons = require("src.bindings.client_buttons"), screen = awful.screen.preferred, - placement = awful.placement.under_mouse + awful.placement.no_overlap + awful.placement.no_offscreen - } - }, - { - rule_any = { - instance = {}, - class = { - "Arandr", - "Lxappearance", - "kdeconnect.app", - "zoom", - "file-roller", - "File-roller" - }, - name = {}, - role = { - "AlarmWindow", - "ConfigManager", - "pop-up", - "dialog", - "modal", - "utility" - } - }, - properties = { - floating = true, - titlebars_enabled = true + placement = awful.placement.under_mouse + awful.placement.no_overlap + awful.placement.no_offscreen + + awful.placement.centered } }, { @@ -76,16 +53,19 @@ awful.rules.rules = { } } -awful.spawn.easy_async_with_shell( - "cat ~/.config/awesome/src/assets/cache/rules.txt", - function(stdout) - for class in stdout:gmatch("%a+") do - ruled.client.append_rule { - rule = { class = class }, - properties = { - floating = true - }, - } - end - end -) +local handler = io.open("/home/crylia/.config/awesome/src/config/floating.json", "r") + +if not handler then return end +local data = json:decode(handler:read("a")) +handler:close() + +if type(data) ~= "table" then return end + +for _, c in ipairs(data) do + ruled.client.append_rule { + rule = { class = c.WM_CLASS, instance = c.WM_INSTANCE }, + properties = { + floating = true + }, + } +end diff --git a/awesome/src/core/signals.lua b/awesome/src/core/signals.lua index f668716..a45c2ec 100644 --- a/awesome/src/core/signals.lua +++ b/awesome/src/core/signals.lua @@ -2,7 +2,9 @@ -- Awesome Libs local awful = require("awful") local gears = require("gears") -local wibox = require("wibox") + +local color = require("src.lib.color") +local rubato = require("src.lib.rubato") screen.connect_signal( "added", @@ -71,7 +73,7 @@ tag.connect_signal( ) -- Sloppy focus -client.connect_signal( +--[[ client.connect_signal( "mouse::enter", function(c) c:emit_signal( @@ -82,7 +84,7 @@ client.connect_signal( } ) end -) +) ]] --- Takes a wibox.container.background and connects four signals to it ---@param widget wibox.container.background a background widget @@ -96,25 +98,41 @@ function Hover_signal(widget, bg_override, fg_override, border_override, icon_ov local r, g, b - widget.bg = widget.bg or "" - widget.fg = widget.fg or "" - widget.border_color = widget.border_color or "" + widget.bg = widget.bg or "#000000" + widget.fg = widget.fg or "#000000" + widget.border_color = widget.border_color or "#000000" local icon = nil if icon_override and icon_override_hover then icon = widget:get_children_by_id("icon")[1].icon widget.icon = widget:get_children_by_id("icon")[1] end + --[[ local r_timed_bg = rubato.timed { duration = 0.5 } + local g_timed_bg = rubato.timed { duration = 0.5 } + local b_timed_bg = rubato.timed { duration = 0.5 } + + local function update_bg() + widget:set_bg("#" .. color.utils.rgba_to_hex { r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos }) + end + + r_timed_bg:subscribe(update_bg) + g_timed_bg:subscribe(update_bg) + b_timed_bg:subscribe(update_bg) + + local function set_bg(newbg) + r_timed_bg.target, g_timed_bg.target, b_timed_bg.target = color.utils.hex_to_rgba(newbg) + end ]] + local mouse_enter = function() _, r, g, b, _ = widget.bg:get_rgba() old_bg = RGB_to_hex(r, g, b) if bg_override or old_bg then - widget.bg = bg_override or old_bg .. "dd" + widget:set_bg(bg_override or old_bg .. "dd") end _, r, g, b, _ = widget.fg:get_rgba() old_fg = RGB_to_hex(r, g, b) if fg_override or old_fg then - widget.fg = fg_override or old_fg .. "dd" + widget:set_fg(fg_override or old_fg .. "dd") end old_border = widget.border_color if border_override or old_border then @@ -162,10 +180,10 @@ function Hover_signal(widget, bg_override, fg_override, border_override, icon_ov local mouse_leave = function() if old_bg then - widget.bg = old_bg + widget:set_bg(old_bg) end if old_fg then - widget.fg = old_fg + widget:set_fg(old_fg) end if old_border then widget.border_color = old_border diff --git a/awesome/src/lib/color b/awesome/src/lib/color new file mode 160000 index 0000000..064459a --- /dev/null +++ b/awesome/src/lib/color @@ -0,0 +1 @@ +Subproject commit 064459a663a717ab29e4c4efd54c9fc0a2e51d66 diff --git a/awesome/src/modules/titlebar.lua b/awesome/src/modules/titlebar.lua index 5d79b8c..3f9136d 100644 --- a/awesome/src/modules/titlebar.lua +++ b/awesome/src/modules/titlebar.lua @@ -8,6 +8,9 @@ local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") +local color = require("src.lib.color") +local rubato = require("src.lib.rubato") + -- Icon directory path local icondir = awful.util.getdir("config") .. "src/assets/icons/titlebar/" diff --git a/awesome/src/modules/window_switcher/window_elements.lua b/awesome/src/modules/window_switcher/window_elements.lua index 082bc15..8320d06 100644 --- a/awesome/src/modules/window_switcher/window_elements.lua +++ b/awesome/src/modules/window_switcher/window_elements.lua @@ -8,6 +8,9 @@ local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") +local color = require("src.lib.color") +local rubato = require("src.lib.rubato") + return function() local elements = wibox.widget { @@ -38,7 +41,7 @@ return function() selected = selected - for i, client in ipairs(clients_sorted) do + for _, client in ipairs(clients_sorted) do local window_element = wibox.widget { { { @@ -89,21 +92,11 @@ return function() end, border_color = Theme_config.window_switcher.border_color, border_width = Theme_config.window_switcher.border_width, - bg = Theme_config.window_switcher.element_bg, + bg = Theme_config.window_switcher.bg, fg = Theme_config.window_switcher.element_fg, widget = wibox.container.background } - if i == selected then - window_element.border_color = Theme_config.window_switcher.selected_border_color - window_element.fg = Theme_config.window_switcher.selected_fg - window_element.bg = Theme_config.window_switcher.selected_bg - else - window_element.border_color = Theme_config.window_switcher.border_color - window_element.fg = Theme_config.window_switcher.element_fg - window_element.bg = Theme_config.window_switcher.bg - end - elements:add(window_element) end @@ -115,14 +108,93 @@ return function() end for i, element in ipairs(elements.children) do + + -- Background rubato init + local r_timed_bg = rubato.timed { duration = 0.5 } + local g_timed_bg = rubato.timed { duration = 0.5 } + local b_timed_bg = rubato.timed { duration = 0.5 } + + -- starting color + r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos = color.utils.hex_to_rgba(Theme_config.window_switcher.bg) + + + -- Foreground rubato init + local r_timed_fg = rubato.timed { duration = 0.5 } + local g_timed_fg = rubato.timed { duration = 0.5 } + local b_timed_fg = rubato.timed { duration = 0.5 } + + -- starting color + r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos = color.utils.hex_to_rgba(Theme_config.window_switcher.element_fg) + + -- Border rubato init + local r_timed_border = rubato.timed { duration = 0.5 } + local g_timed_border = rubato.timed { duration = 0.5 } + local b_timed_border = rubato.timed { duration = 0.5 } + + -- starting color + r_timed_border.pos, g_timed_border.pos, b_timed_border.pos = color.utils.hex_to_rgba(Theme_config.window_switcher + .border_color) + + local function set_bg(newbg) + r_timed_bg.target, g_timed_bg.target, b_timed_bg.target = color.utils.hex_to_rgba(newbg) + end + + local function set_fg(newfg) + r_timed_fg.target, g_timed_fg.target, b_timed_fg.target = color.utils.hex_to_rgba(newfg) + end + + local function set_border(newborder) + r_timed_border.target, g_timed_border.target, b_timed_border.target = color.utils.hex_to_rgba(newborder) + end + + local function update_bg() + element:set_bg("#" .. color.utils.rgba_to_hex { r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos }) + end + + local function update_fg() + element:set_fg("#" .. color.utils.rgba_to_hex { r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos }) + end + + local function update_border() + element.border_color = "#" .. + color.utils.rgba_to_hex { r_timed_border.pos, g_timed_border.pos, b_timed_border.pos } + end + + -- Subscribe to the function bg and fg + r_timed_bg:subscribe(update_bg) + g_timed_bg:subscribe(update_bg) + b_timed_bg:subscribe(update_bg) + r_timed_fg:subscribe(update_fg) + g_timed_fg:subscribe(update_fg) + b_timed_fg:subscribe(update_fg) + r_timed_border:subscribe(update_border) + g_timed_border:subscribe(update_border) + b_timed_border:subscribe(update_border) + if i == selected then - element.border_color = Theme_config.window_switcher.selected_border_color - element.fg = Theme_config.window_switcher.selected_fg - element.bg = Theme_config.window_switcher.selected_bg + r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos = color.utils.hex_to_rgba(Theme_config.window_switcher.bg) + r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos = color.utils.hex_to_rgba(Theme_config.window_switcher.element_fg) + r_timed_border.pos, g_timed_border.pos, b_timed_border.pos = color.utils.hex_to_rgba(Theme_config.window_switcher + .border_color) + set_border(Theme_config.window_switcher.selected_border_color) + set_fg(Theme_config.window_switcher.selected_fg) + set_bg(Theme_config.window_switcher.selected_bg) + elseif i == selected - 1 or (selected == 1 and i == #clients_sorted) then + r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos = color.utils.hex_to_rgba(Theme_config.window_switcher.selected_bg) + r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos = color.utils.hex_to_rgba(Theme_config.window_switcher.selected_fg) + r_timed_border.pos, g_timed_border.pos, b_timed_border.pos = color.utils.hex_to_rgba(Theme_config.window_switcher + .selected_border_color) + set_border(Theme_config.window_switcher.border_color) + set_fg(Theme_config.window_switcher.element_fg) + set_bg(Theme_config.window_switcher.bg) else - element.border_color = Theme_config.window_switcher.border_color - element.fg = Theme_config.window_switcher.element_fg - element.bg = Theme_config.window_switcher.bg + r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos = color.utils.hex_to_rgba(Theme_config.window_switcher.bg) + r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos = color.utils.hex_to_rgba(Theme_config.window_switcher.element_fg) + r_timed_border.pos, g_timed_border.pos, b_timed_border.pos = color.utils.hex_to_rgba(Theme_config.window_switcher + .border_color) + set_border(Theme_config.window_switcher.border_color) + set_fg(Theme_config.window_switcher.element_fg) + set_bg(Theme_config.window_switcher.bg) end end elseif fn == "raise" then diff --git a/awesome/src/theme/theme_config.lua b/awesome/src/theme/theme_config.lua index ab44d66..bbe03f7 100644 --- a/awesome/src/theme/theme_config.lua +++ b/awesome/src/theme/theme_config.lua @@ -93,7 +93,7 @@ Theme_config.layout_list = { Theme_config.network = { bg = color["Red200"], fg = color["Grey900"], - notify_icon_color = color["White"] + notify_icon_color = color["Grey100"] } Theme_config.power_button = { @@ -112,23 +112,23 @@ Theme_config.systray = { Theme_config.taglist = { bg = "#3A475C", - fg = color["White"], + fg = color["Grey100"], bg_urgent = color["RedA200"], fg_urgent = color["Grey900"], - bg_focus = color["White"], + bg_focus = color["Grey100"], bg_focus_pressed = "#dddddd", - bg_focus_hover = color["White"], + bg_focus_hover = color["Grey100"], fg_focus = color["Grey900"], } Theme_config.tasklist = { bg = "#3A475C", - fg = color["White"], + fg = color["Grey100"], bg_urgent = color["RedA200"], fg_urgent = color["Grey900"], - bg_focus = color["White"], + bg_focus = color["Grey100"], bg_focus_pressed = "#dddddd", - bg_focus_hover = color["White"], + bg_focus_hover = color["Grey100"], fg_focus = color["Grey900"], } --#endregion @@ -338,7 +338,7 @@ Theme_config.dock = { element_bg = color["Grey900"], element_focused_bg = color["Grey800"], element_focused_hover_bg = color["Grey800"], - element_focused_hover_fg = color["White"], + element_focused_hover_fg = color["Grey100"], bg = color["Grey900"], indicator_bg = color["Grey600"], indicator_focused_bg = color["YellowA200"], @@ -541,7 +541,7 @@ Theme_config.tooltip = { Theme_config.hotkeys = { bg = color["Grey900"], - fg = color["White"], + fg = color["Grey100"], border_color = color["Grey800"], border_width = dpi(4), shape = function(cr, width, heigth) diff --git a/awesome/src/widgets/battery.lua b/awesome/src/widgets/battery.lua index d741d80..02dd3b1 100644 --- a/awesome/src/widgets/battery.lua +++ b/awesome/src/widgets/battery.lua @@ -1,4 +1,3 @@ ----@diagnostic disable: undefined-field -------------------------------- -- This is the battery widget -- -------------------------------- diff --git a/awesome/src/widgets/cpu_info.lua b/awesome/src/widgets/cpu_info.lua index c0f546f..18ba6d7 100644 --- a/awesome/src/widgets/cpu_info.lua +++ b/awesome/src/widgets/cpu_info.lua @@ -8,6 +8,9 @@ local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") +local color = require("src.lib.color") +local rubato = require("src.lib.rubato") + local icon_dir = awful.util.getdir("config") .. "src/assets/icons/cpu/" --TODO: Add tooltip with more CPU and per core information @@ -149,11 +152,32 @@ return function(widget, _) end ) + local r_timed_cpu_bg = rubato.timed { duration = 2.5 } + local g_timed_cpu_bg = rubato.timed { duration = 2.5 } + local b_timed_cpu_bg = rubato.timed { duration = 2.5 } + + r_timed_cpu_bg.pos, g_timed_cpu_bg.pos, b_timed_cpu_bg.pos = color.utils.hex_to_rgba(Theme_config.cpu_temp.bg_low) + + -- Subscribable function to have rubato set the bg/fg color + local function update_bg() + cpu_temp:set_bg("#" .. color.utils.rgba_to_hex { r_timed_cpu_bg.pos, g_timed_cpu_bg.pos, b_timed_cpu_bg.pos }) + end + + r_timed_cpu_bg:subscribe(update_bg) + g_timed_cpu_bg:subscribe(update_bg) + b_timed_cpu_bg:subscribe(update_bg) + + -- Both functions to set a color, if called they take a new color + local function set_bg(newbg) + r_timed_cpu_bg.target, g_timed_cpu_bg.target, b_timed_cpu_bg.target = color.utils.hex_to_rgba(newbg) + end + awesome.connect_signal( "update::cpu_temp", function(temp) local temp_icon local temp_color + if temp < 50 then temp_color = Theme_config.cpu_temp.bg_low temp_icon = icon_dir .. "thermometer-low.svg" @@ -165,7 +189,7 @@ return function(widget, _) temp_icon = icon_dir .. "thermometer-high.svg" end cpu_temp.container.cpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon) - cpu_temp:set_bg(temp_color) + set_bg(temp_color) cpu_temp.container.cpu_layout.label.text = math.floor(temp) .. "°C" awesome.emit_signal("update::cpu_temp_widget", temp, temp_icon) end diff --git a/awesome/src/widgets/gpu_info.lua b/awesome/src/widgets/gpu_info.lua index f0a2ba7..ecd0818 100644 --- a/awesome/src/widgets/gpu_info.lua +++ b/awesome/src/widgets/gpu_info.lua @@ -1,5 +1,5 @@ --------------------------------- --- This is the CPU Info widget -- +-- This is the gpu Info widget -- --------------------------------- -- Awesome Libs @@ -8,6 +8,9 @@ local dpi = require("beautiful").xresources.apply_dpi local gears = require("gears") local wibox = require("wibox") +local color = require("src.lib.color") +local rubato = require("src.lib.rubato") + local icon_dir = awful.util.getdir("config") .. "src/assets/icons/cpu/" return function(widget) @@ -64,7 +67,7 @@ return function(widget) widget = wibox.widget.imagebox, valign = "center", halign = "center", - image = gears.color.recolor_image(icon_dir .. "cpu.svg", Theme_config.gpu_temp.fg), + image = gears.color.recolor_image(icon_dir .. "gpu.svg", Theme_config.gpu_temp.fg), resize = false }, id = "icon_layout", @@ -108,6 +111,28 @@ return function(widget) end ) + local r_timed_gpu_bg = rubato.timed { duration = 2.5 } + local g_timed_gpu_bg = rubato.timed { duration = 2.5 } + local b_timed_gpu_bg = rubato.timed { duration = 2.5 } + + r_timed_gpu_bg.pos, g_timed_gpu_bg.pos, b_timed_gpu_bg.pos = color.utils.hex_to_rgba(Theme_config.cpu_temp.bg_low) + + -- Subscribable function to have rubato set the bg/fg color + local function update_bg() + gpu_temp_widget:set_bg("#" .. + color.utils.rgba_to_hex { math.max(0, r_timed_gpu_bg.pos), math.max(0, g_timed_gpu_bg.pos), + math.max(0, b_timed_gpu_bg.pos) }) + end + + r_timed_gpu_bg:subscribe(update_bg) + g_timed_gpu_bg:subscribe(update_bg) + b_timed_gpu_bg:subscribe(update_bg) + + -- Both functions to set a color, if called they take a new color + local function set_bg(newbg) + r_timed_gpu_bg.target, g_timed_gpu_bg.target, b_timed_gpu_bg.target = color.utils.hex_to_rgba(newbg) + end + -- GPU Temperature awesome.connect_signal( "update::gpu_temp", @@ -135,7 +160,7 @@ return function(widget) temp_icon = icon_dir .. "thermometer-low.svg" end gpu_temp_widget.container.gpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon) - gpu_temp_widget:set_bg(temp_color) + set_bg(temp_color) gpu_temp_widget.container.gpu_layout.label.text = tostring(temp_num) .. "°C" end ) diff --git a/awesome/src/widgets/taglist.lua b/awesome/src/widgets/taglist.lua index 3010c0c..e562aac 100644 --- a/awesome/src/widgets/taglist.lua +++ b/awesome/src/widgets/taglist.lua @@ -8,6 +8,9 @@ local awful = require("awful") local gears = require("gears") local dpi = require("beautiful").xresources.apply_dpi +local color = require("src.lib.color") +local rubato = require("src.lib.rubato") + local list_update = function(widget, buttons, _, _, objects) widget:reset() @@ -35,6 +38,7 @@ local list_update = function(widget, buttons, _, _, objects) layout = wibox.layout.fixed.horizontal }, fg = Theme_config.taglist.fg, + bg = Theme_config.taglist.bg, shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, dpi(6)) end, @@ -63,17 +67,67 @@ local list_update = function(widget, buttons, _, _, objects) tag_widget:buttons(create_buttons(buttons, object)) - tag_widget.container.margin.label:set_text(object.index) - if object.urgent == true then - 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(Theme_config.taglist.bg_focus) - tag_widget:set_fg(Theme_config.taglist.fg_focus) - else - tag_widget:set_bg(Theme_config.taglist.bg) + --#region Rubato and Color animation + + -- Background rubato init + local r_timed_bg = rubato.timed { duration = 0.5 } + local g_timed_bg = rubato.timed { duration = 0.5 } + local b_timed_bg = rubato.timed { duration = 0.5 } + + -- starting color + r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos = color.utils.hex_to_rgba(Theme_config.taglist.bg) + + + -- Foreground rubato init + local r_timed_fg = rubato.timed { duration = 0.5 } + local g_timed_fg = rubato.timed { duration = 0.5 } + local b_timed_fg = rubato.timed { duration = 0.5 } + + -- starting color + r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos = color.utils.hex_to_rgba(Theme_config.taglist.fg) + + -- Subscribable function to have rubato set the bg/fg color + local function update_bg() + tag_widget:set_bg("#" .. + color.utils.rgba_to_hex { math.max(0, r_timed_bg.pos), math.max(0, g_timed_bg.pos), math.max(0, b_timed_bg.pos) }) end + local function update_fg() + tag_widget:set_fg("#" .. + color.utils.rgba_to_hex { math.max(0, r_timed_fg.pos), math.max(0, g_timed_fg.pos), math.max(0, b_timed_fg.pos) }) + end + + -- Subscribe to the function bg and fg + r_timed_bg:subscribe(update_bg) + g_timed_bg:subscribe(update_bg) + b_timed_bg:subscribe(update_bg) + r_timed_fg:subscribe(update_fg) + g_timed_fg:subscribe(update_fg) + b_timed_fg:subscribe(update_fg) + + -- Both functions to set a color, if called they take a new color + local function set_bg(newbg) + r_timed_bg.target, g_timed_bg.target, b_timed_bg.target = color.utils.hex_to_rgba(newbg) + end + + local function set_fg(newfg) + r_timed_fg.target, g_timed_fg.target, b_timed_fg.target = color.utils.hex_to_rgba(newfg) + end + + tag_widget.container.margin.label:set_text(object.index) + -- Use the wraper function to call the set_bg and set_fg based on the client state + if object.urgent == true then + set_bg(Theme_config.taglist.bg_urgent) + set_fg(Theme_config.taglist.fg_urgent) + elseif object == awful.screen.focused().selected_tag then + set_bg(Theme_config.taglist.bg_focus) + set_fg(Theme_config.taglist.fg_focus) + else + set_fg(Theme_config.taglist.fg) + set_bg(Theme_config.taglist.bg) + end + --#endregion + -- Set the icon for each client for _, client in ipairs(object:clients()) do tag_widget.container.margin:set_right(0) diff --git a/awesome/src/widgets/tasklist.lua b/awesome/src/widgets/tasklist.lua index 217d340..140096b 100644 --- a/awesome/src/widgets/tasklist.lua +++ b/awesome/src/widgets/tasklist.lua @@ -8,6 +8,9 @@ local wibox = require('wibox') local dpi = require('beautiful').xresources.apply_dpi local gears = require('gears') +local color = require("src.lib.color") +local rubato = require("src.lib.rubato") + local list_update = function(widget, buttons, label, _, objects) widget:reset() for _, object in ipairs(objects) do @@ -90,6 +93,55 @@ local list_update = function(widget, buttons, label, _, objects) task_widget:buttons(create_buttons(buttons, object)) local text, _ = label(object, task_widget.container.layout_it.title) + + + --#region Rubato and Color animation + + -- Background rubato init + local r_timed_bg = rubato.timed { duration = 0.5 } + local g_timed_bg = rubato.timed { duration = 0.5 } + local b_timed_bg = rubato.timed { duration = 0.5 } + + -- starting color + r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos = color.utils.hex_to_rgba(Theme_config.tasklist.bg) + + + -- Foreground rubato init + local r_timed_fg = rubato.timed { duration = 0.5 } + local g_timed_fg = rubato.timed { duration = 0.5 } + local b_timed_fg = rubato.timed { duration = 0.5 } + + -- starting color + r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos = color.utils.hex_to_rgba(Theme_config.tasklist.fg) + + -- Subscribable function to have rubato set the bg/fg color + local function update_bg() + task_widget:set_bg("#" .. color.utils.rgba_to_hex { r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos }) + end + + local function update_fg() + task_widget:set_fg("#" .. color.utils.rgba_to_hex { r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos }) + end + + -- Subscribe to the function bg and fg + r_timed_bg:subscribe(update_bg) + g_timed_bg:subscribe(update_bg) + b_timed_bg:subscribe(update_bg) + r_timed_fg:subscribe(update_fg) + g_timed_fg:subscribe(update_fg) + b_timed_fg:subscribe(update_fg) + + -- Both functions to set a color, if called they take a new color + local function set_bg(newbg) + r_timed_bg.target, g_timed_bg.target, b_timed_bg.target = color.utils.hex_to_rgba(newbg) + end + + local function set_fg(newfg) + r_timed_fg.target, g_timed_fg.target, b_timed_fg.target = color.utils.hex_to_rgba(newfg) + end + + --#endregion + if object == client.focus then if text == nil or text == '' then task_widget.container.layout_it.title:set_margins(0) @@ -107,11 +159,11 @@ local list_update = function(widget, buttons, label, _, objects) task_tool_tip:remove_from_object(task_widget) end end - task_widget:set_bg(Theme_config.tasklist.bg_focus) - task_widget:set_fg(Theme_config.tasklist.fg_focus) + set_bg(Theme_config.tasklist.bg_focus) + set_fg(Theme_config.tasklist.fg_focus) task_widget.container.layout_it.title:set_text(text) else - task_widget:set_bg(Theme_config.tasklist.bg) + set_bg(Theme_config.tasklist.bg) task_widget.container.layout_it.title:set_text('') end