Huge refractor and many fixes for dock, icons(again) etc

This commit is contained in:
Kievits Rene
2022-04-18 13:29:50 +02:00
parent adcc361891
commit b1a4b38024
123 changed files with 925 additions and 1019 deletions

View File

@@ -0,0 +1,221 @@
---------------------------------------
-- This is the brightness_osd module --
---------------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("src.theme.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
-- Icon directory path
local icondir = awful.util.getdir("config") .. "src/assets/icons/brightness/"
-- TODO: fix backlight keys and osd not working correctly
return function(s)
local brightness_osd_widget = wibox.widget {
{
{
{
{
nil,
{
nil,
{
id = "icon",
forced_height = dpi(220),
image = icondir .. "brightness-high.svg",
widget = wibox.widget.imagebox
},
nil,
expand = "none",
id = "icon_margin2",
layout = wibox.layout.align.vertical
},
nil,
id = "icon_margin1",
expand = "none",
layout = wibox.layout.align.horizontal
},
{
{
id = "label",
text = "Brightness",
align = "left",
valign = "center",
widget = wibox.widget.textbox
},
nil,
{
id = "value",
text = "0%",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
id = "label_value_layout",
forced_height = dpi(48),
layout = wibox.layout.align.horizontal,
},
{
{
id = "brightness_slider",
bar_shape = gears.shape.rounded_rect,
bar_height = dpi(10),
bar_color = color["Grey800"] .. "88",
bar_active_color = "#ffffff",
handle_color = "#ffffff",
handle_shape = gears.shape.circle,
handle_width = dpi(10),
handle_border_color = color["White"],
maximum = 100,
widget = wibox.widget.slider
},
id = "slider_layout",
forced_height = dpi(24),
widget = wibox.container.place
},
id = "icon_slider_layout",
spacing = dpi(0),
layout = wibox.layout.align.vertical
},
id = "osd_layout",
layout = wibox.layout.align.vertical
},
id = "container",
left = dpi(24),
right = dpi(24),
widget = wibox.container.margin
},
bg = color["Grey900"] .. "88",
widget = wibox.container.background,
ontop = true,
visible = true,
type = "notification",
forced_height = dpi(300),
forced_width = dpi(300),
offset = dpi(5),
}
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:connect_signal(
"property::value",
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 keymappings
--awful.spawn("xbacklight -set " .. brightness_value, false)
brightness_osd_widget.container.osd_layout.icon_slider_layout.label_value_layout.value:set_text(brightness_value .. "%")
awesome.emit_signal(
"widget::brightness:update",
brightness_value
)
if awful.screen.focused().show_brightness_osd then
awesome.emit_signal(
"module::brightness_osd:show",
true
)
end
local icon = icondir .. "brightness"
if brightness_value >= 0 and brightness_value < 34 then
icon = icon .. "-low"
elseif brightness_value >= 34 and brightness_value < 67 then
icon = icon .. "-medium"
elseif brightness_value >= 67 then
icon = icon .. "-high"
end
brightness_osd_widget.container.osd_layout.icon_slider_layout.icon_margin1.icon_margin2.icon:set_image(icon .. ".svg")
end
)
local update_slider = function()
awful.spawn.easy_async_with_shell(
[[ sleep 0.1 && xbacklight -get ]],
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
)
end
awesome.connect_signal(
"module::brightness_slider:update",
function()
update_slider()
end
)
awesome.connect_signal(
"widget::brightness:update",
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 {
widget = wibox.container.background,
ontop = true,
bg = 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)
end
}
local hide_brightness_osd = gears.timer {
timeout = 2,
autostart = true,
callback = function()
brightness_container.visible = false
end
}
brightness_container:setup {
brightness_osd_widget,
layout = wibox.layout.fixed.horizontal
}
awesome.connect_signal(
"widget::brightness_osd:rerun",
function()
if hide_brightness_osd.started then
hide_brightness_osd:again()
else
hide_brightness_osd:start()
end
end
)
awesome.connect_signal(
"module::brightness_osd:show",
function()
if s == mouse.screen then
brightness_container.visible = true
end
end
)
brightness_container:connect_signal(
"mouse::enter",
function()
brightness_container.visible = true
hide_brightness_osd:stop()
end
)
brightness_container:connect_signal(
"mouse::leave",
function()
brightness_container.visible = true
hide_brightness_osd:again()
end
)
end

View File

@@ -0,0 +1,183 @@
---------------------------------------
-- This is the calendar_osd module --
---------------------------------------
-- Awesome Libs
local awful = require("awful")
local wibox = require("wibox")
local gears = require("gears")
local dpi = require("beautiful").xresources.apply_dpi
local color = require("src.theme.colors")
return function(s)
local styles = {}
styles.month = {
padding = 15,
bg_color = color["Grey900"],
border_width = 1,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end
}
styles.normal = {
fg_color = color["Grey900"],
font = user_vars.font.extrabold,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end
}
styles.focus = {
fg_color = color["Grey900"],
bg_color = color["Purple200"],
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end
}
styles.header = {
fg_color = color["Grey900"],
bg_color = color["Teal200"],
markup = function(t) return '<b>' .. t .. '</b>' end,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end
}
styles.weekday = {
padding = 8,
fg_color = color["Grey900"],
bg_color = color["Teal200"],
markup = function(t) return '<b>' .. t .. '</b>' end,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end
}
local function decorate_cell(widget, flag, date)
if flag == 'monthheader' and not styles.monthheader then
flag = 'header'
end
local props = styles[flag] or {}
if props.markup and widget.get_text and widget.set_markup then
widget:set_markup(props.markup(widget:get_text()))
end
-- Change bg color for weekends
local d = { year = date.year, month = (date.month or 1), day = (date.day or 1) }
local weekday = tonumber(os.date('%w', os.time(d)))
local default_bg = (weekday == 0 or weekday == 6) and color["Red200"] or color["White"]
local ret = wibox.widget {
{
widget,
left = dpi(8),
right = dpi(8),
top = dpi(4),
bottom = dpi(4),
widget = wibox.container.margin
},
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end,
fg = props.fg_color or '#999999',
bg = props.bg_color or default_bg,
widget = wibox.container.background
}
return ret
end
local calendar = wibox.widget {
date = os.date('*t'),
fn_embed = decorate_cell,
widget = wibox.widget.calendar.month,
font = user_vars.font.extrabold,
spacing = dpi(10)
}
local calendar_osd_widget = wibox.widget {
{
widget = wibox.widget.textbox,
fg = "#ffffff",
align = "center",
valign = "center",
font = "DS-Digital, Bold Italic 50",
id = "digital_clock"
},
{
widget = calendar
},
visible = true,
layout = wibox.layout.fixed.vertical
}
local set_clock = function()
calendar_osd_widget.digital_clock:set_text(os.date("%H:%M"))
end
local calendar_clock_update = gears.timer {
timeout = 5,
autostart = true,
call_now = true,
callback = function()
set_clock()
end
}
local calendar_osd_container = awful.popup {
screen = s,
widget = wibox.container.background,
ontop = true,
bg = color["Grey900"],
stretch = false,
visible = false,
placement = function(c) awful.placement.top_right(c, { margins = { right = dpi(100), top = dpi(60) } }) end,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
end
}
local hide_osd = gears.timer {
timeout = 0.25,
autostart = true,
callback = function()
calendar_osd_container.visible = false
end
}
calendar_osd_container:setup {
calendar_osd_widget,
layout = wibox.layout.align.horizontal
}
calendar_osd_container:connect_signal(
"mouse::enter",
function()
calendar_osd_container.visible = true
hide_osd:stop()
end
)
calendar_osd_container:connect_signal(
"mouse::leave",
function()
calendar_osd_container.visible = false
hide_osd:stop()
end
)
awesome.connect_signal(
"widget::calendar_osd:stop",
function()
calendar_osd_container.visible = true
hide_osd:stop()
end
)
awesome.connect_signal(
"widget::calendar_osd:rerun",
function()
if hide_osd.started then
hide_osd:again()
else
hide_osd:start()
end
end
)
end

View File

@@ -0,0 +1,320 @@
--------------------------------
-- This is the network widget --
--------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("src.theme.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
require("src.core.signals")
-- Icon directory path
local icondir = awful.util.getdir("config") .. "src/assets/icons/powermenu/"
return function(s)
-- Profile picture imagebox
local profile_picture = wibox.widget {
image = icondir .. "defaultpfp.svg",
resize = true,
forced_height = dpi(200),
clip_shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 30)
end,
widget = wibox.widget.imagebox
}
-- Username textbox
local profile_name = wibox.widget {
align = 'center',
valign = 'center',
text = " ",
font = "JetBrains Mono Bold 30",
widget = wibox.widget.textbox
}
-- 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
local update_profile_picture = function()
awful.spawn.easy_async_with_shell(
[=[
iconPath="/var/lib/AccountsService/icons/${USER}"
userIconPath="${HOME}/.config/awesome/src/assets/userpfp/"
if [[ -f "${userIconPath}" ]];
then
if [[ -f "${iconPath}" ]];
then
if ! cmp --silent "${userIconPath}.png" "${iconPath}";
then
cp "${iconPath}" "${userIconPath}${USER}.png"
fi
printf "${userIconPath}.png"
else
printf "${userIconPath}.png"
fi
exit;
else
if [[ -f "${iconPath}" ]];
then
cp "${iconPath}" "${userIconPath}${USER}.png"
printf "${userIconPath}${USER}.png"
exit;
fi
fi
]=],
function(stdout)
if stdout then
profile_picture:set_image(stdout:gsub("\n", ""))
else
profile_picture:set_image(icondir .. "defaultpfp.svg")
end
end
)
end
update_profile_picture()
-- Will determin the display style
local namestyle = user_vars.namestyle
-- Get the full username(if set) and the username + hostname
local update_user_name = function()
awful.spawn.easy_async_with_shell(
[=[
fullname="$(getent passwd `whoami` | cut -d ':' -f 5)"
user="$(whoami)"
host="$(hostname)"
if [[ "]=] .. namestyle .. [=[" == "userhost" ]];
then
printf "$user@$host"
elif [[ "]=] .. namestyle .. [=[" == "fullname" ]];
then
printf "$fullname"
else
printf "Rick Astley"
fi
]=],
function(stdout)
if stdout:gsub("\n", "") == "Rick Astley" then
profile_picture:set_image(awful.util.getdir("config") .. "src/assets/userpfp/" .. "rickastley.jpg")
end
profile_name:set_text(stdout)
end
)
end
update_user_name()
-- Universal Button widget
local button = function(name, icon, bg_color, callback)
local item = wibox.widget {
{
{
{
{
{
-- TODO: using gears.color to recolor a SVG will make it look super low res
-- currently I recolor it in the .svg file directly, but later implement
-- a better way to recolor a SVG
-- image = gears.color.recolor_image(icon, color["Grey900"]),
image = icon,
resize = true,
forced_height = dpi(30),
widget = wibox.widget.imagebox
},
margins = dpi(0),
widget = wibox.container.margin
},
{
{
text = name,
font = "JetBrains Mono Bold 30",
widget = wibox.widget.textbox
},
margins = dpi(0),
widget = wibox.container.margin
},
widget = wibox.layout.fixed.horizontal
},
margins = dpi(10),
widget = wibox.container.margin
},
fg = color["Grey900"],
bg = bg_color,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 10)
end,
widget = wibox.container.background,
id = 'background'
},
spacing = dpi(0),
layout = wibox.layout.align.vertical
}
item:connect_signal(
"button::release",
function()
callback()
end
)
return item
end
-- Create the power menu actions
local suspend_command = function()
awful.spawn("dm-tool lock & systemctl suspend")
awesome.emit_signal("module::powermenu:hide")
end
local logout_command = function()
awesome.quit()
end
local lock_command = function()
awful.spawn("dm-tool lock")
awesome.emit_signal("module::powermenu:hide")
end
local shutdown_command = function()
awful.spawn("shutdown now")
awesome.emit_signal("module::powermenu:hide")
end
local reboot_command = function()
awful.spawn("reboot")
awesome.emit_signal("module::powermenu:hide")
end
-- Create the buttons with their command and name etc
local shutdown_button = button("Shutdown", icondir .. "shutdown.svg", color["Blue200"], shutdown_command)
local reboot_button = button("Reboot", icondir .. "reboot.svg", color["Red200"], reboot_command)
local suspend_button = button("Suspend", icondir .. "suspend.svg", color["Yellow200"], suspend_command)
local logout_button = button("Logout", icondir .. "logout.svg", color["Green200"], logout_command)
local lock_button = button("Lock", icondir .. "lock.svg", color["Orange200"], lock_command)
-- Signals to change color on hover
Hover_signal(shutdown_button.background, color["Blue200"])
Hover_signal(reboot_button.background, color["Red200"])
Hover_signal(suspend_button.background, color["Yellow200"])
Hover_signal(logout_button.background, color["Green200"])
Hover_signal(lock_button.background, color["Orange200"])
-- The powermenu widget
local powermenu = wibox.widget {
layout = wibox.layout.align.vertical,
expand = "none",
nil,
{
{
nil,
{
{
nil,
{
nil,
{
profile_picture,
margins = dpi(0),
widget = wibox.container.margin
},
nil,
expand = "none",
layout = wibox.layout.align.horizontal
},
nil,
layout = wibox.layout.align.vertical,
expand = "none"
},
spacing = dpi(50),
{
profile_name,
margins = dpi(0),
widget = wibox.container.margin
},
layout = wibox.layout.fixed.vertical
},
nil,
expand = "none",
layout = wibox.layout.align.horizontal
},
{
nil,
{
{
shutdown_button,
reboot_button,
logout_button,
lock_button,
suspend_button,
spacing = dpi(30),
layout = wibox.layout.fixed.horizontal
},
margins = dpi(0),
widget = wibox.container.margin
},
nil,
expand = "none",
layout = wibox.layout.align.horizontal
},
layout = wibox.layout.align.vertical
},
nil
}
-- Container for the widget, covers the entire screen
local powermenu_container = wibox {
widget = powermenu,
screen = s,
type = "splash",
visible = false,
ontop = true,
bg = "#21212188",
height = s.geometry.height,
width = s.geometry.width,
x = s.geometry.x,
y = s.geometry.y
}
-- Close on rightclick
powermenu_container:buttons(
gears.table.join(
awful.button(
{},
3,
function()
awesome.emit_signal("module::powermenu:hide")
end
)
)
)
-- Close on Escape
local powermenu_keygrabber = awful.keygrabber {
autostart = false,
stop_event = 'release',
keypressed_callback = function(self, mod, key, command)
if key == 'Escape' then
awesome.emit_signal("module::powermenu:hide")
end
end
}
-- Signals
awesome.connect_signal(
"module::powermenu:show",
function()
powermenu_container.visible = false
powermenu_container.visible = true
powermenu_keygrabber:start()
end
)
awesome.connect_signal(
"module::powermenu:hide",
function()
powermenu_keygrabber:stop()
powermenu_container.visible = false
end
)
end

View File

@@ -0,0 +1,327 @@
-----------------------------------
-- This is the titlebar module --
-----------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("src.theme.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
require("src.core.signals")
-- Icon directory path
local icondir = awful.util.getdir("config") .. "src/assets/icons/titlebar/"
awful.titlebar.enable_tooltip = true
awful.titlebar.fallback_name = 'Client'
local double_click_event_handler = function(double_click_event)
if double_click_timer then
double_click_timer:stop()
double_click_timer = nil
double_click_event()
return
end
double_click_timer = gears.timer.start_new(
0.20,
function()
double_click_timer = nil
return false
end
)
end
local create_click_events = function(c)
local buttons = gears.table.join(
awful.button(
{},
1,
function()
double_click_event_handler(function()
if c.floating then
c.float = false
return
end
c.maximized = not c.maximized
c:raise()
end)
c:activate { context = 'titlebar', action = 'mouse_move' }
end
),
awful.button(
{},
3,
function()
c:activate { context = 'titlebar', action = 'mouse_resize' }
end
)
)
return buttons
end
local createresize_click_events = function(c)
local buttons = gears.table.join(
awful.button(
{},
1,
function()
c:activate { context = 'titlebar', action = 'mouse_resize' }
end
)
)
return buttons
end
local create_titlebar = function(c, bg, size)
local titlebar = awful.titlebar(c, {
position = "left",
bg = bg,
size = size
})
titlebar:setup {
{
{
{
awful.titlebar.widget.closebutton(c),
widget = wibox.container.background,
bg = color["Red200"],
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, 4)
end,
id = "closebutton"
},
{
awful.titlebar.widget.maximizedbutton(c),
widget = wibox.container.background,
bg = color["Yellow200"],
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, 4)
end,
id = "maximizebutton"
},
{
awful.titlebar.widget.minimizebutton(c),
widget = wibox.container.background,
bg = color["Green200"],
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, 4)
end,
id = "minimizebutton"
},
spacing = dpi(10),
layout = wibox.layout.fixed.vertical,
id = "spacing"
},
margins = dpi(8),
widget = wibox.container.margin,
id = "margin"
},
{
buttons = create_click_events(c),
layout = wibox.layout.flex.vertical
},
{
{
widget = awful.widget.clienticon(c)
},
margins = dpi(5),
widget = wibox.container.margin
},
layout = wibox.layout.align.vertical,
id = "main"
}
Hover_signal(titlebar.main.margin.spacing.closebutton, color["Red200"])
Hover_signal(titlebar.main.margin.spacing.maximizebutton, color["Yellow200"])
Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"])
end
local create_titlebar_dialog = function(c, bg, size)
local titlebar = awful.titlebar(c, {
position = "left",
bg = bg,
size = size
})
titlebar:setup {
{
{
{
awful.titlebar.widget.closebutton(c),
widget = wibox.container.background,
bg = color["Red200"],
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, 4)
end,
id = "closebutton"
},
{
awful.titlebar.widget.minimizebutton(c),
widget = wibox.container.background,
bg = color["Green200"],
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, 4)
end,
id = "minimizebutton"
},
spacing = dpi(10),
layout = wibox.layout.fixed.vertical,
id = "spacing"
},
margins = dpi(8),
widget = wibox.container.margin,
id = "margin"
},
{
buttons = create_click_events(c),
layout = wibox.layout.flex.vertical
},
{
{
widget = awful.widget.clienticon(c)
},
margins = dpi(5),
widget = wibox.container.margin
},
layout = wibox.layout.align.vertical,
id = "main"
}
Hover_signal(titlebar.main.margin.spacing.closebutton, color["Red200"])
Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"])
end
local create_titlebar_borderhack = function(c, bg, position)
local borderhack = awful.titlebar(c, {
position = position,
bg = bg,
size = "4"
})
borderhack:setup {
{
bg = bg,
widget = wibox.container.background
},
{
buttons = createresize_click_events(c),
layout = wibox.layout.flex.vertical
},
nil,
layout = wibox.layout.align.vertical
}
local old_wibox, old_cursor
borderhack:connect_signal(
"mouse::enter",
function()
local w = mouse.current_client
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
borderhack:connect_signal(
"mouse::leave",
function()
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
)
end
local draw_titlebar = function(c)
if c.type == 'normal' and not c.requests_no_titlebar then
create_titlebar_borderhack(c, "#121212AA", "right")
create_titlebar_borderhack(c, "#121212AA", "top")
create_titlebar_borderhack(c, "#121212AA", "bottom")
if c.class == 'Firefox' then
create_titlebar(c, '#121212AA', 35)
elseif c.name == "Steam" then
create_titlebar(c, '#121212AA', 0)
elseif c.name == "Settings" then
create_titlebar(c, '#121212AA', 0)
elseif c.class == "gcr-prompter" or c.class == "Gcr-prompter" then
create_titlebar(c, '#121212AA', 0)
else
create_titlebar(c, '#121212AA', 35)
end
elseif c.type == 'dialog' then
create_titlebar_dialog(c, '#121212AA', 35)
create_titlebar_borderhack(c, "#121212AA", "right")
create_titlebar_borderhack(c, "#121212AA", "top")
create_titlebar_borderhack(c, "#121212AA", "bottom")
elseif c.type == 'modal' then
else
create_titlebar_borderhack(c, "#121212AA", "right")
create_titlebar_borderhack(c, "#121212AA", "top")
create_titlebar_borderhack(c, "#121212AA", "bottom")
create_titlebar_borderhack(c, "#121212AA", "left")
end
end
client.connect_signal(
"property::maximized",
function(c)
if c.maximized then
Theme.titlebar_maximized_button_normal = icondir .. "unmaximize.svg"
Theme.titlebar_maximized_button_active = icondir .. "unmaximize.svg"
Theme.titlebar_maximized_button_inactive = icondir .. "unmaximize.svg"
elseif not c.minimized then
Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg"
Theme.titlebar_maximized_button_active = icondir .. "maximize.svg"
Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg"
end
end
)
client.connect_signal(
"request::titlebars",
function(c)
if c.maximized then
Theme.titlebar_maximized_button_normal = icondir .. "unmaximize.svg"
Theme.titlebar_maximized_button_active = icondir .. "unmaximize.svg"
Theme.titlebar_maximized_button_inactive = icondir .. "unmaximize.svg"
elseif not c.minimized then
Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg"
Theme.titlebar_maximized_button_active = icondir .. "maximize.svg"
Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg"
end
draw_titlebar(c)
if not c.floating or c.maximized then
awful.titlebar.hide(c, 'left')
awful.titlebar.hide(c, 'right')
awful.titlebar.hide(c, 'top')
awful.titlebar.hide(c, 'bottom')
end
end
)
client.connect_signal(
'property::floating',
function(c)
if c.floating and not c.maximized then
if c.class == "Steam" then
awful.titlebar.hide(c, 'left')
awful.titlebar.hide(c, 'right')
awful.titlebar.hide(c, 'top')
awful.titlebar.hide(c, 'bottom')
else
awful.titlebar.show(c, 'left')
awful.titlebar.show(c, 'right')
awful.titlebar.show(c, 'top')
awful.titlebar.show(c, 'bottom')
end
else
awful.titlebar.hide(c, 'left')
awful.titlebar.hide(c, 'right')
awful.titlebar.hide(c, 'top')
awful.titlebar.hide(c, 'bottom')
end
end
)

View File

@@ -0,0 +1,242 @@
-----------------------------------
-- This is the volume_old module --
-----------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("src.theme.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
-- Icon directory path
local icondir = awful.util.getdir("config") .. "src/assets/icons/audio/"
-- Returns the volume_osd
return function(s)
local volume_osd_widget = wibox.widget {
{
{
{
{
nil,
{
nil,
{
id = "icon",
forced_height = dpi(220),
image = icondir .. "volume-high.svg",
widget = wibox.widget.imagebox
},
nil,
expand = "none",
id = "icon_margin2",
layout = wibox.layout.align.vertical
},
nil,
id = "icon_margin1",
expand = "none",
layout = wibox.layout.align.horizontal
},
{
{
id = "label",
text = "Volume",
align = "left",
valign = "center",
widget = wibox.widget.textbox
},
nil,
{
id = "value",
text = "0%",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
id = "label_value_layout",
forced_height = dpi(48),
layout = wibox.layout.align.horizontal,
},
{
{
id = "volume_slider",
bar_shape = gears.shape.rounded_rect,
bar_height = dpi(10),
bar_color = color["Grey800"] .. "88",
bar_active_color = "#ffffff",
handle_color = "#ffffff",
handle_shape = gears.shape.circle,
handle_width = dpi(10),
handle_border_color = color["White"],
maximum = 100,
widget = wibox.widget.slider
},
id = "slider_layout",
forced_height = dpi(24),
widget = wibox.container.place
},
id = "icon_slider_layout",
spacing = dpi(0),
layout = wibox.layout.align.vertical
},
id = "osd_layout",
layout = wibox.layout.align.vertical
},
id = "container",
left = dpi(24),
right = dpi(24),
widget = wibox.container.margin
},
bg = color["Grey900"] .. '88',
widget = wibox.container.background,
ontop = true,
visible = true,
type = "notification",
forced_height = dpi(300),
forced_width = dpi(300),
offset = dpi(5),
}
local function update_osd()
local volume_level = volume_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.volume_slider:get_value()
awesome.emit_signal("widget::volume")
volume_osd_widget.container.osd_layout.icon_slider_layout.label_value_layout.value:set_text(volume_level .. "%")
awesome.emit_signal(
"widget::volume:update",
volume_level
)
if awful.screen.focused().show_volume_osd then
awesome.emit_signal(
"module::volume_osd:show",
true
)
end
local icon = icondir .. "volume"
if volume_level < 1 then
icon = icon .. "-mute"
elseif volume_level >= 1 and volume_level < 34 then
icon = icon .. "-low"
elseif volume_level >= 34 and volume_level < 67 then
icon = icon .. "-medium"
elseif volume_level >= 67 then
icon = icon .. "-high"
end
volume_osd_widget.container.osd_layout.icon_slider_layout.icon_margin1.icon_margin2.icon:set_image(icon .. ".svg")
end
volume_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.volume_slider:connect_signal(
"property::value",
function()
update_osd()
end
)
local update_slider = function()
awful.spawn.easy_async_with_shell(
[[ pacmd list-sinks | grep "muted" ]],
function(stdout)
if stdout:match("yes") then
volume_osd_widget.container.osd_layout.icon_slider_layout.label_value_layout.value:set_text("0%")
volume_osd_widget.container.osd_layout.icon_slider_layout.icon_margin1.icon_margin2.icon:set_image(icondir .. "volume-mute" .. ".svg")
else
awful.spawn.easy_async_with_shell(
[[
SINK="$(pacmd stat | awk -F": " '/^Default sink name: /{print $2}')"
echo $(pacmd list-sinks | awk '/^\s+name: /{indefault = $2 == "<'$SINK'>"} /^\s+volume: / && indefault {print $5; exit}')
]],
function(stdout2)
stdout2 = stdout2:sub(1, -3)
volume_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.volume_slider:set_value(tonumber(stdout2))
update_osd()
end
)
end
end
)
end
-- Signals
awesome.connect_signal(
"module::slider:update",
function()
update_slider()
end
)
awesome.connect_signal(
"widget::volume:update",
function(value)
volume_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.volume_slider:set_value(tonumber(value))
end
)
update_slider()
local volume_container = awful.popup {
widget = wibox.container.background,
ontop = true,
bg = 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)
end
}
local hide_volume_osd = gears.timer {
timeout = 2,
autostart = true,
callback = function()
volume_container.visible = false
end
}
volume_container:setup {
volume_osd_widget,
layout = wibox.layout.fixed.horizontal
}
awesome.connect_signal(
"module::volume_osd:show",
function()
if s == mouse.screen then
volume_container.visible = true
end
end
)
volume_container:connect_signal(
"mouse::enter",
function()
volume_container.visible = true
hide_volume_osd:stop()
end
)
volume_container:connect_signal(
"mouse::leave",
function()
volume_container.visible = true
hide_volume_osd:again()
end
)
awesome.connect_signal(
"widget::volume_osd:rerun",
function()
if hide_volume_osd.started then
hide_volume_osd:again()
else
hide_volume_osd:start()
end
end
)
end