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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 MiB

View File

@@ -1 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" /></svg>

Before

Width:  |  Height:  |  Size: 336 B

View File

@@ -13,9 +13,9 @@ local wibox = require("wibox")
local icondir = awful.util.getdir("config") .. "theme/crylia/assets/icons/brightness/"
-- TODO: fix backlight keys and osd not working correctly
return function (s)
return function(s)
local brightness_osd_widget = wibox.widget{
local brightness_osd_widget = wibox.widget {
{
{
{
@@ -101,7 +101,7 @@ return function (s)
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:connect_signal(
"property::value",
function ()
function()
local brightness_value = brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:get_value()
-- Performance is horrible, or it overrides and executes at the same time as the keybindings
--awful.spawn("xbacklight -set " .. brightness_value, false)
@@ -131,11 +131,11 @@ return function (s)
end
)
local update_slider = function ()
local update_slider = function()
awful.spawn.easy_async_with_shell(
[[ sleep 0.1 && xbacklight -get ]],
function (stdout)
stdout = stdout:sub(1,-9)
function(stdout)
stdout = stdout:sub(1, -9)
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(tonumber(stdout))
end
)
@@ -143,48 +143,49 @@ return function (s)
awesome.connect_signal(
"module::brightness_slider:update",
function ()
function()
update_slider()
end
)
awesome.connect_signal(
"widget::brightness:update",
function (value)
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{
local brightness_container = awful.popup {
widget = wibox.container.background,
ontop = true,
bg = color.color["Grey900"] .. "00",
stretch = false,
visible = false,
placement = function (c) awful.placement.centered(c, {margins = {top = dpi(200)}}) end,
shape = function (cr, width, height)
screen = s,
placement = function(c) awful.placement.centered(c, { margins = { top = dpi(200) } }) end,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 15)
end
}
local hide_brightness_osd = gears.timer{
local hide_brightness_osd = gears.timer {
timeout = 2,
autostart = true,
callback = function ()
callback = function()
brightness_container.visible = false
end
}
brightness_container:setup{
brightness_container:setup {
brightness_osd_widget,
layout = wibox.layout.fixed.horizontal
}
awesome.connect_signal(
"widget::brightness_osd:rerun",
function ()
function()
if hide_brightness_osd.started then
hide_brightness_osd:again()
else
@@ -195,14 +196,16 @@ return function (s)
awesome.connect_signal(
"module::brightness_osd:show",
function ()
brightness_container.visible = true
function()
if s == mouse.screen then
brightness_container.visible = true
end
end
)
brightness_container:connect_signal(
"mouse::enter",
function ()
function()
brightness_container.visible = true
hide_brightness_osd:stop()
end
@@ -210,9 +213,9 @@ return function (s)
brightness_container:connect_signal(
"mouse::leave",
function ()
function()
brightness_container.visible = true
hide_brightness_osd:again()
end
)
end
end

View File

@@ -195,7 +195,7 @@ local create_titlebar_borderhack = function(c, bg, position)
local borderhack = awful.titlebar(c, {
position = position,
bg = bg,
size = "2"
size = "4"
})
borderhack:setup {
{

View File

@@ -184,6 +184,7 @@ echo $(pacmd list-sinks | awk '/^\s+name: /{indefault = $2 == "<'$SINK'>"} /^\s+
bg = color.color["Grey900"] .. "00",
stretch = false,
visible = false,
screen = s,
placement = function(c) awful.placement.centered(c, { margins = { top = dpi(200) } }) end,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 15)
@@ -206,7 +207,9 @@ echo $(pacmd list-sinks | awk '/^\s+name: /{indefault = $2 == "<'$SINK'>"} /^\s+
awesome.connect_signal(
"module::volume_osd:show",
function()
volume_container.visible = true
if s == mouse.screen then
volume_container.visible = true
end
end
)

View File

@@ -1,7 +1,7 @@
local awful = require("awful")
-- Autostart programs
--awful.spawn.with_shell("~/.screenlayout/single_screen.sh")
awful.spawn.with_shell("picom --experimental-backends")
awful.spawn.with_shell("xfce4-power-manager")
awful.spawn.with_shell("light-locker --lock-on-suspend --lock-on-lid &")
function Autostarter(table)
for i, t in ipairs(table) do
awful.spawn.with_shell(t);
end
end

View File

@@ -1,53 +1,56 @@
-----------------------------------------------------
-- Helper to get icons from a program/program name --
-----------------------------------------------------
local naughty = require("naughty")
-- 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, c, is_steam)
if theme and c then
local clientName
if theme ~= nil and c ~= nil then
local clientName = c.name
-- TODO: Access steamdb api to fetch the clienticon if there is no icon found in this theme
if is_steam then
clientName = "steam_icon_" .. tostring(c) .. ".svg"
else
if type(c) == type("") then
clientName = string.lower(c) .. ".svg"
else
if c.class ~= nil then
clientName = string.lower(c.class) .. ".svg"
elseif clientName ~= nil then
clientName = string.lower(c.name) .. ".svg"
else
return
end
end
local resolutions = {"128x128", "96x96", "64x64", "48x48", "42x42", "32x32", "24x24", "16x16"}
local resolutions = { "128x128", "96x96", "64x64", "48x48", "42x42", "32x32", "24x24", "16x16" }
for i, res in ipairs(resolutions) do
local iconDir = "/usr/share/icons/" .. theme .. "/" .. res .."/apps/"
local iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/"
local ioStream = io.open(iconDir .. clientName, "r")
if ioStream ~= nil then
return iconDir .. clientName
else
clientName = clientName:gsub("^%l", string.upper)
iconDir = "/usr/share/icons/" .. theme .. "/" .. res .."/apps/"
iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/"
ioStream = io.open(iconDir .. clientName, "r")
if ioStream ~= nil then
if ioStream ~= nil then
return iconDir .. clientName
elseif type(c) ~= type("") then
local naughty = require("naughty")
if pcall(
function ()
function()
if c:Get_icon(1) then
error("icon error")
error("icon error")
else
return c:Get_icon(1)
end
end
end
) then
return nil
end
return "/usr/share/icons/Papirus-Dark/128x128/apps/Zoom.svg"
end
end
end
end
return nil
if c.icon == nil then
return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg"
else
return c.icon
end
end

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",