fixed bluetooth and taskbar, tasklist icons

This commit is contained in:
Kievits Rene
2022-04-18 03:05:43 +02:00
parent 1ceec3a7d9
commit f8c31d19f2
17 changed files with 182 additions and 271 deletions

View File

@@ -1,93 +0,0 @@
-------------------------------------------------------------
-- This is a button widget to add a new tag to the taglist --
-------------------------------------------------------------
-- !!! THIS WIDGET IS OBSCOLETE !!!
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
-- User Libs
local color = require("theme.crylia.colors")
-- Icon directory path
local icondir = awful.util.getdir("config") .. "theme/crylia/assets/icons/addtag/"
-- Returns the add tag button widget
return function()
-- This is the widget that gets dispayed
local add_tag_button = wibox.widget {
{
{
image = gears.color.recolor_image(icondir .. "plus.svg", color.color["White"]),
widget = wibox.widget.imagebox,
resize = false
},
margins = dpi(4),
widget = wibox.container.margin
},
bg = color.color["Grey900"],
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end,
widget = wibox.container.background
}
-- Keybindings and Mouse click bindings
add_tag_button:buttons(
gears.table.join(
-- Add a new tag
awful.button(
{},
1,
nil,
function()
awful.tag.add()
end
)
)
)
-- Signals
local old_wibox, old_cursor, old_bg
add_tag_button:connect_signal(
"mouse::enter",
function()
old_bg = add_tag_button.bg
add_tag_button.bg = "#ffffff" .. "12"
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
add_tag_button:connect_signal(
"button::press",
function()
add_tag_button.bg = "#ffffff" .. "24"
end
)
add_tag_button:connect_signal(
"button::release",
function()
add_tag_button.bg = "#ffffff" .. "12"
end
)
add_tag_button:connect_signal(
"mouse::leave",
function()
add_tag_button.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
)
return add_tag_button
end

View File

@@ -7,6 +7,7 @@ local awful = require("awful")
local color = require("theme.crylia.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local naughty = require("naughty")
local wibox = require("wibox")
require("main.signals")
@@ -51,54 +52,34 @@ return function()
local bluetooth_state = "off"
local connected_device = "nothing"
-- ! if you don't have a bluetooth device then this function will
-- ! spawn hundereds of processes of bluetoothctl, this will be bad
-- TODO: Check for a bluetooth controller first, maybe use a different program
local get_bluetooth_information = function()
-- awful.spawn.easy_async_with_shell(
-- [[ bluetoothctl show | grep Powered | awk '{print $2}' ]],
-- function(stdout)
-- local icon = icondir .. "bluetooth"
-- stdout = stdout:gsub("\n", "")
-- if stdout == "yes" then
-- icon = icon .. "-on"
-- bluetooth_state = "on"
-- awful.spawn.easy_async_with_shell(
-- [[ bluetoothctl info | grep Name: | awk '{ first = $1; $1 = ""; print $0 }' ]],
-- function(stdout2)
-- if stdout2 == nil or stdout2:gsub("\n", "") == "" then
-- bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently not connected")
-- else
-- bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently connected to:" .. connected_device)
-- connected_device = stdout2
-- end
-- end
-- )
-- else
-- icon = icon .. "-off"
-- bluetooth_state = "off"
-- bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n")
-- end
-- bluetooth_widget.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icon .. ".svg", color.color["Grey900"]))
-- end
-- )
end
local bluetooth_update = gears.timer {
timeout = 5,
autostart = true,
call_now = true,
callback = function()
--[[ awful.spawn.easy_async_with_shell(
"bluetoothctl list",
function(stdout)
if stdout ~= nil or stdout:gsub("\n", ""):match("") then
get_bluetooth_information()
awful.widget.watch(
"rfkill list bluetooth",
5,
function(stdout)
local icon = icondir .. "bluetooth"
if stdout:match('Soft blocked: yes') or stdout:gsub("\n", "") == '' then
icon = icon .. "-off"
bluetooth_state = "off"
bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n")
else
icon = icon .. "-on"
bluetooth_state = "on"
awful.spawn.easy_async_with_shell(
[[ bluetoothctl info | grep Name: | awk '{ first = $1; $1 = ""; print $0 }' ]],
function(stdout2)
if stdout2 == nil or stdout2:gsub("\n", "") == "" then
bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently not connected")
else
bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently connected to:" .. connected_device)
connected_device = stdout2
end
end
end
) ]]
end
}
)
end
bluetooth_widget.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icon .. ".svg", color.color["Grey900"]))
end,
bluetooth_widget
)
-- Signals
Hover_signal(bluetooth_widget, color.color["Blue200"])
@@ -106,24 +87,45 @@ return function()
bluetooth_widget:connect_signal(
"button::press",
function()
if bluetooth_state == "on" then
awful.spawn.easy_async_with_shell(
"bluetoothctl power off",
function(stdout)
get_bluetooth_information()
awful.spawn.easy_async_with_shell(
"rfkill list bluetooth",
function(stdout)
if stdout:gsub("\n", "") == '' then
if bluetooth_state == "on" then
awful.spawn.easy_async_with_shell(
[[
rfkill unblock bluetooth
sleep 1
bluetoothctl power on
]],
function()
naughty.notify({
Title = "System Notification",
app_name = "Bluetooth",
message = "Bluetooth activated"
})
end
)
else
awful.spawn.easy_async_with_shell(
[[
bluetoothctl power off
rfkill block bluetooth
]],
function()
naughty.notify({
Title = "System Notification",
app_name = "Bluetooth",
message = "Bluetooth deactivated"
})
end
)
end
end
)
else
awful.spawn.easy_async_with_shell(
"bluetoothctl power on",
function(stdout)
get_bluetooth_information()
end
)
end
end
)
end
)
get_bluetooth_information()
return bluetooth_widget
end

View File

@@ -84,7 +84,6 @@ local list_update = function(widget, buttons, label, data, objects)
tag_widget:buttons(create_buttons(buttons, object))
local text, bg_color, bg_image, icon, args = label(object, tag_label)
local naughty = require("naughty")
tag_label:set_text(object.index)
if object.urgent == true then
tag_widget:set_bg(color.color["RedA200"])

View File

@@ -64,10 +64,6 @@ local list_update = function(widget, buttons, label, data, objects)
if buttons then
local btns = {}
for _, b in ipairs(buttons) do
-- Create a proxy button object: it will receive the real
-- press and release events, and will propagate them to the
-- button object the user provided, but with the object as
-- argument.
local btn = awful.button {
modifiers = b.modifiers,
button = b.button,
@@ -93,7 +89,11 @@ local list_update = function(widget, buttons, label, data, objects)
else
local text_full = text:match('>(.-)<')
if text_full then
text = object.class:sub(1, 20)
if object.class == nil then
text = object.name
else
text = object.class:sub(1, 20)
end
task_tool_tip:set_text(text_full)
task_tool_tip:add_to_object(task_widget)
else
@@ -110,6 +110,7 @@ local list_update = function(widget, buttons, label, data, objects)
task_widget.container.layout_it.margin.layout_icon.icon:set_image(Get_icon("Papirus-Dark", object))
widget:add(task_widget)
widget:set_spacing(dpi(6))
local old_wibox, old_cursor, old_bg
task_widget:connect_signal(
"mouse::enter",