Fix some more bugs related to the new icon implementation

This commit is contained in:
Rene
2022-08-03 04:19:42 +02:00
parent 2422b9a07f
commit 535c763a30
40 changed files with 152 additions and 263 deletions

View File

@@ -13,7 +13,6 @@ local rubato = require("src.lib.rubato")
local icondir = awful.util.getdir("config") .. "src/assets/icons/notifications/"
-- TODO: Figure out how to use hover effects without messing up the actions
naughty.config.defaults.ontop = true
naughty.config.defaults.icon_size = dpi(80)
naughty.config.defaults.timeout = Theme_config.notification.timeout
@@ -25,9 +24,6 @@ naughty.config.defaults.border_width = Theme_config.notification.border_width
naughty.config.defaults.border_color = Theme_config.notification.border_color
naughty.config.defaults.spacing = Theme_config.notification.spacing
--naughty.config.defaults.screen = screen.primary.index
Theme.notification_spacing = Theme_config.notification.corner_spacing
naughty.connect_signal(
@@ -242,6 +238,7 @@ naughty.connect_signal(
},
id = "background1",
fg = Theme_config.notification.fg_close,
bg = Theme_config.notification.bg_close,
widget = wibox.container.background
},
strategy = "exact",
@@ -380,7 +377,7 @@ naughty.connect_signal(
)
end
Hover_signal(close, nil, Theme_config.notification.fg_close)
Hover_signal(close)
close:connect_signal(
"button::press",

View File

@@ -83,32 +83,29 @@ client.connect_signal(
--- Takes a wibox.container.background and connects four signals to it
---@param widget wibox.container.background
---@param bg string | nil
---@param fg string | nil
---@param border_color string | nil
function Hover_signal(widget, bg, fg, border_color)
function Hover_signal(widget, bg_override)
local old_wibox, old_cursor, old_bg, old_fg, old_border
local r, g, b
bg = bg or nil
fg = fg or nil
border_color = border_color or nil
widget.bg = widget.bg or ""
widget.fg = widget.fg or ""
widget.border_color = widget.border_color or ""
local mouse_enter = function()
if bg ~= nil then
_, r, g, b, _ = widget.bg:get_rgba()
old_bg = RGB_to_hex(r, g, b)
widget.bg = bg .. "dd"
if bg_override or old_bg then
widget.bg = bg_override or old_bg .. "dd"
end
if fg then
_, r, g, b, _ = widget.fg:get_rgba()
old_fg = RGB_to_hex(r, g, b)
widget.fg = fg .. "dd"
if old_fg then
widget.fg = old_fg .. "dd"
end
if border_color then
old_border = widget.border_color
widget.border_color = border_color .. "dd"
if old_border then
widget.border_color = old_border .. "dd"
end
local w = mouse.current_wibox
if w then
@@ -118,31 +115,31 @@ function Hover_signal(widget, bg, fg, border_color)
end
local button_press = function()
if bg then
widget.bg = bg
if old_bg or bg_override then
widget.bg = bg_override or old_bg .. "bb"
end
if fg then
widget.fg = fg
if old_fg then
widget.fg = old_fg .. "bb"
end
end
local button_release = function()
if bg then
widget.bg = bg
if old_bg or bg_override then
widget.bg = bg_override or old_bg .. "dd"
end
if fg then
widget.fg = fg
if old_fg then
widget.fg = old_fg .. "dd"
end
end
local mouse_leave = function()
if bg then
if old_bg then
widget.bg = old_bg
end
if fg then
if old_fg then
widget.fg = old_fg
end
if border_color then
if old_border then
widget.border_color = old_border
end
if old_wibox then
@@ -151,13 +148,8 @@ function Hover_signal(widget, bg, fg, border_color)
end
end
--[[ widget:disconnect_signal("mouse::enter", mouse_enter)
widget:disconnect_signal("button::press", button_press)
widget:disconnect_signal("button::release", button_release)
widget:disconnect_signal("mouse::leave", mouse_leave) ]]
widget:connect_signal("mouse::enter", mouse_enter)
widget:connect_signal("button::press", button_press)
widget:connect_signal("button::release", button_release)
widget:connect_signal("mouse::leave", mouse_leave)
end

Binary file not shown.

View File

@@ -88,6 +88,7 @@ return function()
border_color = Theme_config.application_launcher.application.border_color,
border_width = Theme_config.application_launcher.application.border_width,
bg = Theme_config.application_launcher.application.bg,
fg = Theme_config.application_launcher.application.fg,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(8))
end,
@@ -108,6 +109,7 @@ return function()
)
)
)
Hover_signal(app_widget)
table.insert(list, app_widget)
end
end
@@ -151,8 +153,6 @@ return function()
end
)
awesome.emit_signal("update::selected")
Hover_signal(application, Theme_config.application_launcher.application.bg,
Theme_config.application_launcher.application.fg, application.border_color)
end
end
@@ -221,10 +221,13 @@ return function()
local selected_widget = application_grid:get_widgets_at(curser.y, curser.x)[1]
if selected_widget.terminal then
awful.spawn(User_config.terminal .. " -e " .. selected_widget.exec)
awful.spawn(User_config.terminal ..
" -e " ..
selected_widget.exec:gsub("%%F", ""):gsub("%%u", ""):gsub("%%U", ""):gsub("%%f", ""):gsub("%%i", ""):gsub("%%c"
, ""):gsub("%%k", ""))
else
print(selected_widget.exec)
awful.spawn.with_shell(selected_widget.exec)
awful.spawn.with_shell(selected_widget.exec:gsub("%%F", ""):gsub("%%u", ""):gsub("%%U", ""):gsub("%%f", ""):gsub("%%i"
, ""):gsub("%%c", ""):gsub("%%k", ""))
end
end
)

View File

@@ -227,7 +227,6 @@ return function()
searchbar:buttons(gears.table.join(
awful.button({}, 1, function()
if not awful.keygrabber.is_running then
keygrabber_start()
searchbar.s_background.border_color = Theme_config.application_launcher.searchbar.border_active
searchbar.s_background.fg = Theme_config.application_launcher.searchbar.fg
search_text:set_markup(promt_text_with_cursor("", 1))

View File

@@ -145,8 +145,7 @@ return function(s)
end
)
end
Hover_signal(device_widget, Theme_config.bluetooth_controller.device_bg_hover,
Theme_config.bluetooth_controller.device_fg_hover)
Hover_signal(device_widget)
return device_widget
end

View File

@@ -54,6 +54,7 @@ return function(screen, programs)
gears.shape.rounded_rect(cr, width, height, dpi(10))
end,
bg = Theme_config.dock.element_bg,
fg = "#000000",
widget = wibox.container.background,
id = "background"
},
@@ -69,7 +70,7 @@ return function(screen, programs)
end
end
Hover_signal(dock_element.background, Theme_config.dock.element_focused_hover_bg)
Hover_signal(dock_element.background, Theme_config.dock.element_focused_bg .. "dd")
dock_element:connect_signal(
"button::press",

View File

@@ -368,8 +368,7 @@ return function(s)
end
)
Hover_signal(clear_all_widget.margin3.background4, Theme_config.notification_center.clear_all_button.bg,
Theme_config.notification_center.clear_all_button.fg)
Hover_signal(clear_all_widget.margin3.background4)
--#endregion
end

View File

@@ -82,6 +82,7 @@ function nl.create_notification(n)
},
id = "background",
fg = Theme_config.notification_center.notification_list.close_color,
bg = Theme_config.notification_center.notification_list.close_bg,
widget = wibox.container.background
},
strategy = "exact",
@@ -233,8 +234,7 @@ function nl.create_notification(n)
end
)
Hover_signal(close_widget.const.background, nil,
Theme_config.notification_center.notification_list.close_color)
Hover_signal(close_widget.const.background)
notification:connect_signal(
"mouse::enter",

View File

@@ -394,8 +394,6 @@ return function(s)
function(stdout)
-- Only fetch info if the track changed or if the title/artist is empty
if skip_check or (not stdout:match(trackid)) or (not stdout:match(artist)) or (not stdout:match(title)) then
update_loop()
update_shuffle()
-- Get the song title
awful.spawn.easy_async_with_shell(
"playerctl metadata xesam:title",

View File

@@ -149,11 +149,11 @@ return function(s)
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, 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)
Hover_signal(shutdown_button.background)
Hover_signal(reboot_button.background)
Hover_signal(suspend_button.background)
Hover_signal(logout_button.background)
Hover_signal(lock_button.background)
-- The powermenu widget
local powermenu = wibox.widget {

View File

@@ -132,9 +132,9 @@ local create_titlebar = function(c, size)
layout = wibox.layout.align.vertical,
id = "main"
}
Hover_signal(titlebar.main.margin.spacing.closebutton, Theme_config.titlebar.close_button_bg)
Hover_signal(titlebar.main.margin.spacing.maximizebutton, Theme_config.titlebar.minimize_button_bg)
Hover_signal(titlebar.main.margin.spacing.minimizebutton, Theme_config.titlebar.maximize_button_bg)
Hover_signal(titlebar.main.margin.spacing.closebutton)
Hover_signal(titlebar.main.margin.spacing.maximizebutton)
Hover_signal(titlebar.main.margin.spacing.minimizebutton)
end
local create_titlebar_dialog_modal = function(c, size)
@@ -187,8 +187,8 @@ local create_titlebar_dialog_modal = function(c, size)
layout = wibox.layout.align.vertical,
id = "main"
}
Hover_signal(titlebar.main.margin.spacing.closebutton, Theme_config.titlebar.close_button_bg)
Hover_signal(titlebar.main.margin.spacing.minimizebutton, Theme_config.titlebar.minimize_button_bg)
Hover_signal(titlebar.main.margin.spacing.closebutton)
Hover_signal(titlebar.main.margin.spacing.minimizebutton)
end
client.connect_signal(

View File

@@ -51,12 +51,14 @@ return function(s)
if sink == true then
device:connect_signal(
"button::press",
function()
function(_, _, _, key)
if key == 1 then
if node then
awful.spawn("./.config/awesome/src/scripts/vol.sh set_sink " .. node)
end
awesome.emit_signal("update::bg_sink", node)
end
end
end
)
awesome.connect_signal(
"update::bg_sink",
@@ -92,15 +94,18 @@ return function(s)
end
)
awesome.emit_signal("update::bg_sink", node)
Hover_signal(device)
else
device:connect_signal(
"button::press",
function()
function(_, _, _, key)
if key == 1 then
if node then
awful.spawn("./.config/awesome/src/scripts/mic.sh set_source " .. node)
end
awesome.emit_signal("update::bg_source", node)
end
end
end
)
awesome.connect_signal(
"update::bg_source",
@@ -136,6 +141,7 @@ return function(s)
end
)
awesome.emit_signal("update::bg_source", node)
Hover_signal(device)
end
return device
end
@@ -320,7 +326,7 @@ return function(s)
gears.shape.rounded_rect(cr, width, height, dpi(5))
end,
bar_height = dpi(5),
bar_color = Theme_config.device_border_color,
bar_color = Theme_config.volume_controller.border_color,
bar_active_color = Theme_config.volume_controller.volume_fg,
handle_color = Theme_config.volume_controller.volume_fg,
handle_shape = gears.shape.circle,
@@ -409,7 +415,8 @@ return function(s)
-- Click event for the audio dropdown
audio_selector_margin:connect_signal(
"button::press",
function()
function(_, _, _, key)
if key == 1 then
local rubato_timer = rubato.timed {
duration = 0.4,
intro = 0.1,
@@ -436,6 +443,7 @@ return function(s)
Theme_config.volume_controller.device_headphones_selected_icon_color))
end
end
end
)
-- Variables for easier access and better readability
@@ -447,7 +455,8 @@ return function(s)
-- Click event for the microphone dropdown
mic_selector_margin:connect_signal(
"button::press",
function()
function(_, _, _, key)
if key == 1 then
local rubato_timer = rubato.timed {
duration = 0.4,
intro = 0.1,
@@ -474,6 +483,7 @@ return function(s)
Theme_config.volume_controller.device_microphone_selected_icon_color))
end
end
end
)
local audio_slider_margin = volume_controller:get_children_by_id("audio_volume_margin")[1].audio_volume.slider_margin.slider
@@ -482,7 +492,7 @@ return function(s)
audio_slider_margin:connect_signal(
"property::value",
function()
awful.spawn("pactl set-sink-volume @DEFAULT_SINK@ " .. tonumber(audio_slider_margin.value) .. "%")
awful.spawn.with_shell("pactl set-sink-volume @DEFAULT_SINK@ " .. tonumber(audio_slider_margin.value) .. "%")
end
)

View File

@@ -10,11 +10,12 @@ local awful = require("awful")
local beautiful = require("beautiful")
local gears = require("gears")
require("src.theme.user_config")
require("src.theme.theme_config")
Theme_path = awful.util.getdir("config") .. "/src/theme/"
Theme = {}
--dofile(Theme_path .. "theme_config.lua")
-- Default font, change it in user_config, not here.
Theme.font = User_config.font.bold

View File

@@ -446,6 +446,7 @@ Theme_config.application_launcher = {
border_color_active = color["Purple200"],
border_width = dpi(2),
bg = "#313131",
fg = color["Grey100"],
hover_bg = color["Grey700"],
},
searchbar = {

View File

@@ -20,7 +20,7 @@ User_config = {
"picom --experimental-backends",
"xfce4-power-manager",
"light-locker --lock-on-suspend --lock-on-lid &",
"flatpak run com.spotify.Client",
"spotify",
"discord",
"/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1",
"setxkbmap -option caps:swapescape",
@@ -66,9 +66,9 @@ User_config = {
--[[
Dock program size in dpi.
Example:
dock_size = dpi(50)
dock_size = dpi(48)
]] --
dock_icon_size = dpi(50),
dock_icon_size = dpi(64),
--[[
Add your programs to the dock. You need to provide the name of the .desktop file
@@ -84,7 +84,7 @@ User_config = {
"com.brave.Browser.desktop",
"steam.desktop",
"discord.desktop",
"com.spotify.Client.desktop",
"spotify.desktop",
"code.desktop",
"arduino-arduinoide.desktop",
"us.zoom.Zoom.desktop",

View File

@@ -32,8 +32,8 @@ end
---@param name string
---@return string | nil icon_path
function Get_icon(class, name)
class = string.lower(class) or ""
name = string.lower(name) or ""
class = string.lower(class or "")
name = string.lower(name or "")
for _, app in ipairs(app_list) do
local desktop_app_info = Gio.DesktopAppInfo.new(app_info.get_id(app))
local icon_string = Gio.DesktopAppInfo.get_string(desktop_app_info, "Icon")

View File

@@ -90,7 +90,7 @@ return function(s)
)
-- Signals
Hover_signal(audio_widget, Theme_config.audio.bg, Theme_config.audio.fg)
Hover_signal(audio_widget)
audio_widget:connect_signal(
"button::press",

View File

@@ -67,7 +67,7 @@ return function(battery_kind)
}
-- Color change on mouse over
Hover_signal(battery_widget, Theme_config.battery.bg, Theme_config.battery.fg)
Hover_signal(battery_widget)
-- Open an energy manager on click
battery_widget:connect_signal(
@@ -90,7 +90,7 @@ return function(battery_kind)
---Takes a path and returns the glib object
---@param path string battery device path
---@return UPowerGlib.Device battery battery device object
---@return UPowerGlib.Device | nil battery battery device object
local function get_device_from_path(path)
local devices = upower_glib.Client():get_devices()

View File

@@ -40,7 +40,7 @@ return function(s)
widget = wibox.container.background
}
-- Hover signal to change color when mouse is over
Hover_signal(bluetooth_widget, Theme_config.bluetooth.bg, Theme_config.bluetooth.fg)
Hover_signal(bluetooth_widget)
awesome.connect_signal("state", function(state)
if state then

View File

@@ -58,7 +58,7 @@ return function()
widget = wibox.container.background
}
Hover_signal(clock_widget, Theme_config.clock.bg, Theme_config.clock.fg)
Hover_signal(clock_widget)
return clock_widget
end

View File

@@ -164,7 +164,6 @@ return function(widget, _)
temp_color = Theme_config.cpu_temp.bg_high
temp_icon = icon_dir .. "thermometer-high.svg"
end
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) .. "°C"
@@ -186,8 +185,9 @@ return function(widget, _)
end
)
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)
Hover_signal(cpu_temp)
Hover_signal(cpu_usage_widget)
Hover_signal(cpu_clock)
if widget == "usage" then
return cpu_usage_widget

View File

@@ -60,7 +60,7 @@ return function()
}
-- Signals
Hover_signal(date_widget, Theme_config.date.bg, Theme_config.date.fg)
Hover_signal(date_widget)
return date_widget
end

View File

@@ -53,7 +53,6 @@ return function(widget)
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 {
{
@@ -98,6 +97,9 @@ return function(widget)
widget = wibox.container.background
}
Hover_signal(gpu_temp_widget)
Hover_signal(gpu_usage_widget)
-- GPU Utilization
awesome.connect_signal(
"update::gpu_usage",
@@ -113,7 +115,7 @@ return function(widget)
local temp_icon
local temp_color
local temp_num = tonumber(stdout)
local temp_num = tonumber(stdout) or "N/A"
if temp_num then
@@ -128,7 +130,7 @@ return function(widget)
temp_icon = icon_dir .. "thermometer-high.svg"
end
else
temp_num = "NaN"
temp_num = "N/A"
temp_color = Theme_config.gpu_temp.bg_low
temp_icon = icon_dir .. "thermometer-low.svg"
end

View File

@@ -214,7 +214,6 @@ return function(s)
keymap = keymap
}
-- TODO: Hover effects, this is more pain than I'm willing to take for now
awesome.connect_signal(
"update::background:kblayout",
function()
@@ -235,7 +234,6 @@ return function(s)
)
end
)
get_kblayout()
kb_layout_item:connect_signal(
@@ -352,7 +350,7 @@ return function(s)
)
-- Signals
Hover_signal(kblayout_widget, Theme_config.kblayout.bg, Theme_config.kblayout.fg)
Hover_signal(kblayout_widget)
local kblayout_keygrabber = awful.keygrabber {
autostart = false,

View File

@@ -47,7 +47,7 @@ return function()
}
-- Signals
Hover_signal(layout, Theme_config.layout_list.bg)
Hover_signal(layout)
layout:connect_signal(
"button::press",

View File

@@ -328,7 +328,7 @@ return function()
}
-- Signals
Hover_signal(network_widget, Theme_config.network.bg, Theme_config.network.fg)
Hover_signal(network_widget)
network_widget:connect_signal(
"button::press",

View File

@@ -50,7 +50,7 @@ return function()
}
-- Signals
Hover_signal(power_widget, Theme_config.power_button.bg, Theme_config.power_button.fg)
Hover_signal(power_widget)
power_widget:connect_signal(
"button::release",

View File

@@ -55,7 +55,7 @@ return function()
widget = wibox.container.background
}
Hover_signal(ram_widget, Theme_config.ram_info.bg, Theme_config.ram_info.fg)
Hover_signal(ram_widget)
awesome.connect_signal(
"update::ram_widget",

View File

@@ -28,8 +28,6 @@ return function(s)
end,
bg = Theme_config.systray.bg
}
-- Signals
Hover_signal(systray, Theme_config.systray.bg)
awesome.connect_signal("systray::update", function()
local num_entries = awesome.systray()

View File

@@ -102,61 +102,7 @@ local list_update = function(widget, buttons, _, _, objects)
})
end
--#region Hover_signal
local old_wibox, old_cursor
tag_widget:connect_signal(
"mouse::enter",
function()
if object == awful.screen.focused().selected_tag then
tag_widget.bg = Theme_config.taglist.bg_focus_hover .. 'dd'
else
tag_widget.bg = Theme_config.taglist.bg .. 'dd'
end
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
tag_widget:connect_signal(
"button::press",
function()
if object == awful.screen.focused().selected_tag then
tag_widget.bg = Theme_config.taglist.bg_focus_pressed .. 'dd'
else
tag_widget.bg = Theme_config.taglist.bg .. 'dd'
end
end
)
tag_widget:connect_signal(
"button::release",
function()
if object == awful.screen.focused().selected_tag then
tag_widget.bg = Theme_config.taglist.bg_focus_hover .. 'dd'
else
tag_widget.bg = Theme_config.taglist.bg .. 'dd'
end
end
)
tag_widget:connect_signal(
"mouse::leave",
function()
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
end
end
)
--#endregion
Hover_signal(tag_widget)
widget:add(tag_widget)
widget:set_spacing(dpi(6))

View File

@@ -115,65 +115,10 @@ local list_update = function(widget, buttons, label, _, objects)
task_widget.container.layout_it.title:set_text('')
end
Hover_signal(task_widget)
widget:add(task_widget)
widget:set_spacing(dpi(6))
--#region Hover_signal
local old_wibox, old_cursor
task_widget:connect_signal(
"mouse::enter",
function()
if object == client.focus then
task_widget.bg = Theme_config.tasklist.bg_focus_hover .. "dd"
else
task_widget.bg = Theme_config.tasklist.bg .. 'dd'
end
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
task_widget:connect_signal(
"button::press",
function()
if object == client.focus then
task_widget.bg = Theme_config.tasklist.bg_focus_pressed .. "dd"
else
task_widget.bg = Theme_config.tasklist.bg .. "dd"
end
end
)
task_widget:connect_signal(
"button::release",
function()
if object == client.focus then
task_widget.bg = Theme_config.tasklist.bg_focus_hover .. "dd"
else
task_widget.bg = Theme_config.tasklist.bg .. "dd"
end
end
)
task_widget:connect_signal(
"mouse::leave",
function()
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
end
end
)
--#endregion
end
return widget
end