worked on some stuff and finally the new install script (no idea if it works yet)

This commit is contained in:
Rene Kievits
2023-10-25 15:01:31 +02:00
parent bf8520ed9d
commit 294b15e9ea
28 changed files with 1439 additions and 1147 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 KiB

After

Width:  |  Height:  |  Size: 229 KiB

View File

@@ -240,7 +240,9 @@ return gtable.join(
{},
'XF86AudioLowerVolume',
function(c)
audio_helper.sink_volume_down()
-- When changing the volume it makes sense to unmute
audio_helper:sink_volume_down()
audio_helper:sink_unmute()
end,
{ description = 'Lower volume', group = 'System' }
),
@@ -248,7 +250,9 @@ return gtable.join(
{},
'XF86AudioRaiseVolume',
function(c)
audio_helper.sink_volume_up()
-- When changing the volume it makes sense to unmute
audio_helper:sink_volume_up()
audio_helper:sink_unmute()
end,
{ description = 'Increase volume', group = 'System' }
),
@@ -256,7 +260,7 @@ return gtable.join(
{},
'XF86AudioMute',
function(c)
audio_helper.sink_toggle_mute()
audio_helper:sink_toggle_mute()
end,
{ description = 'Mute volume', group = 'System' }
),
@@ -330,8 +334,8 @@ return gtable.join(
-- Check if data already had the client then return
for _, v in ipairs(data) 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
v.WM_CLASS == client_data.WM_CLASS and
v.WM_INSTANCE == client_data.WM_INSTANCE then
return
end
end
@@ -375,7 +379,7 @@ return gtable.join(
-- Remove client_data from data_table
for k, v in ipairs(data) do
if v.WM_CLASS == client_data.WM_CLASS and
v.WM_INSTANCE == client_data.WM_INSTANCE then
v.WM_INSTANCE == client_data.WM_INSTANCE then
table.remove(data, k)
ruled.client.remove_rule {
rule = { class = c.class, instance = c.instance },

View File

@@ -48,7 +48,6 @@ if not instance then
raise = true,
})
end
collectgarbage('collect')
end)
capi.tag.connect_signal('property::selected', function(c)

View File

@@ -0,0 +1,153 @@
-----------------------------------
-- This is the volume_old module --
-----------------------------------
-- Awesome Libs
local aplacement = require('awful.placement')
local apopup = require('awful.popup')
local beautiful = require('beautiful')
local dpi = require('beautiful').xresources.apply_dpi
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local gshape = require('gears.shape')
local gtable = require('gears.table')
local gtimer = require('gears.timer')
local wibox = require('wibox')
local audio_helper = require('src.tools.helpers.audio')
-- Icon directory path
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/audio/'
local capi = {
awesome = awesome,
}
local osd = {}
function osd:display()
self.popup.visible = true
if self.timer.started then
self.timer:again()
else
self.timer:start()
end
end
local instance = nil
if not instance then
instance = setmetatable(osd, {
__call = function(self, ...)
local args = ... or {}
self.popup = apopup {
widget = {
{
{
{ -- Volume Icon
{
image = gcolor.recolor_image(icondir .. 'volume-off.svg',
beautiful.colorscheme.bg_yellow),
resize = true,
id = 'icon_role',
widget = wibox.widget.imagebox,
},
widget = wibox.container.constraint,
width = dpi(36),
height = dpi(36),
strategy = 'exact',
},
{
widget = wibox.container.constraint,
width = dpi(24),
strategy = 'exact',
},
{ -- Volume Bar
{
{
id = 'progressbar',
value = 0,
max_value = 100,
color = beautiful.colorscheme.bg_yellow,
background_color = beautiful.colorscheme.bg1,
shape = gshape.rounded_rect,
widget = wibox.widget.progressbar,
},
widget = wibox.container.constraint,
width = dpi(250),
height = dpi(12),
},
widget = wibox.container.place,
},
{ -- Value text
{
widget = wibox.widget.textbox,
halign = 'right',
id = 'text_role',
text = 'NAN%',
},
widget = wibox.container.constraint,
width = dpi(60),
strategy = 'min',
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
},
margins = dpi(20),
widget = wibox.container.margin,
},
shape = beautiful.shape[12],
widget = wibox.container.background,
},
ontop = true,
stretch = false,
visible = true,
border_color = beautiful.colorscheme.border_color,
border_width = dpi(2),
fg = beautiful.colorscheme.fg,
bg = beautiful.colorscheme.bg,
screen = 1,
placement = function(c) aplacement.bottom(c, { margins = dpi(20) }) end,
}
self.popup.visible = false
self.timer = gtimer {
timeout = args.display_time or 3,
autostart = true,
callback = function()
self.popup.visible = false
end,
}
local volume_icon = self.popup.widget:get_children_by_id('icon_role')[1]
local volume_text = self.popup.widget:get_children_by_id('text_role')[1]
local volume_progressbar = self.popup.widget:get_children_by_id('progressbar')[1]
audio_helper:connect_signal('sink::get', function(_, muted, volume)
volume = tonumber(volume or 0)
local icon = 'volume-mute.svg'
if muted then
volume_progressbar.value = 0
else
volume_progressbar.value = volume
icon = icondir .. 'volume'
if volume < 1 then
icon = icon .. '-mute'
elseif volume >= 1 and volume < 34 then
icon = icon .. '-low'
elseif volume >= 34 and volume < 67 then
icon = icon .. '-medium'
elseif volume >= 67 then
icon = icon .. '-high'
end
end
volume_icon:set_image(gcolor.recolor_image(icon .. '.svg', beautiful.colorscheme.bg_yellow))
volume_text.text = volume .. '%'
self:display()
end)
end,
})
end
return instance

View File

@@ -1,139 +0,0 @@
-----------------------------------
-- This is the volume_old module --
-----------------------------------
-- Awesome Libs
local aplacement = require('awful.placement')
local apopup = require('awful.popup')
local beautiful = require('beautiful')
local dpi = require('beautiful').xresources.apply_dpi
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local gshape = require('gears.shape')
local gtable = require('gears.table')
local gtimer = require('gears.timer')
local wibox = require('wibox')
local audio_helper = require('src.tools.helpers.audio')
-- Icon directory path
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/audio/'
local osd = {}
function osd:run()
self.visible = true
if self.timer.started then
self.timer:again()
else
self.timer:start()
end
end
function osd.new(args)
args = args or {}
args.screen = args.screen or 1
local w = apopup {
widget = {
{
{
{ -- Volume Icon
{
image = gcolor.recolor_image(icondir .. 'volume-off.svg', beautiful.colorscheme.bg_purple),
valign = 'center',
halign = 'center',
resize = true,
id = 'icon_role',
widget = wibox.widget.imagebox,
},
widget = wibox.container.constraint,
width = dpi(25),
height = dpi(25),
strategy = 'exact',
},
{ -- Volume Bar
{
{
id = 'progressbar',
color = beautiful.colorscheme.bg_purple,
background_color = beautiful.colorscheme.bg1,
max_value = 100,
value = 0,
shape = gshape.rounded_rect,
widget = wibox.widget.progressbar,
},
widget = wibox.container.constraint,
width = dpi(250),
height = dpi(5),
},
widget = wibox.container.place,
},
{ -- Volume text
widget = wibox.widget.textbox,
id = 'text_role',
text = '0',
valign = 'center',
halign = 'center',
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
},
left = dpi(10),
right = dpi(10),
top = dpi(20),
bottom = dpi(20),
widget = wibox.container.margin,
},
shape = beautiful.shape[12],
widget = wibox.container.background,
},
ontop = true,
stretch = false,
visible = false,
border_color = beautiful.colorscheme.border_color,
border_width = dpi(2),
fg = beautiful.colorscheme.bg_purple,
bg = beautiful.colorscheme.bg,
screen = 1,
placement = function(c) aplacement.bottom(c, { margins = dpi(20) }) end,
}
gtable.crush(w, osd)
w.timer = gtimer {
timeout = 2,
autostart = true,
callback = function()
w.visible = false
end,
}
audio_helper:connect_signal('output::get', function(_, muted, volume)
volume = tonumber(volume or 0)
if muted then
w.widget:get_children_by_id('icon_role')[1]:set_image(gcolor.recolor_image(icondir .. 'volume-mute' .. '.svg', beautiful.colorscheme.bg_purple))
w.widget:get_children_by_id('progressbar')[1].value = 0
else
w.widget:get_children_by_id('progressbar')[1].value = volume
local icon = icondir .. 'volume'
if volume < 1 then
icon = icon .. '-mute'
elseif volume >= 1 and volume < 34 then
icon = icon .. '-low'
elseif volume >= 34 and volume < 67 then
icon = icon .. '-medium'
elseif volume >= 67 then
icon = icon .. '-high'
end
w.widget:get_children_by_id('icon_role')[1]:set_image(gcolor.recolor_image(icon .. '.svg', beautiful.colorscheme.bg_purple))
w.widget:get_children_by_id('text_role')[1].text = volume
end
w:run()
end)
return w
end
return setmetatable(osd, { __call = function(_, ...) return osd.new(...) end })

View File

@@ -227,7 +227,8 @@ function device.new(args)
widget = wibox.container.margin,
},
widget = wibox.container.background,
}, spacing = dpi(10),
},
spacing = dpi(10),
entries = {
{ -- Connect/Disconnect a device
name = ret.device.Connected and 'Disconnect' or 'Connect',

File diff suppressed because it is too large Load Diff

View File

@@ -1,144 +0,0 @@
---------------------------------------
-- This is the brightness_osd module --
---------------------------------------
-- Awesome Libs
local aplacement = require('awful.placement')
local apopup = require('awful.popup')
local beautiful = require('beautiful')
local dpi = require('beautiful').xresources.apply_dpi
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local gshape = require('gears.shape')
local gtable = require('gears.table')
local gtimer = require('gears.timer')
local wibox = require('wibox')
local backlight_helper = require('src.tools.helpers.backlight')
local capi = {
awesome = awesome,
mouse = mouse,
}
-- Icon directory path
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/brightness/'
local brightness_osd = { mt = {} }
-- Hide the brightness_osd after 3 seconds
function brightness_osd:run()
self.visible = true
if self.timer.started then
self.timer:again()
else
self.timer:start()
end
end
function brightness_osd.new(args)
args = args or {}
local w = apopup {
widget = {
{
{
{ -- Brightness Icon
{
image = gcolor.recolor_image(icondir .. 'volume-off.svg', beautiful.colorscheme.bg_blue),
valign = 'center',
halign = 'center',
resize = true,
id = 'icon_role',
widget = wibox.widget.imagebox,
},
widget = wibox.container.constraint,
width = dpi(25),
height = dpi(25),
strategy = 'exact',
},
{ -- Brightness Bar
{
{
id = 'progressbar',
color = beautiful.colorscheme.bg_blue,
background_color = beautiful.colorscheme.bg,
max_value = 100,
value = 0,
shape = gshape.rounded_rect,
widget = wibox.widget.progressbar,
},
widget = wibox.container.constraint,
width = dpi(250),
height = dpi(5),
},
widget = wibox.container.place,
},
{ -- Brightness text
widget = wibox.widget.textbox,
id = 'text_role',
text = '0',
valign = 'center',
halign = 'center',
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
},
left = dpi(10),
right = dpi(10),
top = dpi(20),
bottom = dpi(20),
widget = wibox.container.margin,
},
shape = beautiful.shape[4],
widget = wibox.container.background,
},
ontop = true,
stretch = false,
visible = false,
border_color = beautiful.colorscheme.border_color,
border_width = dpi(2),
fg = beautiful.colorscheme.bg_blue,
bg = beautiful.colorscheme.bg,
screen = 1,
placement = function(c) aplacement.bottom(c, { margins = dpi(20) }) end,
}
gtable.crush(w, brightness_osd, true)
w.timer = gtimer {
timeout = 2,
autostart = true,
callback = function()
w.visible = false
end,
}
backlight_helper:connect_signal('brightness_changed', function()
backlight_helper:brightness_get_async(function(brightness)
brightness = brightness / (backlight_helper.brightness_max or 24000) * 100
w.widget:get_children_by_id('progressbar')[1].value = brightness
local icon = icondir .. 'brightness'
if brightness >= 0 and brightness < 34 then
icon = icon .. '-low.svg'
elseif brightness >= 34 and brightness < 67 then
icon = icon .. '-medium.svg'
elseif brightness >= 67 then
icon = icon .. '-high.svg'
end
w.widget:get_children_by_id('icon')[1]:set_image(gcolor.recolor_image(icon, beautiful.colorscheme.bg_blue))
w.widget:get_children_by_id('text_role')[1].text = brightness
w:run()
end)
end)
return w
end
function brightness_osd.mt:__call(...)
return brightness_osd.new(...)
end
return setmetatable(brightness_osd, brightness_osd.mt)

View File

@@ -0,0 +1,154 @@
local setmetatable = setmetatable
local apopup = require('awful.popup')
local aplacement = require('awful.placement')
local beautiful = require('beautiful')
local dpi = beautiful.xresources.apply_dpi
local gcolor = require('gears.color')
local gobject = require('gears.object')
local gtable = require('gears.table')
local gtimer = require('gears.timer')
local gfilesystem = require('gears.filesystem')
local gshape = require('gears.shape')
local wibox = require('wibox')
local backlight_helper = require('src.tools.helpers.backlight')
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/brightness/'
local capi = {
awesome = awesome,
}
local osd = gobject {}
-- Show the popup for x seconds, default is 3
function osd:display()
self.popup.visible = true
if self.timer.started then
self.timer:again()
else
self.timer:start()
end
end
local instance = nil
if not instance then
instance = setmetatable(osd, {
---Create a backlight osd that shows when the backlight is changed
---@param ... table[display_time]
__call = function(self, ...)
local args = ... or {}
-- Set to visible on creation so the popup is cached on startup
self.popup = apopup {
widget = {
{
{
{ -- Icon
{
image = gcolor.recolor_image(icondir .. 'brightness-high.svg',
beautiful.colorscheme.bg_blue),
resize = true,
id = 'icon_role',
widget = wibox.widget.imagebox,
},
widget = wibox.container.constraint,
width = dpi(36),
height = dpi(36),
strategy = 'exact',
},
{
widget = wibox.container.constraint,
width = dpi(24),
strategy = 'exact',
},
{ -- Progressbar
{
{
id = 'progressbar',
value = 0,
max_value = 100,
color = beautiful.colorscheme.bg_blue,
background_color = beautiful.colorscheme.bg1,
shape = gshape.rounded_rect,
widget = wibox.widget.progressbar,
},
widget = wibox.container.constraint,
width = dpi(250),
height = dpi(12),
},
widget = wibox.container.place,
},
{ -- Value text
{
widget = wibox.widget.textbox,
halign = 'right',
id = 'text_role',
text = 'NAN%',
},
widget = wibox.container.constraint,
width = dpi(60),
strategy = 'min',
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
},
widget = wibox.container.margin,
margins = dpi(20),
},
widget = wibox.container.background,
shape = beautiful.shape[12],
},
ontop = true,
stretch = false,
visible = true,
border_color = beautiful.colorscheme.border_color,
border_width = dpi(2),
fg = beautiful.colorscheme.fg,
bg = beautiful.colorscheme.bg,
screen = 1,
placement = function(c) aplacement.bottom(c, { margins = dpi(20) }) end,
}
self.popup.visible = false
self.timer = gtimer {
timeout = args.display_time or 3,
autostart = true,
callback = function()
self.popup.visible = false
end,
}
local progressbar = self.popup.widget:get_children_by_id('progressbar')[1]
local brightness_text = self.popup.widget:get_children_by_id('text_role')[1]
local brightness_icon = self.popup.widget:get_children_by_id('icon_role')[1]
backlight_helper:connect_signal('brightness_changed', function()
backlight_helper.brightness_get_async(function(brightness)
if not brightness then return end
brightness = math.floor((tonumber(brightness) / (backlight_helper.brightness_max or 24000) * 100) + 0.5)
local icon = icondir .. 'brightness'
if brightness >= 0 and brightness < 34 then
icon = icon .. '-low.svg'
elseif brightness >= 34 and brightness < 67 then
icon = icon .. '-medium.svg'
elseif brightness >= 67 then
icon = icon .. '-high.svg'
end
brightness_icon.image = gcolor.recolor_image(icon,
beautiful.colorscheme.bg_blue)
progressbar.value = brightness
brightness_text.text = brightness .. '%'
self:display()
end)
end)
return self
end,
})
end
return instance

View File

@@ -101,7 +101,9 @@ function dock:get_element_widget(desktop_file)
if not desktop_file then return end
local GDesktopAppInfo = Gio.DesktopAppInfo.new_from_filename(desktop_file)
if not GDesktopAppInfo then
return
end
local icon = icon_lookup:get_gicon_path(nil, GDesktopAppInfo.get_string(GDesktopAppInfo, 'Icon')) or
icon_lookup:get_gicon_path(nil, Gio.DesktopAppInfo.get_string(GDesktopAppInfo, 'X-AppImage-Old-Icon')) or ''

View File

@@ -30,6 +30,8 @@ if not instance then
end)
require('src.modules.app_launcher')()
require('src.modules.powermenu')()
require('src.modules.brightness')()
require('src.modules.audio')()
end,
})
end

View File

@@ -454,9 +454,9 @@ end
local button_signal = function(self, x, y, button)
if button == 1 then
self:set_cursor_pos_from_mouse(x, y)
self:start_mousegrabber(x, y)
self:start_keygrabber()
--self:set_cursor_pos_from_mouse(x, y)
--self:start_mousegrabber(x, y)
--self:start_keygrabber()
end
end

View File

@@ -380,7 +380,7 @@ function network:add_ap_to_list(ap)
halign = 'center',
widget = wibox.widget.imagebox,
},
strategy = 'max',
strategy = 'exact',
height = dpi(24),
width = dpi(24),
widget = wibox.container.constraint,

View File

@@ -15,7 +15,7 @@ local rubato = require('src.lib.rubato')
-- Own Libs
local audio = require('src.tools.helpers.audio')
local backlight = require('src.tools.helpers.backlight')
local backlight_helper = require('src.tools.helpers.backlight')
--local battery = require('src.tools.helpers.battery')
local cpu_usage = require('src.tools.helpers.cpu_usage')
local cpu_temp = require('src.tools.helpers.cpu_temp')
@@ -26,250 +26,277 @@ local gpu_temp = require('src.tools.helpers.gpu_temp')
-- Icon directory path
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/'
return setmetatable({}, { __call = function()
local capi = {
awesome = awesome,
}
---Creates a layout with bar widgets based on the given table
---@param widget_table table
---@return table
local function create_bar_layout(widget_table)
local bar_layout = { layout = wibox.layout.flex.horizontal, spacing = dpi(10) }
return setmetatable({}, {
__call = function()
---Creates a layout with bar widgets based on the given table
---@param widget_table table
---@return table
local function create_bar_layout(widget_table)
local bar_layout = { layout = wibox.layout.flex.horizontal, spacing = dpi(10) }
for _, widget in pairs(widget_table) do
local w = base.make_widget_from_value {
{
for _, widget in pairs(widget_table) do
local w = base.make_widget_from_value {
{
{
{ --Bar
color = beautiful.colorscheme.bg_teal,
background_color = beautiful.colorscheme.bg1,
max_value = 100,
value = 0,
forced_height = dpi(8),
shape = function(cr)
gears.shape.rounded_bar(cr, dpi(58), dpi(8))
end,
id = 'progress_role',
widget = wibox.widget.progressbar,
{
{ --Bar
color = beautiful.colorscheme.bg_teal,
background_color = beautiful.colorscheme.bg1,
max_value = 100,
value = 0,
forced_height = dpi(8),
shape = function(cr)
gears.shape.rounded_bar(cr, dpi(58), dpi(8))
end,
id = 'progress_role',
widget = wibox.widget.progressbar,
},
halign = 'center',
valign = 'center',
widget = wibox.container.place,
},
direction = 'east',
widget = wibox.container.rotate,
},
widget = wibox.container.constraint,
height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58
width = dpi(24),
strategy = 'exact',
},
{
{ --Icon
id = 'image_role',
halign = 'center',
valign = 'center',
widget = wibox.container.place,
widget = wibox.widget.imagebox,
},
direction = 'east',
widget = wibox.container.rotate,
height = dpi(24),
width = dpi(24),
widget = wibox.container.constraint,
},
widget = wibox.container.constraint,
height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58
width = dpi(24),
strategy = 'exact',
},
{
{ --Icon
id = 'image_role',
halign = 'center',
valign = 'center',
widget = wibox.widget.imagebox,
},
height = dpi(24),
width = dpi(24),
widget = wibox.container.constraint,
},
spacing = dpi(10),
layout = wibox.layout.fixed.vertical,
}
spacing = dpi(10),
layout = wibox.layout.fixed.vertical,
}
assert(type(w) == 'table', 'Widget creation failed')
assert(type(w) == 'table', 'Widget creation failed')
local bar = w:get_children_by_id('progress_role')[1]
local bar = w:get_children_by_id('progress_role')[1]
local rubato_timer = rubato.timed {
duration = 1,
pos = bar.value,
easing = rubato.linear,
subscribed = function(v)
bar.value = v
end,
}
local rubato_timer = rubato.timed {
duration = 1,
pos = bar.value,
easing = rubato.linear,
subscribed = function(v)
bar.value = v
end,
}
local tooltip = awful.tooltip {
objects = { w },
mode = 'inside',
preferred_alignments = 'middle',
margins = dpi(10),
}
local tooltip = awful.tooltip {
objects = { w },
mode = 'inside',
preferred_alignments = 'middle',
margins = dpi(10),
}
if widget == 'cpu_usage' then
cpu_usage:connect_signal('update::cpu_usage', function(_, v)
if not v then return nil end
tooltip.text = 'CPU Usage: ' .. v .. '%'
rubato_timer.target = v
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icondir .. 'cpu/cpu.svg',
beautiful.colorscheme.bg_teal)
end)
elseif widget == 'cpu_temp' then
cpu_temp:connect_signal('update::cpu_temp', function(_, v)
if not v then return nil end
local temp_icon
if v < 50 then
temp_icon = icondir .. 'cpu/thermometer-low.svg'
elseif v >= 50 and v < 80 then
temp_icon = icondir .. 'cpu/thermometer.svg'
elseif v >= 80 then
temp_icon = icondir .. 'cpu/thermometer-high.svg'
end
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(temp_icon,
beautiful.colorscheme.bg_blue)
tooltip.text = 'CPU Temp: ' .. v .. '°C'
rubato_timer.target = v
end)
elseif widget == 'ram_usage' then
ram:connect_signal('update::ram_widget', function(_, MemTotal, _, MemAvailable)
if not MemTotal and MemAvailable then return nil end
if not MemTotal or not MemAvailable then return end
local ram_usage = math.floor(((MemTotal - MemAvailable) / MemTotal * 100) + 0.5)
tooltip.text = 'RAM Usage: ' .. ram_usage .. '%'
rubato_timer.target = ram_usage
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icondir .. 'cpu/ram.svg',
beautiful.colorscheme.bg_red)
end)
elseif widget == 'gpu_usage' then
gpu_usage:connect_signal('update::gpu_usage', function(_, v)
if not v then return nil end
tooltip.text = 'GPU Usage: ' .. v .. '%'
rubato_timer.target = tonumber(v)
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icondir .. 'cpu/gpu.svg',
beautiful.colorscheme.bg_green)
end)
elseif widget == 'gpu_temp' then
gpu_temp:connect_signal('update::gpu_temp', function(_, v)
if not v then return nil end
local temp_icon, temp_num
if v then
temp_num = tonumber(v)
if temp_num < 50 then
if widget == 'cpu_usage' then
cpu_usage:connect_signal('update::cpu_usage', function(_, v)
if not v then return nil end
tooltip.text = 'CPU Usage: ' .. v .. '%'
rubato_timer.target = v
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icondir .. 'cpu/cpu.svg',
beautiful.colorscheme.bg_teal)
end)
elseif widget == 'cpu_temp' then
cpu_temp:connect_signal('update::cpu_temp', function(_, v)
if not v then return nil end
local temp_icon
if v < 50 then
temp_icon = icondir .. 'cpu/thermometer-low.svg'
elseif temp_num >= 50 and temp_num < 80 then
elseif v >= 50 and v < 80 then
temp_icon = icondir .. 'cpu/thermometer.svg'
elseif temp_num >= 80 then
elseif v >= 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('image_role')[1].image = gears.color.recolor_image(temp_icon,
beautiful.colorscheme.bg_green)
tooltip.text = 'GPU Temp: ' .. temp_num .. '°C'
rubato_timer.target = temp_num
end)
elseif widget == 'volume' then
audio:connect_signal('sink::get', function(_, muted, volume)
if not volume and muted then return nil end
local icon = icondir .. 'audio/volume'
volume = tonumber(volume)
if not volume then
return
end
if muted then
icon = icon .. '-mute'
else
if volume < 1 then
icon = icon .. '-mute'
elseif volume >= 1 and volume < 34 then
icon = icon .. '-low'
elseif volume >= 34 and volume < 67 then
icon = icon .. '-medium'
elseif volume >= 67 then
icon = icon .. '-high'
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(temp_icon,
beautiful.colorscheme.bg_blue)
tooltip.text = 'CPU Temp: ' .. v .. '°C'
rubato_timer.target = v
end)
elseif widget == 'ram_usage' then
ram:connect_signal('update::ram_widget', function(_, MemTotal, _, MemAvailable)
if not MemTotal and MemAvailable then return nil end
if not MemTotal or not MemAvailable then return end
local ram_usage = math.floor(((MemTotal - MemAvailable) / MemTotal * 100) + 0.5)
tooltip.text = 'RAM Usage: ' .. ram_usage .. '%'
rubato_timer.target = ram_usage
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icondir .. 'cpu/ram.svg',
beautiful.colorscheme.bg_red)
end)
elseif widget == 'gpu_usage' then
gpu_usage:connect_signal('update::gpu_usage', function(_, v)
if not v then return nil end
tooltip.text = 'GPU Usage: ' .. v .. '%'
rubato_timer.target = v
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icondir .. 'cpu/gpu.svg',
beautiful.colorscheme.bg_green)
end)
elseif widget == 'gpu_temp' then
gpu_temp:connect_signal('update::gpu_temp', function(_, v)
if not v then return nil end
local temp_icon, temp_num
if v then
temp_num = tonumber(v)
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
end
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icon .. '.svg',
beautiful.colorscheme.bg_yellow)
tooltip.text = 'Volume: ' .. volume .. '%'
rubato_timer.target = volume
end)
elseif widget == 'microphone' then
audio:connect_signal('source::get', function(_, muted, volume)
if not volume and muted then return nil end
if not volume then
return
end
local icon = icondir .. 'audio/microphone'
volume = tonumber(volume)
if not volume then
return
end
if muted or (volume < 1) then
icon = icon .. '-off'
end
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icon .. '.svg',
beautiful.colorscheme.bg_blue)
tooltip.text = 'Microphone: ' .. volume .. '%'
rubato_timer.target = volume
end)
elseif widget == 'backlight' then
backlight:connect_signal('brightness::get', function(_, v)
if not v then return nil end
local icon = icondir .. 'brightness'
if v >= 0 and v < 34 then
icon = icon .. '-low'
elseif v >= 34 and v < 67 then
icon = icon .. '-medium'
elseif v >= 67 then
icon = icon .. '-high'
end
w:get_children_by_id('image_role')[1]:set_image(gears.color.recolor_image(icon .. '.svg',
beautiful.colorscheme.bg_purple))
tooltip.text = 'Backlight: ' .. v .. '%'
rubato_timer.target = v
end)
elseif widget == 'battery' then
--[[ battery:connect_signal('update::battery_widget', function(battery, battery_icon)
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(battery_icon,
beautiful.colorscheme.bg_purple)
tooltip.text = 'Battery: ' .. battery .. '%'
rubato_timer.target = battery
end) ]]
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(temp_icon,
beautiful.colorscheme.bg_green)
tooltip.text = 'GPU Temp: ' .. temp_num .. '°C'
rubato_timer.target = temp_num
end)
elseif widget == 'volume' then
audio:connect_signal('sink::get', function(_, muted, volume)
if not volume and muted then return nil end
local icon = icondir .. 'audio/volume'
volume = tonumber(volume)
if not volume then
return
end
if muted then
icon = icon .. '-mute'
else
if volume < 1 then
icon = icon .. '-mute'
elseif volume >= 1 and volume < 34 then
icon = icon .. '-low'
elseif volume >= 34 and volume < 67 then
icon = icon .. '-medium'
elseif volume >= 67 then
icon = icon .. '-high'
end
end
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icon .. '.svg',
beautiful.colorscheme.bg_yellow)
tooltip.text = 'Volume: ' .. volume .. '%'
rubato_timer.target = volume
end)
elseif widget == 'microphone' then
audio:connect_signal('source::get', function(_, muted, volume)
if not volume and muted then return nil end
if not volume then
return
end
local icon = icondir .. 'audio/microphone'
volume = tonumber(volume)
if not volume then
return
end
if muted or (volume < 1) then
icon = icon .. '-off'
end
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(icon .. '.svg',
beautiful.colorscheme.bg_blue)
tooltip.text = 'Microphone: ' .. volume .. '%'
rubato_timer.target = volume
end)
elseif widget == 'backlight' then
backlight_helper:connect_signal('brightness_changed', function()
backlight_helper.brightness_get_async(function(brightness)
if not brightness then return end
brightness = math.floor((tonumber(brightness) / (backlight_helper.brightness_max or 24000) * 100) + 0.5)
local icon = icondir .. 'brightness/brightness'
if brightness >= 0 and brightness < 34 then
icon = icon .. '-low.svg'
elseif brightness >= 34 and brightness < 67 then
icon = icon .. '-medium.svg'
elseif brightness >= 67 then
icon = icon .. '-high.svg'
end
w:get_children_by_id('image_role')[1]:set_image(gears.color.recolor_image(icon,
beautiful.colorscheme.bg_purple))
tooltip.text = 'Backlight: ' .. brightness .. '%'
rubato_timer.target = brightness
end)
end)
backlight_helper.brightness_get_async(function(brightness)
if not brightness then return end
brightness = math.floor((tonumber(brightness) / (backlight_helper.brightness_max or 24000) * 100) + 0.5)
local icon = icondir .. 'brightness/brightness'
if brightness >= 0 and brightness < 34 then
icon = icon .. '-low.svg'
elseif brightness >= 34 and brightness < 67 then
icon = icon .. '-medium.svg'
elseif brightness >= 67 then
icon = icon .. '-high.svg'
end
w:get_children_by_id('image_role')[1]:set_image(gears.color.recolor_image(icon,
beautiful.colorscheme.bg_purple))
tooltip.text = 'Backlight: ' .. brightness .. '%'
rubato_timer.target = brightness
end)
elseif widget == 'battery' then
capi.awesome.connect_signal('update::battery_widget', function(battery, battery_icon)
w:get_children_by_id('image_role')[1].image = gears.color.recolor_image(battery_icon,
beautiful.colorscheme.bg_purple)
tooltip.text = 'Battery: ' .. battery .. '%'
rubato_timer.target = battery
end)
end
table.insert(bar_layout, w)
end
table.insert(bar_layout, w)
return bar_layout
end
return bar_layout
end
return wibox.widget {
{
return wibox.widget {
{
{
{
{
create_bar_layout(beautiful.user_config.status_bar_widgets),
width = dpi(480),
strategy = 'exact',
widget = wibox.container.constraint,
{
create_bar_layout(beautiful.user_config.status_bar_widgets),
width = dpi(480),
strategy = 'exact',
widget = wibox.container.constraint,
},
widget = wibox.container.place,
},
widget = wibox.container.place,
magins = dpi(10),
layout = wibox.container.margin,
},
magins = dpi(10),
layout = wibox.container.margin,
border_color = beautiful.colorscheme.border_color,
border_width = dpi(2),
shape = beautiful.shape[12],
widget = wibox.container.background,
},
border_color = beautiful.colorscheme.border_color,
border_width = dpi(2),
shape = beautiful.shape[12],
widget = wibox.container.background,
widget = wibox.container.constraint,
height = dpi(120),
width = dpi(500),
strategy = 'exact',
},
widget = wibox.container.constraint,
height = dpi(120),
width = dpi(500),
strategy = 'exact',
},
top = dpi(10),
left = dpi(20),
right = dpi(20),
bottom = dpi(10),
widget = wibox.container.margin,
}
end, })
top = dpi(10),
left = dpi(20),
right = dpi(20),
bottom = dpi(10),
widget = wibox.container.margin,
}
end,
})

View File

View File

@@ -10,6 +10,7 @@ local dpi = require('beautiful').xresources.apply_dpi
local gfilesystem = require('gears.filesystem')
local gtable = require('gears.table')
local wibox = require('wibox')
local gsurface = require('gears.surface')
local hover = require('src.tools.hover')
@@ -116,7 +117,7 @@ if instance == nil then
{
{
{
image = icondir .. 'defaultpfp.svg',
image = gsurface.load_uncached(gfilesystem.get_configuration_dir() .. 'src/assets/userpfp/userpfp.png'),
resize = true,
clip_shape = beautiful.shape[30],
valign = 'center',
@@ -192,13 +193,14 @@ if instance == nil then
-- Get the profile script from /var/lib/AccountsService/icons/${USER}
-- and copy it to the assets folder
-- TODO: If the user doesnt have AccountsService look into $HOME/.faces
aspawn.easy_async_with_shell("./.config/awesome/src/scripts/pfp.sh 'userPfp'", function(stdout)
--[[ aspawn.easy_async_with_shell("./.config/awesome/src/scripts/pfp.sh 'userPfp'", function(stdout)
print(stdout)
if stdout then
self.w:get_children_by_id('icon_role')[1].image = stdout:gsub('\n', '')
self.w:get_children_by_id('icon_role')[1].image = gsurface.load_uncached(gfilesystem.get_configuration_dir() .. 'src/assets/userpfp/userpfp.png')
else
self.w:get_children_by_id('icon_role')[1].image = icondir .. 'defaultpfp.svg'
end
end)
end) ]]
aspawn.easy_async_with_shell("./.config/awesome/src/scripts/pfp.sh 'userName' '" .. beautiful.user_config.namestyle .. "'", function(stdout)
self.w:get_children_by_id('text_role')[1].text = stdout:gsub('\n', '')

View File

@@ -5,7 +5,7 @@ case $1 in
"userPfp")
iconPath="/var/lib/AccountsService/icons/$USER"
userIconPath="$HOME/.config/awesome/src/assets/userpfp/"
userIconPath="../assets/userpfp/"
if [[ -f "$userIconPath" ]];
then

View File

@@ -0,0 +1,4 @@
#!/bin/bash
# First update the profile picture

View File

@@ -0,0 +1,91 @@
local setmetatable = setmetatable
local gtable = require('gears.table')
local gobject = require('gears.object')
local lgi = require('lgi')
local dbus_proxy = require('src.lib.lua-dbus_proxy.src.dbus_proxy')
local bluetooth = {}
function bluetooth:StartDiscovery()
self.Adapter1:StartDiscovery()
self:emit_signal('Bluetooth::DiscoveryStarted')
end
function bluetooth:StopDiscovery()
self.Adapter1:StopDiscovery()
self:emit_signal('Bluetooth::DiscoveryStopped')
end
function bluetooth:RemoveDevice(device)
if not device then return end
self.Adapter1:RemoveDevice(device)
end
function bluetooth:toggle_wifi()
local powered = not self.Adapter1.Powered
self.Adapter1:Set('org.bluez.Adapter1', 'Powered', lgi.GLib.Variant('b', powered))
self.Adapter1.Powered = {
signature = 'b',
value = powered,
}
end
return setmetatable(bluetooth, {
__call = function(self)
gtable.crush(self, gobject())
self.ObjectManager = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = 'org.bluez',
interface = 'org.freedesktop.DBus.ObjectManager',
path = '/',
}
self.Adapter1 = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = 'org.bluez',
interface = 'org.bluez.Adapter1',
path = '/org/bluez/hci0',
}
self.Adapter1Properties = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = 'org.bluez',
interface = 'org.freedesktop.DBus.Properties',
path = '/org/bluez/hci0',
}
self.Adapter1Properties:connect_signal(function(_, _, data)
if data.Powered ~= nil then
self:emit_signal('Bluetooth::Powered', data.Powered)
end
end, 'PropertiesChanged')
self.ObjectManager:connect_signal(function(_, path)
self:emit_signal('Bluetooth::DeviceAdded', path)
end, 'InterfacesAdded')
self.ObjectManager:connect_signal(function(_, path)
self:emit_signal('Bluetooth::DeviceRemoved', path)
end, 'InterfacesRemoved')
setmetatable(self, {
__index = function(_, key)
if key == 'Powered' then
return self.Adapter1.Powered
elseif key == 'Alias' then
return self.Adapter1.Alias
elseif key == 'PowerState' then
return self.Adapter1.PowerState
end
end,
})
return self
end,
})

View File

@@ -0,0 +1,88 @@
local setmetatable = setmetatable
local gtable = require('gears.table')
local gobject = require('gears.object')
local lgi = require('lgi')
local dbus_proxy = require('src.lib.lua-dbus_proxy.src.dbus_proxy')
local device = {}
function device:Connect()
self.Device1:ConnectAsync()
end
function device:Disconnect()
self.Device1:DisconnectAsync()
end
function device:Pair()
self.AgentManager1:RegisterAgent(self.Agent1.object_path, 'KeyboardDisplay')
self.Device1:PairAsync()
end
function device:CancelPair()
self.Device1:CancelPairAsync()
end
function device:Rename(newname)
self.Device1:Set('org.bluez.Device1', 'Alias', lgi.GLib.Variant('s', newname))
self.Device1.Alias = { signature = 's', value = newname }
return self.Device1:Get('org.bluez.Device1', 'Alias')
end
function device:ToggleTrusted()
local trusted = not self.Device1.Trusted
self.Device1:Set('org.bluez.Device1', 'Trusted', lgi.GLib.Variant('b', trusted))
self.Device1.Trusted = { signature = 'b', value = trusted }
end
return setmetatable(device, {
__call = function(_, path)
if not path then return end
local self = gobject {}
gtable.crush(self, device, true)
self.Device1 = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = 'org.bluez',
interface = 'org.bluez.Device1',
path = path,
}
if not self.Device1 then return end
self.Agent1 = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = 'org.bluez',
interface = 'org.bluez.Agent1',
path = '/org/bluez/agent',
}
self.AgentManager1 = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = 'org.bluez',
interface = 'org.bluez.AgentManager1',
path = '/org/bluez',
}
setmetatable(self, {
__index = function(_, key)
if key == 'Alias' then
return self.Device1.Alias
elseif key == 'Icon' then
return self.Device1.Icon
elseif key == 'Paired' then
return self.Device1.Paired
elseif key == 'Connected' then
return self.Device1.Connected
elseif key == 'Trusted' then
return self.Device1.Trusted
elseif key == 'RSSI' then
return self.Device1.RSSI
end
end,
})
return self
end,
})

View File

@@ -7,23 +7,31 @@ local Gtk = lgi.require('Gtk', '3.0')
local icon_lookup = {}
function icon_lookup:get_gicon_path(app, icon_string)
if (not app) and (not icon_string) then return end
if (not app) and (not icon_string) or not self.gtk_theme then return end
if icon_string then
return self.gtk_theme:lookup_icon(icon_string, 64, 0):get_filename() or ''
local icon = self.gtk_theme:lookup_icon(icon_string or "", 64, 0)
if icon then
return icon:get_filename() or ''
end
end
local icon_info = self.gtk_theme:lookup_by_gicon(app, 64, 0)
if icon_info then
return icon_info:get_filename()
if app then
local icon_info = self.gtk_theme:lookup_by_gicon(app, 64, 0)
if icon_info then
return icon_info:get_filename()
end
end
return nil
end
local instance = nil
if not instance then
instance = setmetatable(icon_lookup, {
__call = function(self, ...)
__call = function(self, theme_name,...)
self.gtk_theme = Gtk.IconTheme.get_default()
return self
end,
})

View File

@@ -6,43 +6,108 @@ local audio = {}
local instance = nil
function audio.set_sink_volume(volume)
aspawn('pactl set-sink-volume @DEFAULT_SINK@ ' .. volume .. '%')
function audio:set_sink_volume(volume)
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-sink-volume @DEFAULT_SINK@ ' .. volume .. '%', function()
self.allow_cmd = true
end)
end
function audio.set_source_volume(volume)
aspawn('pactl set-source-volume @DEFAULT_SOURCE@ ' .. volume .. '%')
function audio:set_source_volume(volume)
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-source-volume @DEFAULT_SOURCE@ ' .. volume .. '%', function()
self.allow_cmd = true
end)
end
function audio.sink_volume_up()
aspawn('pactl set-sink-volume @DEFAULT_SINK@ +2%')
function audio:sink_volume_up()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-sink-volume @DEFAULT_SINK@ +2%', function()
self.allow_cmd = true
end)
end
function audio.source_volume_up()
aspawn('pactl set-source-volume @DEFAULT_SOURCE@ +2%')
function audio:source_volume_up()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-source-volume @DEFAULT_SOURCE@ +2%', function()
self.allow_cmd = true
end)
end
function audio.sink_volume_down()
aspawn('pactl set-sink-volume @DEFAULT_SINK@ -2%')
function audio:sink_volume_down()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-sink-volume @DEFAULT_SINK@ -2%', function()
self.allow_cmd = true
end)
end
function audio.source_volume_down()
aspawn('pactl set-source-volume @DEFAULT_SOURCE@ -2%')
function audio:source_volume_down()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-source-volume @DEFAULT_SOURCE@ -2%', function()
self.allow_cmd = true
end)
end
function audio.sink_toggle_mute()
aspawn('pactl set-sink-mute @DEFAULT_SINK@ toggle')
function audio:sink_toggle_mute()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-sink-mute @DEFAULT_SINK@ toggle', function()
self.allow_cmd = true
end)
end
function audio.source_toggle_mute()
aspawn('pactl set-source-mute @DEFAULT_SOURCE@ toggle')
function audio:source_toggle_mute()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-source-mute @DEFAULT_SOURCE@ toggle', function()
self.allow_cmd = true
end)
end
function audio:sink_unmute()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-sink-mute @DEFAULT_SINK@ false', function()
self.allow_cmd = true
end)
end
function audio:sink_mute()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-sink-mute @DEFAULT_SINK@ true', function()
self.allow_cmd = true
end)
end
function audio:source_unmute()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('pactl set-source-mute @DEFAULT_SOURCE@ false', function()
self.allow_cmd = true
end)
end
function audio:source_mute()
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn('pactl set-source-mute @DEFAULT_SOURCE@ true', function()
self.allow_cmd = true
end)
end
local function new()
local self = gobject {}
gtable.crush(self, audio, true)
self.allow_cmd = true
aspawn.with_line_callback([[bash -c "LC_ALL=C pactl subscribe"]], {
stdout = function(line)
-- Volume changed

View File

@@ -1,6 +1,7 @@
local aspawn = require('awful.spawn')
local gobject = require('gears.object')
local gtable = require('gears.table')
local gtimer = require('gears.timer')
local backlight = {}
@@ -8,17 +9,25 @@ local instance = nil
function backlight.brightness_get_async(callback)
aspawn.easy_async_with_shell('brightnessctl get', function(stdout)
callback(tonumber(stdout:gsub('\n', '')))
callback(stdout:gsub('\n', ''))
end)
end
function backlight:brightness_increase()
aspawn('brightnessctl set 2+%')
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('brightnessctl set 2+%', function()
self.allow_cmd = true
end)
self:emit_signal('brightness_changed')
end
function backlight:brightness_decrease()
aspawn('brightnessctl set 2-%')
if not self.allow_cmd then return end
self.allow_cmd = false
aspawn.easy_async_with_shell('brightnessctl set 2-%', function()
self.allow_cmd = true
end)
self:emit_signal('brightness_changed')
end
@@ -32,6 +41,11 @@ local function new()
self.max_brightness = tonumber(stdout:gsub('\n', '') or 1)
end)
-- Function locker to avoid spawning more commands than can be processed at a time
self.allow_cmd = true
self:emit_signal('brightness_changed')
return self
end

View File

@@ -1,15 +1,38 @@
local awatch = require('awful.widget.watch')
local aspawn = require('awful.spawn')
local gobject = require('gears.object')
local instance
local json = require('src.lib.json-lua.json-lua')
local function new()
local self = gobject {}
awatch([[ bash -c "nvidia-smi -q -d UTILIZATION | grep Gpu | awk '{print $3}'"]], 3, function(_, stdout)
stdout = stdout:match('%d+')
if not stdout then return end
self:emit_signal('update::gpu_usage', stdout)
aspawn.easy_async_with_shell([[ lspci | grep ' VGA ' | cut -d" " -f 1 ]], function(stdout)
if stdout:match('00:03.0') then -- Nvidia
awatch([[ bash -c "nvidia-smi -q -d UTILIZATION | grep Gpu | awk '{print $3}'"]], 3, function(_, stdout)
stdout = stdout:match('%d+')
if not stdout then return end
self:emit_signal('update::gpu_usage', stdout)
end)
elseif stdout:match('00:02.0') then -- Intel
awatch([[ bash -c "intel_gpu_top -J & sleep 1 && pkill intel_gpu_top" ]], 3, function(_, stdout)
local gpu_data = json:decode('[' .. stdout:gsub('/', '') .. ']')[2]
if not gpu_data or type(gpu_data) ~= table then return end
local gpu_usage = (gpu_data.engines.Render3D0.busy +
gpu_data.engines.Blitter0.busy +
gpu_data.engines.Video0.busy +
gpu_data.engines.VideoEnhance0.busy) / 4
self:emit_signal('update::gpu_usage', math.floor(gpu_usage + 0.5))
end)
elseif stdout:match('00:01.0') then -- AMD
-- AMD
end
end)
return self
end

View File

@@ -30,7 +30,7 @@ local function overlay_color(col, overlay, opacity)
end
local function bg_hover(args)
--[[ args = args or {}
--[[ args = args or {}
local old_cursor, old_wibox
local _, r, g, b, a = args.widget.bg:get_rgba()

View File

@@ -0,0 +1,60 @@
local setmetatable = setmetatable
local aspawn = require("awful.spawn")
local lgi = require('lgi')
local cairo = lgi.cairo
local gfilesystem = require('gears.filesystem')
local gsurface = require('gears.surface')
local gtable = require('gears.table')
local gobject = require('gears.object')
--[[
Preload all external image or svg files as cairo surfaces and return them,
if no icon is found an empty surface is returned
]]
local cache = {}
local ret = {}
local instance = nil
if not instance then
instance = setmetatable(ret, {
__call = function()
gtable.crush(ret, gobject{}, true)
local icon_path = gfilesystem.get_configuration_dir() .. 'src/assets/icons/'
local layout_path = gfilesystem.get_configuration_dir() .. 'src/assets/layout/'
aspawn.easy_async_with_shell('ls -a "' .. icon_path .. '"', function(stdout)
for str in stdout:gmatch("([^\n]*)\n?") do
if str ~= "" and str ~= "." and str ~= ".." then
local surface = cairo.ImageSurface(cairo.ARGB, 64, 64)
cache[str] = surface
end
end
ret:emit_signal("done")
end)
aspawn.easy_async_with_shell('ls -a "' .. layout_path .. '"', function(stdout)
for str in stdout:gmatch("([^\n]*)\n?") do
if str ~= "" and str ~= "." and str ~= ".." then
local surface = cairo.ImageSurface(cairo.ARGB, 64, 64)
cache[str] = surface
end
end
end)
return ret
end,
__index = function(self,key)
print(key, cache[key])
if key and cache[key] then
print("test")
return cache[key]
elseif(key == "user_image") or (key == "background") or (key == "os_logo") then
return cache[key]
else
--return cairo.ImageSurface()
end
end
})
end
return instance

7
awesome_crylia.desktop Normal file
View File

@@ -0,0 +1,7 @@
[Desktop Entry]
Name=Awesome Crylia Theme
Comment=Crylia Theme for AwesomeWM
TryExec=sh -c "awesome_crylia -c $HOME/.config/crylia_theme/rc.lua"
Exec=sh -c "/usr/local/bin/awesome_crylia -c $HOME/.config/crylia_theme/rc.lua"
Type=Application

96
install.sh Normal file
View File

@@ -0,0 +1,96 @@
#!/bin/bash
echo "
╭─────────────────────────────────────────────────────────────────╮
│ ______ ___ ________ │
│ / ____/______ __/ (_)___ _ /_ __/ /_ ___ ____ ___ ___ │
│ / / / ___/ / / / / / __ `/ / / / __ \/ _ \/ __ `__ \/ _ \ │
│ / /___/ / / /_/ / / / /_/ / / / / / / / __/ / / / / / __/ │
│ \____/_/ \__, /_/_/\__,_/ /_/ /_/ /_/\___/_/ /_/ /_/\___/ │
│ /____/ │
╰─────────────────────────────────────────────────────────────────╯
"
if (($EUID != 0)); then
echo "ERROR: Please run as root!\n"
exit
fi
# Try to install dependencies
if [whereis apt | awk '{print $2}' = "*apt"]; then
apt update && apt install libconfig-dev libdbus-1-dev libegl-dev libev-dev libgl-dev libpcre2-dev libpixman-1-dev libx11-xcb-dev libxcb1-dev libxcb-composite0-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-glx0-dev libxcb-image0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-util-dev libxcb-xfixes0-dev libxext-dev meson ninja-build uthash-dev
else if [whereis pacman | awk '{print $2}' = "*apt"]; then
pacman -Suy
fi
CONFIG_PATH="$HOME/.config";
DESKTOP_FILE="awesome_crylia.desktop";
SESSION_PATH="/usr/share/xsessions";
# Copy the desktop file to the xsessions folder
cp $DESKTOP_FILE "$SESSION_PATH/$DESKTOP_FILE"
# Check if the file got copied
if ![ -f "$SESSION_PATH/$DESKTOP_FILE"]; then
printf '%c' "ERROR: Couldn't copy .desktop file";
fi
function y_or_n {
while true; do
read -p "$* [Y/N]: " yn
case $yn in
[Yy]*) return 1;;
[Nn]*) return 0;;
esac
done
}
# $1 the folder that should be backuped
# $2 the new backup folder name
# $3 the file to copy to $1
function backup_and_copy {
if [-d "$1"]; then
cp -r "$1" "$2"
if [-d "$2"]; then
rm -r "$1"
else
if (yes_or_no "WARNING: Couldn't create backup of $1, continue?" == 0); then
echo "Aborted";
exit -1;
fi
fi
fi
cp -r "$3 $1"
if ![-d "$1"]; then
echo "ERROR: Couldn't copy $3 to $1"
fi
}
backup_and_copy "$CONFIG_PATH/crylia_theme" "$CONFIG_PATH/crylia_theme_backup" "awesome"
backup_and_copy "$CONFIG_PATH/kitty" "$CONFIG_PATH/kitty_backup" "kitty"
backup_and_copy "$CONFIG_PATH/starship.toml" "$CONFIG_PATH/starship.toml.backup" "starship.toml"
# Clone, build and install my awesome fork
git clone https://github.com/Crylia/awesome /tmp
cd /tmp/awesome
make
make install
rm -rf /tmp/awesome
while true; do
read -p "Would you like to install my neofetch config? [Y/N]: " yn
if (($yn == [Yy*])); then
backup_and_copy "$CONFIG_PATH/neofetch" "$CONFIG_PATH/neofetch_backup" "neofetch"
fi
done
# Clone, build and install picom
git clone https://github.com/yshui/picom.git /tmp
meson setup --buildtype=release build
ninja -C build
ninja -C build install
rm -rf /tmp/picom