Add new window switcher on super+tab and smaller fixes
This commit is contained in:
@@ -6,6 +6,34 @@ local ruled = require("ruled")
|
|||||||
|
|
||||||
local modkey = User_config.modkey
|
local modkey = User_config.modkey
|
||||||
|
|
||||||
|
awful.keygrabber {
|
||||||
|
keybindings = {
|
||||||
|
awful.key {
|
||||||
|
modifiers = { modkey },
|
||||||
|
key = "Tab",
|
||||||
|
on_press = function()
|
||||||
|
awesome.emit_signal("window_switcher::select_next")
|
||||||
|
end
|
||||||
|
}
|
||||||
|
},
|
||||||
|
root_keybindings = {
|
||||||
|
awful.key { -- Has to be here and can't be nil
|
||||||
|
modifiers = { "Also Nothing" },
|
||||||
|
key = "Nothing"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
stop_key = "Mod4",
|
||||||
|
stop_event = "release",
|
||||||
|
start_callback = function()
|
||||||
|
awesome.emit_signal("toggle_window_switcher")
|
||||||
|
end,
|
||||||
|
stop_callback = function()
|
||||||
|
awesome.emit_signal("window_switcher::raise")
|
||||||
|
awesome.emit_signal("toggle_window_switcher")
|
||||||
|
end,
|
||||||
|
export_keybindings = true,
|
||||||
|
}
|
||||||
|
|
||||||
return gears.table.join(
|
return gears.table.join(
|
||||||
awful.key(
|
awful.key(
|
||||||
{ modkey },
|
{ modkey },
|
||||||
@@ -156,14 +184,6 @@ return gears.table.join(
|
|||||||
end,
|
end,
|
||||||
{ descripton = "Application launcher", group = "Application" }
|
{ descripton = "Application launcher", group = "Application" }
|
||||||
),
|
),
|
||||||
awful.key(
|
|
||||||
{ modkey },
|
|
||||||
"#23",
|
|
||||||
function()
|
|
||||||
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" }
|
|
||||||
),
|
|
||||||
awful.key(
|
awful.key(
|
||||||
{ "Mod1" },
|
{ "Mod1" },
|
||||||
"#23",
|
"#23",
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ client.connect_signal(
|
|||||||
)
|
)
|
||||||
|
|
||||||
--- Takes a wibox.container.background and connects four signals to it
|
--- Takes a wibox.container.background and connects four signals to it
|
||||||
|
---@diagnostic disable-next-line: undefined-doc-name
|
||||||
---@param widget widget.container.background
|
---@param widget widget.container.background
|
||||||
---@param bg string
|
---@param bg string
|
||||||
---@param fg string
|
---@param fg string
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ return function(s)
|
|||||||
color = Theme_config.brightness_osd.bar_bg_active,
|
color = Theme_config.brightness_osd.bar_bg_active,
|
||||||
background_color = Theme_config.brightness_osd.bar_bg,
|
background_color = Theme_config.brightness_osd.bar_bg,
|
||||||
max_value = 100,
|
max_value = 100,
|
||||||
value = 50,
|
value = 0,
|
||||||
forced_height = dpi(6),
|
forced_height = dpi(6),
|
||||||
shape = function(cr, width, height)
|
shape = function(cr, width, height)
|
||||||
gears.shape.rounded_bar(cr, width, height, dpi(6))
|
gears.shape.rounded_bar(cr, width, height, dpi(6))
|
||||||
@@ -86,7 +86,9 @@ return function(s)
|
|||||||
[[ pkexec xfpm-power-backlight-helper --get-brightness ]],
|
[[ pkexec xfpm-power-backlight-helper --get-brightness ]],
|
||||||
function(stdout)
|
function(stdout)
|
||||||
local brightness_value = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100)
|
local brightness_value = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100)
|
||||||
brightness_osd_widget:get_children_by_id("progressbar")[1].value = stdout
|
brightness_osd_widget:get_children_by_id("progressbar1")[1].value = brightness_value
|
||||||
|
|
||||||
|
awesome.emit_signal("update::backlight", brightness_value)
|
||||||
|
|
||||||
local icon = icondir .. "brightness"
|
local icon = icondir .. "brightness"
|
||||||
if brightness_value >= 0 and brightness_value < 34 then
|
if brightness_value >= 0 and brightness_value < 34 then
|
||||||
@@ -96,7 +98,7 @@ return function(s)
|
|||||||
elseif brightness_value >= 67 then
|
elseif brightness_value >= 67 then
|
||||||
icon = icon .. "-high"
|
icon = icon .. "-high"
|
||||||
end
|
end
|
||||||
brightness_osd_widget:get_children_by_id("icon"):set_image(gears.color.recolor_image(icon .. ".svg",
|
brightness_osd_widget:get_children_by_id("icon")[1]:set_image(gears.color.recolor_image(icon .. ".svg",
|
||||||
Theme_config.brightness_osd.icon_color))
|
Theme_config.brightness_osd.icon_color))
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ local rubato = require("src.lib.rubato")
|
|||||||
local icondir = awful.util.getdir("config") .. "src/assets/icons/"
|
local icondir = awful.util.getdir("config") .. "src/assets/icons/"
|
||||||
|
|
||||||
--- Signal bars widget for the notification-center
|
--- Signal bars widget for the notification-center
|
||||||
|
---@diagnostic disable-next-line: undefined-doc-name
|
||||||
---@return wibox.widget
|
---@return wibox.widget
|
||||||
return function()
|
return function()
|
||||||
|
|
||||||
@@ -90,9 +91,8 @@ return function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
awesome.connect_signal(
|
awesome.connect_signal(
|
||||||
"update::cpu_usage_widget",
|
"update::cpu_usage",
|
||||||
function(cpu_usage)
|
function(cpu_usage)
|
||||||
--w:get_children_by_id("progressbar1")[1].value = cpu_usage
|
|
||||||
tooltip.text = "CPU Usage: " .. cpu_usage .. "%"
|
tooltip.text = "CPU Usage: " .. cpu_usage .. "%"
|
||||||
rubato_timer.target = cpu_usage
|
rubato_timer.target = cpu_usage
|
||||||
end
|
end
|
||||||
@@ -161,10 +161,17 @@ return function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
awesome.connect_signal(
|
awesome.connect_signal(
|
||||||
"update::cpu_temp_widget",
|
"update::cpu_temp",
|
||||||
function(cpu_temp, cpu_temp_icon)
|
function(cpu_temp)
|
||||||
--w:get_children_by_id("progressbar1")[1].value = cpu_temp
|
local temp_icon
|
||||||
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(cpu_temp_icon, color["Blue200"])
|
if cpu_temp < 50 then
|
||||||
|
temp_icon = icondir .. "cpu/thermometer-low.svg"
|
||||||
|
elseif cpu_temp >= 50 and cpu_temp < 80 then
|
||||||
|
temp_icon = icondir .. "cpu/thermometer.svg"
|
||||||
|
elseif cpu_temp >= 80 then
|
||||||
|
temp_icon = icondir .. "cpu/thermometer-high.svg"
|
||||||
|
end
|
||||||
|
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(temp_icon, color["Blue200"])
|
||||||
tooltip.text = "CPU Temp: " .. cpu_temp .. "°C"
|
tooltip.text = "CPU Temp: " .. cpu_temp .. "°C"
|
||||||
rubato_timer.target = cpu_temp
|
rubato_timer.target = cpu_temp
|
||||||
end
|
end
|
||||||
@@ -232,8 +239,8 @@ return function()
|
|||||||
|
|
||||||
awesome.connect_signal(
|
awesome.connect_signal(
|
||||||
"update::ram_widget",
|
"update::ram_widget",
|
||||||
function(ram_usage)
|
function(MemTotal, MemFree, MemAvailable)
|
||||||
--w:get_children_by_id("progressbar1")[1].value = ram_usage
|
local ram_usage = math.floor(((MemTotal - MemAvailable) / MemTotal * 100) + 0.5)
|
||||||
tooltip.text = "RAM Usage: " .. ram_usage .. "%"
|
tooltip.text = "RAM Usage: " .. ram_usage .. "%"
|
||||||
rubato_timer.target = ram_usage
|
rubato_timer.target = ram_usage
|
||||||
end
|
end
|
||||||
@@ -300,11 +307,10 @@ return function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
awesome.connect_signal(
|
awesome.connect_signal(
|
||||||
"update::gpu_usage_widget",
|
"update::gpu_usage",
|
||||||
function(gpu_usage)
|
function(gpu_usage)
|
||||||
--w:get_children_by_id("progressbar1")[1].value = gpu_usage
|
|
||||||
tooltip.text = "GPU Usage: " .. gpu_usage .. "%"
|
tooltip.text = "GPU Usage: " .. gpu_usage .. "%"
|
||||||
rubato_timer.target = gpu_usage
|
rubato_timer.target = tonumber(gpu_usage)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
elseif widget == "gpu_temp" then
|
elseif widget == "gpu_temp" then
|
||||||
@@ -337,7 +343,7 @@ return function()
|
|||||||
{
|
{
|
||||||
{ --Icon
|
{ --Icon
|
||||||
id = "icon1",
|
id = "icon1",
|
||||||
image = gears.color.recolor_image(icondir .. "cpu/gpu.svg", color["Green200"]),
|
image = gears.color.recolor_image(icondir .. "cpu/thermometer.svg", color["Green200"]),
|
||||||
halign = "center",
|
halign = "center",
|
||||||
valign = "center",
|
valign = "center",
|
||||||
widget = wibox.widget.imagebox
|
widget = wibox.widget.imagebox
|
||||||
@@ -371,12 +377,27 @@ return function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
awesome.connect_signal(
|
awesome.connect_signal(
|
||||||
"update::gpu_temp_widget",
|
"update::gpu_temp",
|
||||||
function(gpu_temp, gpu_temp_icon)
|
function(gpu_temp)
|
||||||
--w:get_children_by_id("progressbar1")[1].value = gpu_temp
|
local temp_icon
|
||||||
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(gpu_temp_icon, color["Green200"])
|
local temp_num = tonumber(gpu_temp)
|
||||||
tooltip.text = "GPU Temp: " .. gpu_temp .. "°C"
|
|
||||||
rubato_timer.target = gpu_temp
|
if temp_num then
|
||||||
|
|
||||||
|
if temp_num < 50 then
|
||||||
|
temp_icon = icondir .. "cpu/thermometer-low.svg"
|
||||||
|
elseif temp_num >= 50 and temp_num < 80 then
|
||||||
|
temp_icon = icondir .. "cpu/thermometer.svg"
|
||||||
|
elseif temp_num >= 80 then
|
||||||
|
temp_icon = icondir .. "cpu/thermometer-high.svg"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
temp_num = "NaN"
|
||||||
|
temp_icon = icondir .. "cpu/thermometer-low.svg"
|
||||||
|
end
|
||||||
|
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(temp_icon, color["Green200"])
|
||||||
|
tooltip.text = "GPU Temp: " .. temp_num .. "°C"
|
||||||
|
rubato_timer.target = temp_num
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
elseif widget == "volume" then
|
elseif widget == "volume" then
|
||||||
@@ -587,7 +608,7 @@ return function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
awesome.connect_signal(
|
awesome.connect_signal(
|
||||||
"update::backlight_widget",
|
"update::backlight",
|
||||||
function(backlight, backlight_icon)
|
function(backlight, backlight_icon)
|
||||||
--w:get_children_by_id("progressbar1")[1].value = backlight
|
--w:get_children_by_id("progressbar1")[1].value = backlight
|
||||||
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(backlight_icon, color["Pink200"])
|
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(backlight_icon, color["Pink200"])
|
||||||
|
|||||||
@@ -4,46 +4,85 @@
|
|||||||
|
|
||||||
-- Awesome Libs
|
-- Awesome Libs
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local color = require("src.theme.colors")
|
|
||||||
local dpi = require("beautiful").xresources.apply_dpi
|
local dpi = require("beautiful").xresources.apply_dpi
|
||||||
local gears = require("gears")
|
local gears = require("gears")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
|
|
||||||
|
local naughty = require("naughty")
|
||||||
-- Icon directory path
|
-- Icon directory path
|
||||||
local icondir = awful.util.getdir("config") .. "src/assets/icons/window_switcher/"
|
local icondir = awful.util.getdir("config") .. "src/assets/icons/window_switcher/"
|
||||||
|
|
||||||
return function(s)
|
return function(s)
|
||||||
|
|
||||||
|
-- Variable to check if client is selected
|
||||||
|
|
||||||
local list_update = function(widget, buttons, label, _, objects)
|
local list_update = function(widget, buttons, label, _, objects)
|
||||||
widget:reset()
|
widget:reset()
|
||||||
for _, object in ipairs(objects) do
|
|
||||||
|
local function sort_objects()
|
||||||
|
local objects_sorted = {}
|
||||||
|
objects_sorted[1] = objects[1]
|
||||||
|
local index = 2
|
||||||
|
for _, object in ipairs(objects) do
|
||||||
|
if object ~= nil or object ~= 0 then
|
||||||
|
if object == client.focus then
|
||||||
|
objects_sorted[1] = object
|
||||||
|
else
|
||||||
|
objects_sorted[index] = object
|
||||||
|
index = index + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
index = 2
|
||||||
|
if objects_sorted[1].pid == objects_sorted[2].pid then
|
||||||
|
table.remove(objects_sorted, 2)
|
||||||
|
end
|
||||||
|
return objects_sorted
|
||||||
|
end
|
||||||
|
|
||||||
|
local objects_sorted = sort_objects()
|
||||||
|
|
||||||
|
local selected = objects_sorted[1].pid
|
||||||
|
|
||||||
|
for _, object in ipairs(objects_sorted) do
|
||||||
local window_element = wibox.widget {
|
local window_element = wibox.widget {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
{ -- Icon
|
{
|
||||||
|
{ -- 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
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id = "icon",
|
{
|
||||||
image = object.icon,
|
text = "Application",
|
||||||
|
id = "label",
|
||||||
|
widget = wibox.widget.textbox
|
||||||
|
},
|
||||||
|
id = "place",
|
||||||
valign = "center",
|
valign = "center",
|
||||||
halign = "center",
|
halign = "center",
|
||||||
widget = wibox.widget.imagebox
|
widget = wibox.container.place
|
||||||
},
|
},
|
||||||
width = dpi(100),
|
id = "layout1",
|
||||||
height = dpi(100),
|
spacing = dpi(10),
|
||||||
id = "icon_const",
|
layout = wibox.layout.fixed.vertical
|
||||||
strategy = "exact",
|
|
||||||
widget = wibox.container.constraint
|
|
||||||
},
|
},
|
||||||
{
|
id = "box",
|
||||||
text = "Application",
|
width = dpi(150),
|
||||||
id = "label",
|
height = dpi(150),
|
||||||
valign = "center",
|
strategy = "exact",
|
||||||
align = "center",
|
widget = wibox.container.constraint
|
||||||
widget = wibox.widget.textbox
|
|
||||||
},
|
|
||||||
id = "layout1",
|
|
||||||
spacing = dpi(10),
|
|
||||||
layout = wibox.layout.fixed.vertical
|
|
||||||
},
|
},
|
||||||
id = "margin",
|
id = "margin",
|
||||||
margins = dpi(20),
|
margins = dpi(20),
|
||||||
@@ -52,7 +91,8 @@ return function(s)
|
|||||||
shape = function(cr, width, height)
|
shape = function(cr, width, height)
|
||||||
gears.shape.rounded_rect(cr, width, height, dpi(12))
|
gears.shape.rounded_rect(cr, width, height, dpi(12))
|
||||||
end,
|
end,
|
||||||
bg = Theme_config.window_switcher.element_bg,
|
border_color = Theme_config.window_switcher.border_color,
|
||||||
|
border_width = Theme_config.window_switcher.border_width,
|
||||||
fg = Theme_config.window_switcher.element_fg,
|
fg = Theme_config.window_switcher.element_fg,
|
||||||
widget = wibox.container.background
|
widget = wibox.container.background
|
||||||
}
|
}
|
||||||
@@ -78,38 +118,122 @@ return function(s)
|
|||||||
end
|
end
|
||||||
|
|
||||||
window_element:buttons(create_buttons(buttons, object))
|
window_element:buttons(create_buttons(buttons, object))
|
||||||
|
local text, _ = label(object, window_element:get_children_by_id("label")[1])
|
||||||
|
|
||||||
local text, _ = label(object, window_element.margin.layout1.label)
|
local i = 1
|
||||||
|
local sel = nil
|
||||||
|
|
||||||
if object == client.focus then
|
local select_next = function()
|
||||||
if text == nil or text == "" then
|
if #objects_sorted >= i then
|
||||||
window_element:get_children_by_id("label")[1].text = "Application"
|
selected = objects_sorted[i].pid
|
||||||
else
|
sel = selected
|
||||||
local text_full = text:match(">(.-)<")
|
|
||||||
if text_full then
|
if object.valid then
|
||||||
if object.class == nil then
|
if selected == object.pid then
|
||||||
text = object.name
|
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
|
else
|
||||||
text = object.class:sub(1, 20)
|
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
|
end
|
||||||
end
|
end
|
||||||
window_element:get_children_by_id("label")[1].text = text
|
|
||||||
end
|
end
|
||||||
else
|
if #objects_sorted > i then
|
||||||
|
i = i + 1
|
||||||
|
else
|
||||||
|
i = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
awesome.connect_signal(
|
||||||
|
"window_switcher::select_next",
|
||||||
|
select_next
|
||||||
|
)
|
||||||
|
|
||||||
|
object:connect_signal(
|
||||||
|
"unmanage",
|
||||||
|
function(c)
|
||||||
|
i = 1
|
||||||
|
objects_sorted[1] = objects_sorted[#objects_sorted]
|
||||||
|
objects_sorted[#objects_sorted] = nil
|
||||||
|
if objects_sorted[1] then
|
||||||
|
selected = objects_sorted[1].pid
|
||||||
|
end
|
||||||
|
-- remove object from table
|
||||||
|
for _, object in ipairs(objects) do
|
||||||
|
if object.pid == c.pid then
|
||||||
|
table.remove(objects, _)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for _, object in ipairs(objects_sorted) do
|
||||||
|
if object.pid == c.pid then
|
||||||
|
table.remove(objects_sorted, _)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
awesome.connect_signal(
|
||||||
|
"window_switcher::raise",
|
||||||
|
function()
|
||||||
|
if objects_sorted[i] then
|
||||||
|
if object.valid then
|
||||||
|
if sel == object.pid then
|
||||||
|
object:jump_to()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Reset window switcher
|
||||||
|
i = 1
|
||||||
|
selected = objects_sorted[i].pid
|
||||||
|
sel = selected
|
||||||
|
if selected == object.pid 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.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.selected_bg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
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 = object.name
|
||||||
|
end
|
||||||
|
if selected == object.pid 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
|
||||||
end
|
end
|
||||||
|
|
||||||
window_element:get_children_by_id("icon")[1]:set_image(xdg_icon_lookup:find_icon(object.class, 64))
|
window_element:get_children_by_id("icon")[1]:set_image(xdg_icon_lookup:find_icon(object.class, 64))
|
||||||
|
|
||||||
widget:add(window_element)
|
widget:add(window_element)
|
||||||
widget:set_spacing(dpi(6))
|
widget:set_spacing(dpi(20))
|
||||||
end
|
end
|
||||||
return widget
|
return widget
|
||||||
end
|
end
|
||||||
|
|
||||||
local window_switcher = awful.widget.tasklist(
|
local window_switcher = awful.widget.tasklist(
|
||||||
s,
|
s,
|
||||||
awful.widget.tasklist.filter.allscreen,
|
awful.widget.tasklist.source.all_clients,
|
||||||
awful.util.table.join(
|
awful.util.table.join(
|
||||||
awful.button(
|
awful.button(
|
||||||
{},
|
{},
|
||||||
@@ -133,21 +257,36 @@ return function(s)
|
|||||||
wibox.layout.fixed.horizontal()
|
wibox.layout.fixed.horizontal()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
local window_switcher_margin = wibox.widget {
|
||||||
|
window_switcher,
|
||||||
|
margins = dpi(20),
|
||||||
|
widget = wibox.container.margin
|
||||||
|
}
|
||||||
|
|
||||||
local window_switcher_container = awful.popup {
|
local window_switcher_container = awful.popup {
|
||||||
|
widget = wibox.container.background,
|
||||||
ontop = true,
|
ontop = true,
|
||||||
visible = false,
|
visible = false,
|
||||||
|
stretch = false,
|
||||||
screen = s,
|
screen = s,
|
||||||
shape = function(cr, width, height)
|
shape = function(cr, width, height)
|
||||||
gears.shape.rounded_rect(cr, width, height, dpi(12))
|
gears.shape.rounded_rect(cr, width, height, dpi(12))
|
||||||
end,
|
end,
|
||||||
widget = { window_switcher },
|
|
||||||
placement = awful.placement.centered,
|
placement = awful.placement.centered,
|
||||||
bg = Theme_config.window_switcher.bg,
|
bg = Theme_config.window_switcher.bg,
|
||||||
border_color = Theme_config.window_switcher.border_color,
|
border_color = Theme_config.window_switcher.border_color,
|
||||||
border_width = Theme_config.window_switcher.border_width
|
border_width = Theme_config.window_switcher.border_width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
awesome.connect_signal(
|
||||||
|
"toggle_window_switcher",
|
||||||
|
function()
|
||||||
|
window_switcher_container.visible = not window_switcher_container.visible
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
window_switcher_container:setup {
|
window_switcher_container:setup {
|
||||||
|
window_switcher_margin,
|
||||||
layout = wibox.layout.fixed.vertical
|
layout = wibox.layout.fixed.vertical
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -256,8 +256,11 @@ Theme_config.volume_osd = {
|
|||||||
|
|
||||||
Theme_config.window_switcher = {
|
Theme_config.window_switcher = {
|
||||||
element_bg = color["Grey800"],
|
element_bg = color["Grey800"],
|
||||||
element_fg = color["CyanA200"],
|
element_fg = color["Green200"],
|
||||||
border_color = color["Grey800"],
|
border_color = color["Grey800"],
|
||||||
border_width = dpi(4),
|
border_width = dpi(4),
|
||||||
bg = color["Grey900"],
|
bg = color["Grey900"],
|
||||||
|
selected_fg = color["CyanA200"],
|
||||||
|
selected_border_color = color["Purple200"],
|
||||||
|
selected_bg = "#313131"
|
||||||
}
|
}
|
||||||
|
|||||||
26
awesome/src/tools/helpers/cpu_freq.lua
Normal file
26
awesome/src/tools/helpers/cpu_freq.lua
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
local awful = require("awful")
|
||||||
|
local watch = awful.widget.watch
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[[ bash -c "cat /proc/cpuinfo | grep "MHz" | awk '{print int($4)}'" ]],
|
||||||
|
3,
|
||||||
|
function(_, stdout)
|
||||||
|
local cpu_freq = {}
|
||||||
|
|
||||||
|
for value in stdout:gmatch("%d+") do
|
||||||
|
table.insert(cpu_freq, value)
|
||||||
|
end
|
||||||
|
|
||||||
|
local average = 0
|
||||||
|
|
||||||
|
if User_config.clock_mode == "average" then
|
||||||
|
for i = 1, #cpu_freq do
|
||||||
|
average = average + cpu_freq[i]
|
||||||
|
end
|
||||||
|
average = math.floor(average / #cpu_freq)
|
||||||
|
awesome.emit_signal("update::cpu_freq_average", average)
|
||||||
|
elseif User_config.clock_mode then
|
||||||
|
awesome.emit_signal("update::cpu_freq_core", cpu_freq[User_config.clock_mode])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
14
awesome/src/tools/helpers/cpu_temp.lua
Normal file
14
awesome/src/tools/helpers/cpu_temp.lua
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
local awful = require("awful")
|
||||||
|
local watch = awful.widget.watch
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[[ bash -c "sensors | grep 'Package id 0:' | awk '{print $4}'" ]],
|
||||||
|
3,
|
||||||
|
function(_, stdout)
|
||||||
|
local temp = tonumber(stdout:match("%d+"))
|
||||||
|
awesome.emit_signal(
|
||||||
|
"update::cpu_temp",
|
||||||
|
temp
|
||||||
|
)
|
||||||
|
end
|
||||||
|
)
|
||||||
26
awesome/src/tools/helpers/cpu_usage.lua
Normal file
26
awesome/src/tools/helpers/cpu_usage.lua
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
local awful = require("awful")
|
||||||
|
local watch = awful.widget.watch
|
||||||
|
|
||||||
|
local total_prev = 0
|
||||||
|
local idle_prev = 0
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[[ cat "/proc/stat" | grep '^cpu ' ]],
|
||||||
|
3,
|
||||||
|
function(_, stdout)
|
||||||
|
local user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice =
|
||||||
|
stdout:match("(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s")
|
||||||
|
|
||||||
|
local total = user + nice + system + idle + iowait + irq + softirq + steal
|
||||||
|
|
||||||
|
local diff_idle = idle - idle_prev
|
||||||
|
local diff_total = total - total_prev
|
||||||
|
local diff_usage = math.floor(((1000 * (diff_total - diff_idle) / diff_total + 5) / 10) + 0.5)
|
||||||
|
|
||||||
|
awesome.emit_signal("update::cpu_usage", diff_usage)
|
||||||
|
|
||||||
|
total_prev = total
|
||||||
|
idle_prev = idle
|
||||||
|
collectgarbage("collect")
|
||||||
|
end
|
||||||
|
)
|
||||||
10
awesome/src/tools/helpers/gpu_temp.lua
Normal file
10
awesome/src/tools/helpers/gpu_temp.lua
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
local awful = require("awful")
|
||||||
|
local watch = awful.widget.watch
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[[ bash -c "nvidia-smi -q -d TEMPERATURE | grep 'GPU Current Temp' | awk '{print $5}'"]],
|
||||||
|
3,
|
||||||
|
function(_, stdout)
|
||||||
|
awesome.emit_signal("update::gpu_temp", stdout:match("%d+"):gsub("\n", ""))
|
||||||
|
end
|
||||||
|
)
|
||||||
11
awesome/src/tools/helpers/gpu_usage.lua
Normal file
11
awesome/src/tools/helpers/gpu_usage.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
local awful = require("awful")
|
||||||
|
local watch = awful.widget.watch
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[[ bash -c "nvidia-smi -q -d UTILIZATION | grep Gpu | awk '{print $3}'"]],
|
||||||
|
3,
|
||||||
|
function(_, stdout)
|
||||||
|
stdout = stdout:match("%d+")
|
||||||
|
awesome.emit_signal("update::gpu_usage", stdout)
|
||||||
|
end
|
||||||
|
)
|
||||||
6
awesome/src/tools/helpers/init.lua
Normal file
6
awesome/src/tools/helpers/init.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
require("src.tools.helpers.cpu_temp")
|
||||||
|
require("src.tools.helpers.cpu_usage")
|
||||||
|
require("src.tools.helpers.cpu_freq")
|
||||||
|
require("src.tools.helpers.ram")
|
||||||
|
require("src.tools.helpers.gpu_usage")
|
||||||
|
require("src.tools.helpers.gpu_temp")
|
||||||
11
awesome/src/tools/helpers/ram.lua
Normal file
11
awesome/src/tools/helpers/ram.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
local awful = require("awful")
|
||||||
|
local watch = awful.widget.watch
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[[ bash -c "cat /proc/meminfo| grep Mem | awk '{print $2}'" ]],
|
||||||
|
3,
|
||||||
|
function(_, stdout)
|
||||||
|
local MemTotal, MemFree, MemAvailable = stdout:match("(%d+)\n(%d+)\n(%d+)\n")
|
||||||
|
awesome.emit_signal("update::ram_widget", MemTotal, MemFree, MemAvailable)
|
||||||
|
end
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user