This commit is contained in:
Rene Kievits
2022-12-08 16:06:16 +01:00
parent 675ab6692d
commit 42a888c311
68 changed files with 732 additions and 2238 deletions

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6,19C6,20.1 6.9,21 8,21H16C17.1,21 18,20.1 18,19V7H6V19M8,9H16V19H8V9M15.5,4L14.5,3H9.5L8.5,4H5V6H19V4H15.5Z" /></svg>

After

Width:  |  Height:  |  Size: 188 B

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14.06,9L15,9.94L5.92,19H5V18.08L14.06,9M17.66,3C17.41,3 17.15,3.1 16.96,3.29L15.13,5.12L18.88,8.87L20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18.17,3.09 17.92,3 17.66,3M14.06,6.19L3,17.25V21H6.75L17.81,9.94L14.06,6.19Z" /></svg>

After

Width:  |  Height:  |  Size: 305 B

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24">
<path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" />
</svg>

After

Width:  |  Height:  |  Size: 539 B

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24">
<path d="M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.43 19.12,14.63 17.79,15L19.25,16.44C20.88,15.61 22,13.95 22,12A5,5 0 0,0 17,7M16,11H13.81L15.81,13H16V11M2,4.27L5.11,7.38C3.29,8.12 2,9.91 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12C3.9,10.41 5.11,9.1 6.66,8.93L8.73,11H8V13H10.73L13,15.27V17H14.73L18.74,21L20,19.74L3.27,3L2,4.27Z" />
</svg>

After

Width:  |  Height:  |  Size: 649 B

Submodule awesome/src/lib/lgi-async-extra deleted from 45281ceaf4

1
awesome/src/lib/nice Submodule

Submodule awesome/src/lib/nice added at 8ee083f18c

View File

@@ -134,7 +134,7 @@ function device.new(args)
inputbox,
widget = wibox.container.constraint,
strategy = "exact",
width = dpi(400),
width = dpi(300),
id = "const"
},
spacing = dpi(10),

View File

@@ -6,7 +6,7 @@
local abutton = require("awful.button")
local aspawn = require("awful.spawn")
local base = require("wibox.widget.base")
local dbus_proxy = require("dbus_proxy")
local dbus_proxy = require("src.lib.lua-dbus_proxy.src.dbus_proxy")
local dpi = require("beautiful").xresources.apply_dpi
local gcolor = require("gears").color
local gfilesystem = require("gears").filesystem
@@ -249,167 +249,159 @@ end
function bluetooth.new(args)
args = args or {}
local ret = base.make_widget_from_value(wibox.widget {
-- For some reason the first widget isn't read so the first container is a duplicate
local ret = base.make_widget_from_value({
{
{
{
{
{
{
{
resize = false,
image = gcolor.recolor_image(icondir .. "menu-down.svg",
Theme_config.bluetooth_controller.connected_icon_color),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
id = "icon"
},
{
{
text = "Paired Devices",
valign = "center",
halign = "center",
widget = wibox.widget.textbox,
},
margins = dpi(5),
widget = wibox.container.margin
},
id = "connected",
layout = wibox.layout.fixed.horizontal
},
bg = Theme_config.bluetooth_controller.connected_bg,
fg = Theme_config.bluetooth_controller.connected_fg,
shape = Theme_config.bluetooth_controller.connected_shape,
widget = wibox.container.background
},
id = "connected_margin",
widget = wibox.container.margin
},
{
{
{
step = dpi(50),
spacing = dpi(10),
layout = require("src.lib.overflow_widget.overflow").vertical,
scrollbar_width = 0,
id = "connected_device_list"
},
id = "margin",
margins = dpi(10),
widget = wibox.container.margin
},
border_color = Theme_config.bluetooth_controller.con_device_border_color,
border_width = Theme_config.bluetooth_controller.con_device_border_width,
shape = Theme_config.bluetooth_controller.con_device_shape,
widget = wibox.container.background,
forced_height = 0,
id = "connected_list",
},
{
{
{
{
resize = false,
image = gcolor.recolor_image(icondir .. "menu-down.svg",
Theme_config.bluetooth_controller.discovered_icon_color),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
id = "icon",
},
{
{
text = "Nearby Devices",
valign = "center",
halign = "center",
widget = wibox.widget.textbox,
},
margins = dpi(5),
widget = wibox.container.margin
},
id = "discovered",
layout = wibox.layout.fixed.horizontal
},
id = "discovered_bg",
bg = Theme_config.bluetooth_controller.discovered_bg,
fg = Theme_config.bluetooth_controller.discovered_fg,
shape = Theme_config.bluetooth_controller.discovered_shape,
widget = wibox.container.background
},
id = "discovered_margin",
top = dpi(10),
widget = wibox.container.margin
},
{
{
{
id = "discovered_device_list",
spacing = dpi(10),
step = dpi(50),
layout = require("src.lib.overflow_widget.overflow").vertical,
scrollbar_width = 0,
},
margins = dpi(10),
widget = wibox.container.margin
},
border_color = Theme_config.bluetooth_controller.con_device_border_color,
border_width = Theme_config.bluetooth_controller.con_device_border_width,
shape = Theme_config.bluetooth_controller.con_device_shape,
widget = wibox.container.background,
forced_height = 0,
id = "discovered_list",
},
{
{ -- action buttons
{
dnd_widget {
color = Theme_config.bluetooth_controller.power_bg,
size = dpi(40)
},
id = "dnd",
widget = wibox.container.place,
resize = false,
image = gcolor.recolor_image(icondir .. "menu-down.svg",
Theme_config.bluetooth_controller.connected_icon_color),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center"
halign = "center",
id = "connected_icon"
},
nil,
{ -- refresh
{
{
{
image = gcolor.recolor_image(icondir .. "refresh.svg",
Theme_config.bluetooth_controller.refresh_icon_color),
resize = false,
valign = "center",
halign = "center",
widget = wibox.widget.imagebox,
},
widget = wibox.container.margin,
margins = dpi(5),
text = "Paired Devices",
valign = "center",
halign = "center",
widget = wibox.widget.textbox,
},
shape = Theme_config.bluetooth_controller.refresh_shape,
bg = Theme_config.bluetooth_controller.refresh_bg,
id = "scan",
widget = wibox.container.background
margins = dpi(5),
widget = wibox.container.margin
},
layout = wibox.layout.align.horizontal
layout = wibox.layout.fixed.horizontal
},
widget = wibox.container.margin,
top = dpi(10),
bg = Theme_config.bluetooth_controller.connected_bg,
fg = Theme_config.bluetooth_controller.connected_fg,
shape = Theme_config.bluetooth_controller.connected_shape,
widget = wibox.container.background,
id = "connected_bg"
},
layout = wibox.layout.fixed.vertical
id = "connected_margin",
widget = wibox.container.margin
},
margins = dpi(15),
widget = wibox.container.margin
{
{
{
step = dpi(50),
spacing = dpi(10),
layout = require("src.lib.overflow_widget.overflow").vertical,
scrollbar_width = 0,
id = "connected_device_list"
},
id = "margin",
margins = dpi(10),
widget = wibox.container.margin
},
border_color = Theme_config.bluetooth_controller.con_device_border_color,
border_width = Theme_config.bluetooth_controller.con_device_border_width,
shape = Theme_config.bluetooth_controller.con_device_shape,
widget = wibox.container.background,
forced_height = 0,
id = "connected_list",
},
{
{
{
{
resize = false,
image = gcolor.recolor_image(icondir .. "menu-down.svg",
Theme_config.bluetooth_controller.discovered_icon_color),
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
id = "discovered_icon",
},
{
{
text = "Nearby Devices",
valign = "center",
halign = "center",
widget = wibox.widget.textbox,
},
margins = dpi(5),
widget = wibox.container.margin
},
layout = wibox.layout.fixed.horizontal
},
id = "discovered_bg",
bg = Theme_config.bluetooth_controller.discovered_bg,
fg = Theme_config.bluetooth_controller.discovered_fg,
shape = Theme_config.bluetooth_controller.discovered_shape,
widget = wibox.container.background
},
id = "discovered_margin",
top = dpi(10),
widget = wibox.container.margin
},
{
{
{
id = "discovered_device_list",
spacing = dpi(10),
step = dpi(50),
layout = require("src.lib.overflow_widget.overflow").vertical,
scrollbar_width = 0,
},
margins = dpi(10),
widget = wibox.container.margin
},
border_color = Theme_config.bluetooth_controller.con_device_border_color,
border_width = Theme_config.bluetooth_controller.con_device_border_width,
shape = Theme_config.bluetooth_controller.con_device_shape,
widget = wibox.container.background,
forced_height = 0,
id = "discovered_list",
},
{
{ -- action buttons
{
dnd_widget {
color = Theme_config.bluetooth_controller.power_bg,
size = dpi(40)
},
id = "dnd",
widget = wibox.container.place,
valign = "center",
halign = "center"
},
nil,
{ -- refresh
{
{
image = gcolor.recolor_image(icondir .. "refresh.svg",
Theme_config.bluetooth_controller.refresh_icon_color),
resize = false,
valign = "center",
halign = "center",
widget = wibox.widget.imagebox,
},
widget = wibox.container.margin,
margins = dpi(5),
},
shape = Theme_config.bluetooth_controller.refresh_shape,
bg = Theme_config.bluetooth_controller.refresh_bg,
id = "scan",
widget = wibox.container.background
},
layout = wibox.layout.align.horizontal
},
widget = wibox.container.margin,
top = dpi(10),
},
layout = wibox.layout.fixed.vertical
},
shape = Theme_config.bluetooth_controller.shape,
border_color = Theme_config.bluetooth_controller.container_border_color,
border_width = Theme_config.bluetooth_controller.container_border_width,
bg = Theme_config.bluetooth_controller.container_bg,
widget = wibox.container.background
margins = dpi(15),
widget = wibox.container.margin,
},
width = dpi(400),
strategy = "exact",
widget = wibox.container.constraint
margins = dpi(15),
widget = wibox.container.margin,
})
-- Get a reference to the dnd button
@@ -489,7 +481,7 @@ function bluetooth.new(args)
--#region Dropdown logic
local connected_margin = ret:get_children_by_id("connected_margin")[1]
local connected_list = ret:get_children_by_id("connected_list")[1]
local connected = ret:get_children_by_id("connected")[1].center
local connected_icon = ret:get_children_by_id("connected_icon")[1]
connected_margin:connect_signal(
"button::press",
@@ -503,21 +495,23 @@ function bluetooth.new(args)
end
}
if connected_list.forced_height == 0 then
local size = (#ret:get_paired_devices() * 60) + 1
local size = (#ret:get_paired_devices() * 60)
if size < 210 then
rubato_timer.target = dpi(size)
end
connected_margin.connected_bg.shape = function(cr, width, height)
gshape.partially_rounded_rect(cr, width, height, true, true, false, false, dpi(4))
if size > 0 then
connected_margin.connected_bg.shape = function(cr, width, height)
gshape.partially_rounded_rect(cr, width, height, true, true, false, false, dpi(4))
end
connected_icon:set_image(gcolor.recolor_image(icondir .. "menu-up.svg",
Theme_config.bluetooth_controller.connected_icon_color))
end
connected.icon:set_image(gcolor.recolor_image(icondir .. "menu-up.svg",
Theme_config.bluetooth_controller.connected_icon_color))
else
rubato_timer.target = 0
connected_margin.connected_bg.shape = function(cr, width, height)
gshape.rounded_rect(cr, width, height, 4)
end
connected.icon:set_image(gcolor.recolor_image(icondir .. "menu-down.svg",
connected_icon:set_image(gcolor.recolor_image(icondir .. "menu-down.svg",
Theme_config.bluetooth_controller.connected_icon_color))
end
end
@@ -526,7 +520,7 @@ function bluetooth.new(args)
local discovered_margin = ret:get_children_by_id("discovered_margin")[1]
local discovered_list = ret:get_children_by_id("discovered_list")[1]
local discovered_bg = ret:get_children_by_id("discovered_bg")[1]
local discovered = ret:get_children_by_id("discovered")[1].center
local discovered_icon = ret:get_children_by_id("discovered_icon")[1]
discovered_margin:connect_signal(
"button::press",
@@ -541,22 +535,24 @@ function bluetooth.new(args)
}
if discovered_list.forced_height == 0 then
local size = (#ret:get_discovered_devices() * 60) + 1
local size = (#ret:get_discovered_devices() * 60)
if size > 210 then
size = 210
end
rubato_timer.target = dpi(size)
discovered_margin.discovered_bg.shape = function(cr, width, height)
gshape.partially_rounded_rect(cr, width, height, true, true, false, false, dpi(4))
if size > 0 then
rubato_timer.target = dpi(size)
discovered_margin.discovered_bg.shape = function(cr, width, height)
gshape.partially_rounded_rect(cr, width, height, true, true, false, false, dpi(4))
end
discovered_icon:set_image(gcolor.recolor_image(icondir .. "menu-up.svg",
Theme_config.bluetooth_controller.discovered_icon_color))
end
discovered.icon:set_image(gcolor.recolor_image(icondir .. "menu-up.svg",
Theme_config.bluetooth_controller.discovered_icon_color))
else
rubato_timer.target = 0
discovered_bg.shape = function(cr, width, height)
gshape.rounded_rect(cr, width, height, 4)
end
discovered.icon:set_image(gcolor.recolor_image(icondir .. "menu-down.svg",
discovered_icon:set_image(gcolor.recolor_image(icondir .. "menu-down.svg",
Theme_config.bluetooth_controller.discovered_icon_color))
end
end

View File

@@ -15,7 +15,7 @@ return function(s)
elseif widget == "Battery" then
table.insert(widget_table, require("src.widgets.battery")(User_config.battery_kind))
elseif widget == "Bluetooth" then
table.insert(widget_table, require("src.widgets.bluetooth")())
table.insert(widget_table, require("src.widgets.bluetooth")(s))
elseif widget == "Clock" then
table.insert(widget_table, require("src.widgets.clock")())
elseif widget == "Cpu Frequency" then

View File

@@ -16,7 +16,8 @@ local cm = require("src.modules.context_menu.init")
local capi = {
mouse = mouse,
awesome = awesome
awesome = awesome,
screen = screen,
}
local icondir = gfilesystem.get_configuration_dir() .. "src/assets/icons/desktop/"
@@ -46,7 +47,7 @@ function desktop:save_layout()
}
end
local dir = gfilesystem.get_configuration_dir() .. "src/config"
dir = gfilesystem.get_configuration_dir() .. "src/config"
gfilesystem.make_directories(dir)
if not gfilesystem.file_readable(dir .. "/desktop.json") then
os.execute("touch " .. dir .. "/desktop.json")
@@ -214,6 +215,9 @@ function desktop:add_element(args, pos)
cm_popup.visible = false
end)
local cols = math.floor(self.args.screen.geometry.width / (args.icon_size * 1.75 * (4 / 3)))
local rows = math.floor((self.args.screen.geometry.height - 75 + 95) / (args.icon_size * 1.75))
print(cols, rows)
-- While the mouse is down, remove the element from the grid and add it to manual then move it
-- until the mouse is released and then add it back to the grid.
e:connect_signal("button::press", function(_, _, _, b)
@@ -221,8 +225,8 @@ function desktop:add_element(args, pos)
if not mousegrabber.isrunning() then
local width = args.icon_size * 1.75 * (4 / 3)
local height = args.icon_size * 1.75
local width = (self.args.screen.geometry.width - 20 - ((cols - 1) * 10)) / cols
local height = (self.args.screen.geometry.height - 170 - 20) / rows
local dnd_widget = element {
icon = args.icon,
@@ -291,33 +295,39 @@ function desktop:add_element(args, pos)
end
function desktop:draw_selector()
local start_pos = mouse.coords()
local start_pos = capi.mouse.coords()
if not mousegrabber.isrunning() then
local selector = wibox.widget {
widget = wibox.container.background,
bg = gcolor("#0ffff088"),
border_color = gcolor("#0ffff0"),
border_width = dpi(2),
width = 100,
height = 100,
forced_width = 0,
forced_height = 0,
x = start_pos.x,
y = start_pos.y,
visible = true,
shape = function(cr, w, h)
gshape.rounded_rect(cr, w, h, dpi(10))
end
}
local coords = capi.mouse.coords()
selector.point = { x = coords.x, y = coords.y }
selector.point = { x = start_pos.x, y = start_pos.y }
self.widget.manual:add(selector)
mousegrabber.run(function(m)
if m.buttons[1] then
selector.visible = true
end
if not m.buttons[1] then
print("stop")
mousegrabber.stop()
selector.visible = false
self.widget.manual:reset()
end
selector.forced_width = selector.forced_width + ((start_pos.x - m.x) * -1)
selector.forced_height = selector.forced_width + ((start_pos.y - m.y) * -1)
print(selector.forced_width, selector.forced_height)
return m.buttons[1]
end, "left_ptr")
end
end
@@ -341,18 +351,10 @@ end
function desktop.new(args)
args = args or {}
args.screen = args.screen or awful.screen.focused()
local icon_size = args.icon_size or dpi(96)
-- calculate the row and column count based on the screen size and icon size and aspect ratio of 16:9
local screen_width = awful.screen.focused().geometry.width
local screen_height = awful.screen.focused().geometry.height
local aspect_ratio = 4 / 3
local cols = math.floor(screen_width / (icon_size * 1.75 * aspect_ratio))
local rows = math.floor((screen_height - (dpi(75 + 95))) / (icon_size * 1.75))
local cols = math.floor(args.screen.geometry.width / (icon_size * 1.75 * (4 / 3)))
local rows = math.floor((args.screen.geometry.height - 75 + 95) / (icon_size * 1.75))
--[[
The wibox has a stacked layout with a manual layout over a grid.
@@ -371,15 +373,15 @@ function desktop.new(args)
x = 0,
y = 0,
bg = gcolor.transparent,
width = 1920,
height = 1080,
width = args.screen.geometry.width,
height = args.screen.geometry.height,
screen = args.screen,
widget = wibox.widget {
{
{
layout = grid,
homogeneous = true,
spacing = dpi(10),
spacing = 10,
expand = true,
orientation = "horizontal",
forced_num_cols = cols,
@@ -401,6 +403,8 @@ function desktop.new(args)
}
}
w.args = args
local cm_popup = cm {
widget_template = wibox.widget {
{
@@ -563,29 +567,19 @@ function desktop.new(args)
}
}
w.widget.manual:buttons(
gtable.join(
awful.button(
{},
1,
function()
cm_popup.visible = false
if capi.mouse.current_widgets[4] == w.widget.manual then
--w:draw_selector()
end
end
),
awful.button(
{},
3,
function()
if capi.mouse.current_widgets[4] == w.widget.manual then
cm_popup:toggle()
end
end
)
)
)
w.widget.manual:buttons(gtable.join(
awful.button({}, 1, function()
cm_popup.visible = false
if capi.mouse.current_widgets[4] == w.widget.manual then
w:draw_selector()
end
end),
awful.button({}, 3, function()
if capi.mouse.current_widgets[4] == w.widget.manual then
cm_popup:toggle()
end
end)
))
gtable.crush(w, desktop, true)

View File

@@ -39,10 +39,10 @@ function element:on_hover()
self.border_color = "#0ffff099"
end)
self:connect_signal("mouse::leave", function()
--[[ self:connect_signal("mouse::leave", function()
self.bg = gcolor.transparent
self.border_color = gcolor.transparent
end)
end) ]]
self:connect_signal("button::press", function()
self.bg = "#0ffff088"

View File

@@ -4,31 +4,22 @@
-- Awesome Libs
local awful = require("awful")
awful.screen.connect_for_each_screen(
-- For each screen this function is called once
-- If you want to change the modules per screen use the indices
-- e.g. 1 would be the primary screen and 2 the secondary screen.
function(s)
-- Create 9 tags
awful.layout.append_default_layouts(User_config.layouts)
awful.tag(
{ "1", "2", "3", "4", "5", "6", "7", "8", "9" },
s,
User_config.layouts[1]
)
awful.screen.connect_for_each_screen(function(s)
-- Create 9 tags
awful.layout.append_default_layouts(User_config.layouts)
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, User_config.layouts[1])
require("src.modules.desktop.desktop") { screen = s }
require("src.modules.powermenu.powermenu")(s)
require("src.modules.audio.volume_osd") { screen = s }
--require("src.modules.audio.volume_controller") { screen = s }
require("src.modules.brightness.brightness_osd")(s)
require("src.modules.titlebar.titlebar")
require("src.modules.crylia_bar.init")(s)
--require("src.modules.crylia_wibox.init")(s)
require("src.modules.notification-center.init")(s)
require("src.modules.window_switcher.init")(s)
require("src.modules.application_launcher.init") { screen = s }
--require("src.modules.calendar.init") { screen = s }
require("src.modules.network_controller.init") { screen = s }
end
)
require("src.modules.desktop.desktop") { screen = s }
require("src.modules.powermenu.powermenu")(s)
require("src.modules.audio.volume_osd") { screen = s }
--require("src.modules.audio.volume_controller") { screen = s }
require("src.modules.brightness.brightness_osd") { screen = s }
require("src.lib.nice") { titlebar_font = User_config.font.bold,
titlebar_items = { left = { "icon" }, right = { "minimize", "maximize", "close" } } }
require("src.modules.crylia_bar.init")(s)
--require("src.modules.crylia_wibox.init")(s)
require("src.modules.notification-center.init")(s)
require("src.modules.window_switcher.init")(s)
require("src.modules.application_launcher.init") { screen = s }
require("src.modules.network_controller.init") { screen = s }
end)

View File

@@ -3,22 +3,152 @@
------------------------------------
-- Awesome Libs
local awful = require("awful")
local abutton = require("awful.button")
local awidget = require("awful.widget")
local dpi = require("beautiful").xresources.apply_dpi
local gtable = require("gears").table
local gfilesystem = require("gears").filesystem
local gobject = require("gears").object
local gcolor = require("gears").color
local lgi = require("lgi")
local wibox = require("wibox")
local base = require("wibox.widget.base")
local NM = require("lgi").NM
local NM = lgi.NM
-- Third party libs
local dbus_proxy = require("src.lib.lua-dbus_proxy.src.dbus_proxy")
-- Own libs
local ap_form = require("src.modules.network_controller.ap_form")
local cm = require("src.modules.context_menu.init")
local icondir = gfilesystem.get_configuration_dir() .. "src/assets/icons/network/"
local access_point = { mt = {} }
local function flags_to_security(flags, wpa_flags, rsn_flags)
local str = ""
if flags == 1 and wpa_flags == 0 and rsn_flags == 0 then
str = str .. " WEP"
end
if wpa_flags ~= 0 then
str = str .. " WPA1"
end
if not rsn_flags ~= 0 then
str = str .. " WPA2"
end
if wpa_flags == 512 or rsn_flags == 512 then
str = str .. " 802.1X"
end
return (str:gsub("^%s", ""))
end
function access_point:get_access_point_connections(ssid)
local cn = {}
local connections = self.NetworkManagerSettings:ListConnections()
for _, connection_path in ipairs(connections) do
local NetworkManagerSettingsConnection = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = "org.freedesktop.NetworkManager",
interface = "org.freedesktop.NetworkManager.Settings.Connection",
path = connection_path
}
if NetworkManagerSettingsConnection.Filename:find(ssid) then
table.insert(cn, NetworkManagerSettingsConnection)
end
end
return cn
end
function access_point:create_profile(ap, password, auto_connect)
local s_wsec = {}
local security = flags_to_security(ap.Flags, ap.WpaFlags, ap.RsnFlags)
if security ~= "" then
if security:match("WPA") then
s_wsec["key-mgmt"] = lgi.GLib.Variant("s", "wpa-psk")
s_wsec["auth-alg"] = lgi.GLib.Variant("s", "open")
s_wsec["psk"] = lgi.GLib.Variant("s", password)
else
s_wsec["key-mgmt"] = lgi.GLib.Variant("s", "None")
s_wsec["wep-key-type"] = lgi.GLib.Variant("s", NM.WepKeyType.PASSPHRASE)
s_wsec["wep-key0"] = lgi.GLib.Variant("s", password)
end
end
return {
["connection"] = {
-- ["interface-name"] = lgi.GLib.Variant("s", ap.device_interface),
["uuid"] = lgi.GLib.Variant("s", string.gsub('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', '[xy]', function(c)
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
return string.format('%x', v)
end)),
["id"] = lgi.GLib.Variant("s", NM.utils_ssid_to_utf8(ap.Ssid)),
["type"] = lgi.GLib.Variant("s", "802-11-wireless"),
["autoconnect"] = lgi.GLib.Variant("b", auto_connect),
},
["ipv4"] = {
["method"] = lgi.GLib.Variant("s", "auto")
},
["ipv6"] = {
["method"] = lgi.GLib.Variant("s", "auto"),
},
["802-11-wireless"] = {
["mode"] = lgi.GLib.Variant("s", "infrastructure"),
},
["802-11-wireless-security"] = s_wsec
}
end
function access_point:disconnect_ap()
self.NetworkManager:DeactivateConnection(self.NetworkManagerDevice.ActiveConnection)
end
function access_point:connect(ap, password, auto_connect)
local connections = self:get_access_point_connections(NM.utils_ssid_to_utf8(ap.Ssid))
local profile = self:create_profile(self.NetworkManagerAccessPoint, password, auto_connect)
if #connections == 0 then
self.NetworkManager:AddAndActivateConnectionAsync(function(proxy, context, success, fail)
if fail ~= nil then
print("Error: " .. tostring(fail), tostring(fail.code))
self:emit_signal("NetworkManager::failed", tostring(fail), tostring(fail.code))
return
end
self:emit_signal("NetworkManager::connected", success)
end, { call_id = "my-id" }, profile, self.NetworkManagerDevice.object_path,
self.NetworkManagerAccessPoint.object_path)
--88ALYLNxo9Kk*RwRxMfN
else
connections[1]:Update(profile)
self.NetworkManager:ActivateConnectionAsync(function(proxy, context, success, failure)
if failure then
self:emit_signal("NM::AccessPointFailed", tostring(failure))
return
end
self:emit_signal("NM::AccessPointConnected", NM.utils_ssid_to_utf8(ap.Ssid))
end,
{ call_id = "my-id" }, connections[1].object_path, self.NetworkManagerDevice.object_path,
self.NetworkManagerAccessPoint.object_path)
end
end
function access_point:toggle_access_point(ap, password, auto_connect)
if self:is_ap_active(ap) then
self:disconnect_ap()
else
self:connect_ap(ap, password, auto_connect)
end
end
function access_point:is_ap_active(ap)
return ap.path == self.NetworkManagerDeviceWireless.ActiveAccessPoint
end
function access_point.new(args)
args = args or {}
@@ -32,6 +162,13 @@ function access_point.new(args)
Theme_config.network_manager.access_point.icon_color2
end ]]
local ssid_text = awidget.inputbox {
text = NM.utils_ssid_to_utf8(args.NetworkManagerAccessPoint.Ssid) or
args.NetworkManagerAccessPoint.hw_address or "Unknown",
halign = "left",
valign = "center",
}
local ret = base.make_widget_from_value(wibox.widget {
{
{
@@ -57,21 +194,11 @@ function access_point.new(args)
},
{
{
{
text = NM.utils_ssid_to_utf8(args.NetworkManagerAccessPoint.Ssid) or
args.NetworkManagerAccessPoint.hw_address or "Unknown",
id = "alias",
widget = wibox.widget.textbox
},
{
text = "Connecting...",
id = "connecting",
visible = false,
font = User_config.font.specify .. ", regular 10",
widget = wibox.widget.textbox
},
id = "alias_container",
layout = wibox.layout.fixed.horizontal
ssid_text,
widget = wibox.container.constraint,
strategy = "exact",
width = dpi(300),
id = "alias"
},
width = dpi(260),
height = dpi(40),
@@ -130,21 +257,92 @@ function access_point.new(args)
gtable.crush(ret, access_point, true)
ret.NetworkManagerAccessPoint = args.NetworkManagerAccessPoint
ret.NetworkManagerSettings = args.NetworkManagerSettings
ret.NetworkManagerDeviceWireless = args.NetworkManagerDeviceWireless
ret.NetworkManagerDevice = args.NetworkManagerDevice
ret.NetworkManager = args.NetworkManager
ret.ap_form = ap_form { screen = args.screen, ssid = NM.utils_ssid_to_utf8(ret.NetworkManagerAccessPoint.Ssid) }
ret.ap_form = ap_form {
screen = args.screen,
NetworkManagerAccessPoint = args.NetworkManagerAccessPoint,
ap = ret
}
ret:buttons(
gtable.join(
awful.button(
{},
1,
nil,
function()
ret.ap_form:popup_toggle()
ret.cm = cm {
widget_template = wibox.widget {
{
{
{
{
widget = wibox.widget.imagebox,
resize = true,
valign = "center",
halign = "center",
id = "icon_role",
},
widget = wibox.container.constraint,
stragety = "exact",
width = dpi(24),
height = dpi(24),
id = "const"
},
{
widget = wibox.widget.textbox,
valign = "center",
halign = "left",
id = "text_role"
},
layout = wibox.layout.fixed.horizontal
},
widget = wibox.container.margin
},
widget = wibox.container.background,
}, spacing = dpi(10),
entries = {
{ -- Connect/Disconnect a device
name = "ret.device.Connected" and "Disconnect" or "Connect",
icon = gcolor.recolor_image("ret.device.Connected" and icondir .. "link-off.svg" or
icondir .. "link.svg",
Theme_config.network_manager.access_point.icon_color),
callback = function()
ret:toggle_access_point()
end,
id = "connected"
},
{ -- Rename a device
name = "Rename",
icon = gcolor.recolor_image(icondir .. "edit.svg", Theme_config.network_manager.icon_color),
callback = function()
ssid_text:focus()
ssid_text:connect_signal("submit", function(text)
text = text:get_text()
ssid_text.markup = ret:rename(text)
end)
end
)
},
{ -- Remove a device
name = "Remove",
icon = gcolor.recolor_image(icondir .. "delete.svg", Theme_config.network_manager.icon_color),
callback = function()
end
}
}
}
ret:buttons(gtable.join(
abutton({}, 1, nil,
function()
--TODO:Check if there are any connection details, else open the popup
ret.ap_form:popup_toggle()
end
),
abutton({}, 3, nil,
function()
ret.cm:toggle()
end
)
)
))
ret:get_children_by_id("con")[1].image = gcolor.recolor_image(
icondir .. "link.svg", icon_color)

View File

@@ -1,16 +1,20 @@
local awful = require("awful")
local abutton = require("awful.button")
local aplacement = require("awful.placement")
local apopup = require("awful.popup")
local awidget = require("awful.widget")
local dpi = require("beautiful").xresources.apply_dpi
local gtable = require("gears.table")
local gobject = require("gears.object")
local gcolor = require("gears.color")
local gshape = require("gears.shape")
local gfilesystem = require("gears.filesystem")
local NM = require("lgi").NM
local wibox = require("wibox")
local icondir = gfilesystem.get_configuration_dir() .. "src/assets/icons/network/"
local capi = {
awesome = awesome,
mouse = mouse,
mousegrabber = mousegrabber
}
@@ -22,47 +26,11 @@ end
function ap_form.new(args)
args = args or {}
args.screen = args.screen or awful.screen.preferred()
args.screen = args.screen
local settigns_form = {
password = awful.widget.inputbox {
widget_template = wibox.template {
widget = wibox.widget {
{
{
{
widget = wibox.widget.textbox,
halign = "left",
valign = "center",
id = "text_role",
},
widget = wibox.container.margin,
margins = 5,
id = "marg"
},
widget = wibox.container.constraint,
strategy = "exact",
width = 400,
height = 50,
id = "const"
},
widget = wibox.container.background,
bg = "#212121",
fg = "#F0F0F0",
border_color = "#414141",
border_width = 2,
shape = gshape.rounded_rect,
forced_width = 300,
forced_height = 50,
},
update_callback = function(template_widget, args)
template_widget.widget.const.marg.text_role.markup = args.text
end
}
},
}
local password = awidget.inputbox { hint_text = "Password..." }
local ret = awful.popup {
local ret = apopup {
widget = {
{
{ -- Header
@@ -71,7 +39,7 @@ function ap_form.new(args)
{
{
widget = wibox.widget.textbox,
text = args.ssid,
text = NM.utils_ssid_to_utf8(args.NetworkManagerAccessPoint.Ssid),
font = User_config.font.specify .. ",extra bold 16",
halign = "center",
valign = "center",
@@ -115,7 +83,30 @@ function ap_form.new(args)
right = dpi(20),
},
-- Change to inputtextbox container
settigns_form.password,
{
{
{
password,
widget = wibox.container.margin,
margins = 5,
id = "marg"
},
widget = wibox.container.constraint,
strategy = "exact",
width = 400,
height = 50,
id = "const"
},
widget = wibox.container.background,
bg = "#212121",
fg = "#F0F0F0",
border_color = "#414141",
border_width = 2,
shape = gshape.rounded_rect,
forced_width = 300,
forced_height = 50,
id = "password_container"
},
layout = wibox.layout.align.horizontal
},
{ -- Actions
@@ -181,7 +172,7 @@ function ap_form.new(args)
widget = wibox.container.margin,
margins = dpi(10)
},
placement = awful.placement.centered,
placement = aplacement.centered,
ontop = true,
visible = false,
width = dpi(600),
@@ -195,6 +186,30 @@ function ap_form.new(args)
screen = args.screen,
}
local password_container = ret.widget:get_children_by_id("password_container")[1]
-- Focus the searchbar when its left clicked
password_container:buttons(gtable.join {
abutton({}, 1, function()
password:focus()
end)
})
--#region Hover signals to change the cursor to a text cursor
local old_cursor, old_wibox
password_container:connect_signal("mouse::enter", function()
local wid = capi.mouse.current_wibox
if wid then
old_cursor, old_wibox = wid.cursor, wid
wid.cursor = "xterm"
end
end)
password_container:connect_signal("mouse::leave", function()
old_wibox.cursor = old_cursor
old_wibox = nil
end)
--#endregion
gtable.crush(ret, ap_form, true)
local checkbox = ret.widget:get_children_by_id("checkbox")[1]
@@ -210,13 +225,10 @@ function ap_form.new(args)
local connect_button = ret.widget:get_children_by_id("connect_button")[1]
connect_button:connect_signal("button::press", function()
ret:emit_signal("ap_form::connect", {
ssid = args.ssid,
password = settigns_form.password:get_text(),
auto_connect = ret.widget:get_children_by_id("checkbox")[1].checked
})
print("Connect to " .. args.ssid:get_text(), "\nPassword: " .. settigns_form.password:get_text(),
"\nAuto connect: " .. tostring(ret.widget:get_children_by_id("checkbox")[1].checked))
password:stop()
args.ap:connect(args.NetworkManagerAccessPoint, password:get_text(),
ret.widget:get_children_by_id("checkbox")[1].checked)
ret:popup_toggle()
end)
Hover_signal(connect_button)

View File

@@ -4,12 +4,11 @@
-- Awesome Libs
local awful = require("awful")
local dbus_proxy = require("dbus_proxy")
local dbus_proxy = require("src.lib.lua-dbus_proxy.src.dbus_proxy")
local dpi = require("beautiful").xresources.apply_dpi
local gtable = require("gears").table
local gtimer = require("gears").timer
local gshape = require("gears").shape
local gobject = require("gears").object
local gcolor = require("gears").color
local gears = require("gears")
local lgi = require("lgi")
@@ -24,11 +23,6 @@ local dnd_widget = require("awful.widget.toggle_widget")
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/network/"
local capi = {
awesome = awesome,
}
local network = { mt = {} }
network.NMState = {
@@ -63,31 +57,6 @@ network.DeviceState = {
FAILED = 120
}
local function flags_to_security(flags, wpa_flags, rsn_flags)
local str = ""
if flags == 1 and wpa_flags == 0 and rsn_flags == 0 then
str = str .. " WEP"
end
if wpa_flags ~= 0 then
str = str .. " WPA1"
end
if not rsn_flags ~= 0 then
str = str .. " WPA2"
end
if wpa_flags == 512 or rsn_flags == 512 then
str = str .. " 802.1X"
end
return (str:gsub("^%s", ""))
end
local function generate_uuid()
return string.gsub('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', '[xy]', function(c)
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
return string.format('%x', v)
end)
end
function network:get_wifi_proxy()
local devices = self._private.NetworkManager:GetDevices()
for _, path in ipairs(devices) do
@@ -146,74 +115,16 @@ function network.device_state_to_string(state)
return device_state_to_string[state]
end
function network:get_access_point_connections(ssid)
local cn = {}
local connections = self._private.NetworkManagerSettings:ListConnections()
for _, connection_path in ipairs(connections) do
local NetworkManagerSettingsConnection = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = "org.freedesktop.NetworkManager",
interface = "org.freedesktop.NetworkManager.Settings.Connection",
path = connection_path
}
if NetworkManagerSettingsConnection.Filename:find(ssid) then
table.insert(cn, NetworkManagerSettingsConnection)
end
end
return cn
end
function network:create_profile(ap, password, auto_connect)
local s_wsec = {}
if ap.security ~= "" then
if ap.security:match("WPA") then
s_wsec["key-mgmt"] = lgi.GLib.Variant("s", "wpa-psk")
s_wsec["auth-alg"] = lgi.GLib.Variant("s", "open")
--s_wsec["psk"] = lgi.GLib.Variant("s", helpers.string.trim(password))
else
s_wsec["key-mgmt"] = lgi.GLib.Variant("s", "None")
s_wsec["wep-key-type"] = lgi.GLib.Variant("s", NM.WepKeyType.PASSPHRASE)
--s_wsec["wep-key0"] = lgi.GLib.Variant("s", helpers.string.trim(password))
end
end
return {
["connection"] = {
-- ["interface-name"] = lgi.GLib.Variant("s", ap.device_interface),
["uuid"] = lgi.GLib.Variant("s", generate_uuid()),
["id"] = lgi.GLib.Variant("s", ap.ssid),
["type"] = lgi.GLib.Variant("s", "802-11-wireless"),
["autoconnect"] = lgi.GLib.Variant("b", auto_connect),
},
["ipv4"] = {
["method"] = lgi.GLib.Variant("s", "auto")
},
["ipv6"] = {
["method"] = lgi.GLib.Variant("s", "auto"),
},
["802-11-wireless"] = {
["mode"] = lgi.GLib.Variant("s", "infrastructure"),
},
["802-11-wireless-security"] = s_wsec
}
end
---Scan for access points and create a widget for each one.
function network:scan_access_points()
local ap_list = self:get_children_by_id("wifi_ap_list")[1]
ap_list:reset()
self._private.NetworkManagerDeviceWireless:RequestScanAsync(function(proxy, context, success, failure)
if failure then
-- Send an error notification
print("AP Scan failed: ", failure)
return
end
-- Get every access point even those who hide their ssid
print(#self._private.NetworkManagerDeviceWireless:GetAllAccessPoints())
for _, ap in ipairs(self._private.NetworkManagerDeviceWireless:GetAllAccessPoints()) do
-- Create a new proxy for every ap
@@ -223,69 +134,27 @@ function network:scan_access_points()
interface = "org.freedesktop.NetworkManager.AccessPoint",
path = ap
}
--[[ for _, ap2 in ipairs(ap_list.children) do
if ap2.NetworkManagerAccessPoint.HwAddress:match(ap.HwAddress or "") then
goto continue
end
end ]]
print("AP Found: ", NetworkManagerAccessPoint.HwAddress, NM.utils_ssid_to_utf8(NetworkManagerAccessPoint.Ssid),
NetworkManagerAccessPoint.Strength)
-- We are only interested in those with a ssid
if NetworkManagerAccessPoint.Ssid then
ap_list:add(access_point { NetworkManagerAccessPoint = NetworkManagerAccessPoint })
ap_list:add(access_point {
NetworkManagerAccessPoint = NetworkManagerAccessPoint,
NetworkManagerDevice = self._private.NetworkManagerDevice,
NetworkManagerSettings = self._private.NetworkManagerSettings,
NetworkManager = self._private.NetworkManager,
NetworkManagerDeviceWireless = self._private.NetworkManagerDeviceWireless
})
end
end
table.sort(ap_list, function(a, b)
return a.NetworkManagerAccessPoint.Strength > b.NetworkManagerAccessPoint.Strength
end)
print("AP_Anzahl: ", #ap_list.children)
end, { call_id = "my-id" }, {})
end
function network:is_ap_active(ap)
return ap.path == self._private.wifi_proxy.ActiveAccessPoint
end
function network:disconnect_ap()
self._private.NetworkManager:DeactivateConnection(self._private.NetworkManagerDevice.ActiveConnection)
end
function network:connect_ap(ap, pw, auto_connect)
local connections = self:get_access_point_connections(ap.ssid)
local profile = self:create_profile(ap, pw, auto_connect)
if #connections == 0 then
self._private.NetworkManager:AddAndActivateConnectionAsync(function(proxy, context, success, failure)
if failure then
self:emit_signal("NM::AccessPointFailed", tostring(failure))
return
end
self:emit_signal("NM::AccessPointConnected", ap.ssid)
end, { call_id = "my-id", profile, ap.device_proxy_path, ap.path })
else
connections[1]:Update(profile)
self._private.NetworkManager:ActivateConnectionAsync(function(proxy, context, success, failure)
if failure then
self:emit_signal("NM::AccessPointFailed", tostring(failure))
return
end
self:emit_signal("NM::AccessPointConnected", ap.ssid)
end, { call_id = "my-id", connections[1].object_path, ap.device_proxy_path, ap.path })
end
end
function network:toggle_access_point(ap, password, auto_connect)
if self:is_ap_active(ap) then
self:disconnect_ap()
else
self:connect_ap(ap, password, auto_connect)
end
return ap.path == self._private.NetworkManagerDeviceWireless.ActiveAccessPoint
end
---Toggles networking on or off

View File

@@ -1,447 +0,0 @@
-----------------------------------
-- This is the titlebar module --
-----------------------------------
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
local capi = {
awesome = awesome,
client = client
}
-- Icon directory path
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/titlebar/"
awful.titlebar.enable_tooltip = true
awful.titlebar.fallback_name = 'Client'
-- Normal AND Focus(active/inactive) have to be set or errors will appear in stdout
Theme.titlebar_close_button_normal = icondir .. "close.svg"
Theme.titlebar_close_button_focus = icondir .. "close.svg"
Theme.titlebar_minimize_button_normal = icondir .. "minimize.svg"
Theme.titlebar_minimize_button_focus = icondir .. "minimize.svg"
Theme.titlebar_maximized_button_normal = icondir .. "maximize.svg"
Theme.titlebar_maximized_button_active = icondir .. "maximize.svg"
Theme.titlebar_maximized_button_inactive = icondir .. "maximize.svg"
local create_buttons = function(c)
local buttons = gears.table.join(
awful.button(
{},
1,
function()
c:activate { context = 'titlebar', action = 'mouse_move' }
end
),
awful.button(
{},
3,
function()
c:activate { context = 'titlebar', action = 'mouse_resize' }
end
)
)
return buttons
end
local create_titlebar = function(c, size, position)
local close_button = awful.titlebar.widget.closebutton(c)
local minimize_button = awful.titlebar.widget.minimizebutton(c)
local maximize_button = awful.titlebar.widget.maximizedbutton(c)
local tb
if position == "left" then
local titlebar = awful.titlebar(c, {
position = "left",
bg = Theme_config.titlebar.bg,
size = size
})
tb = wibox.widget {
{
{
{
close_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.close_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "closebutton"
},
{
maximize_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.maximize_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "maximizebutton"
},
{
minimize_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.minimize_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "minimizebutton"
},
spacing = dpi(10),
layout = wibox.layout.fixed.vertical,
id = "spacing"
},
margins = dpi(5),
widget = wibox.container.margin,
id = "margin"
},
{
buttons = create_buttons(c),
layout = wibox.layout.flex.vertical
},
{
awful.titlebar.widget.iconwidget(c),
margins = dpi(5),
widget = wibox.container.margin
},
layout = wibox.layout.align.vertical,
id = "main"
}
titlebar:setup { tb, layout = wibox.layout.fixed.horizontal }
elseif position == "top" then
local titlebar = awful.titlebar(c, {
position = "top",
bg = Theme_config.titlebar.bg,
size = size
})
tb = wibox.widget {
{
awful.titlebar.widget.iconwidget(c),
margins = dpi(5),
widget = wibox.container.margin
},
{
{
awful.titlebar.widget.titlewidget(c),
valign = "center",
halign = "center",
layout = wibox.container.place,
},
buttons = create_buttons(c),
fill_space = true,
layout = wibox.layout.stack
},
{
{
{
minimize_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.minimize_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "minimizebutton"
},
{
maximize_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.maximize_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "maximizebutton"
},
{
close_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.close_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "closebutton"
},
spacing = dpi(10),
layout = wibox.layout.fixed.horizontal,
id = "spacing"
},
margins = dpi(5),
widget = wibox.container.margin,
id = "margin"
},
layout = wibox.layout.align.horizontal,
id = "main"
}
titlebar:setup { tb, layout = wibox.layout.fixed.vertical }
end
if not tb then return end
close_button:connect_signal(
"mouse::enter",
function()
c.border_color = Theme_config.titlebar.close_button.hover_border
local cb = tb:get_children_by_id("closebutton")[1]
cb.border_color = Theme_config.titlebar.close_button.hover_border
cb.bg = Theme_config.titlebar.close_button.hover_bg
end
)
close_button:connect_signal(
"mouse::leave",
function()
c.border_color = Theme_config.window.border_normal
local cb = tb:get_children_by_id("closebutton")[1]
cb.border_color = Theme_config.titlebar.close_button.border_color
cb.bg = Theme_config.titlebar.close_button.bg
end
)
minimize_button:connect_signal(
"mouse::enter",
function()
c.border_color = Theme_config.titlebar.minimize_button.hover_border
local mb = tb:get_children_by_id("minimizebutton")[1]
mb.border_color = Theme_config.titlebar.minimize_button.hover_border
mb.bg = Theme_config.titlebar.minimize_button.hover_bg
end
)
minimize_button:connect_signal(
"mouse::leave",
function()
c.border_color = Theme_config.window.border_normal
local mb = tb:get_children_by_id("minimizebutton")[1]
mb.border_color = Theme_config.titlebar.minimize_button.border_color
mb.bg = Theme_config.titlebar.minimize_button.bg
end
)
maximize_button:connect_signal(
"mouse::enter",
function()
c.border_color = Theme_config.titlebar.maximize_button.hover_border
local mb = tb:get_children_by_id("maximizebutton")[1]
mb.border_color = Theme_config.titlebar.maximize_button.hover_border
mb.bg = Theme_config.titlebar.maximize_button.hover_bg
end
)
maximize_button:connect_signal(
"mouse::leave",
function()
c.border_color = Theme_config.window.border_normal
local mb = tb:get_children_by_id("maximizebutton")[1]
mb.border_color = Theme_config.titlebar.maximize_button.border_color
mb.bg = Theme_config.titlebar.maximize_button.bg
end
)
end
local create_titlebar_dialog_modal = function(c, size, position)
local close_button = awful.titlebar.widget.closebutton(c)
local minimize_button = awful.titlebar.widget.minimizebutton(c)
local maximize_button = awful.titlebar.widget.maximizedbutton(c)
local tb
if position == "left" then
local titlebar = awful.titlebar(c, {
position = "left",
bg = Theme_config.titlebar.bg,
size = size
})
tb = wibox.widget {
{
{
close_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.close_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "closebutton"
},
margins = dpi(5),
widget = wibox.container.margin,
id = "margin"
},
{
buttons = create_buttons(c),
layout = wibox.layout.flex.vertical
},
{
awful.titlebar.widget.iconwidget(c),
margins = dpi(5),
widget = wibox.container.margin
},
layout = wibox.layout.align.vertical,
id = "main"
}
titlebar:setup { tb, layout = wibox.layout.fixed.horizontal }
elseif position == "top" then
local titlebar = awful.titlebar(c, {
position = "top",
bg = Theme_config.titlebar.bg,
size = size
})
tb = wibox.widget {
{
awful.titlebar.widget.iconwidget(c),
margins = dpi(5),
widget = wibox.container.margin
},
{
{
awful.titlebar.widget.titlewidget(c),
valign = "center",
halign = "center",
layout = wibox.container.place,
},
buttons = create_buttons(c),
fill_space = true,
layout = wibox.layout.stack
},
{
{
close_button,
widget = wibox.container.background,
border_color = Theme_config.titlebar.close_button.border_color,
border_width = dpi(2),
shape = function(cr, height, width)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end,
id = "closebutton"
},
margins = dpi(5),
widget = wibox.container.margin,
id = "margin"
},
layout = wibox.layout.align.horizontal,
id = "main"
}
titlebar:setup { tb, layout = wibox.layout.fixed.vertical }
end
if not tb then return end
close_button:connect_signal(
"mouse::enter",
function()
c.border_color = Theme_config.titlebar.close_button.hover_border
local cb = tb:get_children_by_id("closebutton")[1]
cb.border_color = Theme_config.titlebar.close_button.hover_border
cb.bg = Theme_config.titlebar.close_button.hover_bg
end
)
close_button:connect_signal(
"mouse::leave",
function()
c.border_color = Theme_config.window.border_normal
local cb = tb:get_children_by_id("closebutton")[1]
cb.border_color = Theme_config.titlebar.close_button.border_color
cb.bg = Theme_config.titlebar.close_button.bg
end
)
minimize_button:connect_signal(
"mouse::enter",
function()
c.border_color = Theme_config.titlebar.minimize_button.hover_border
local mb = tb:get_children_by_id("minimizebutton")[1]
mb.border_color = Theme_config.titlebar.minimize_button.hover_border
mb.bg = Theme_config.titlebar.minimize_button.hover_bg
end
)
minimize_button:connect_signal(
"mouse::leave",
function()
c.border_color = Theme_config.window.border_normal
local mb = tb:get_children_by_id("minimizebutton")[1]
mb.border_color = Theme_config.titlebar.minimize_button.border_color
mb.bg = Theme_config.titlebar.minimize_button.bg
end
)
maximize_button:connect_signal(
"mouse::enter",
function()
c.border_color = Theme_config.titlebar.maximize_button.hover_border
local mb = tb:get_children_by_id("maximizebutton")[1]
mb.border_color = Theme_config.titlebar.maximize_button.hover_border
mb.bg = Theme_config.titlebar.maximize_button.hover_bg
end
)
maximize_button:connect_signal(
"mouse::leave",
function()
c.border_color = Theme_config.window.border_normal
local mb = tb:get_children_by_id("maximizebutton")[1]
mb.border_color = Theme_config.titlebar.maximize_button.border_color
mb.bg = Theme_config.titlebar.maximize_button.bg
end
)
end
capi.client.connect_signal(
"request::titlebars",
function(c)
if c.type == "dialog" then
create_titlebar_dialog_modal(c, dpi(35), User_config.titlebar_position)
elseif c.type == "modal" then
create_titlebar_dialog_modal(c, dpi(35), User_config.titlebar_position)
else
create_titlebar(c, dpi(35), User_config.titlebar_position)
end
if not c.floating or c.maximized or c.fullscreen then
if User_config.titlebar_position == "left" then
awful.titlebar.hide(c, "left")
elseif User_config.titlebar_position == "top" then
awful.titlebar.hide(c, "top")
end
end
end
)
capi.client.connect_signal(
"property::floating",
function(c)
if c.floating and not (c.maximized or c.fullscreen) then
if User_config.titlebar_position == "left" then
awful.titlebar.show(c, "left")
elseif User_config.titlebar_position == "top" then
awful.titlebar.show(c, "top")
end
else
if User_config.titlebar_position == "left" then
awful.titlebar.hide(c, "left")
elseif User_config.titlebar_position == "top" then
awful.titlebar.hide(c, "top")
end
end
end
)

View File

@@ -1,10 +0,0 @@
#!/bin/bash
case $1 in
"get")
echo $(xfpm-power-backlight-helper --get-brightness)
;;
"set")
echo $(pkexec xfpm-power-backlight-helper --set-brightness $2)
;;
esac

View File

@@ -515,8 +515,13 @@ Theme_config.right_bar = {
Theme_config.titlebar = {
bg = "#121212AA",
size = dpi(38),
close_button = {
border_color = "#00000000",
border_width = dpi(2),
shape = function(cr, width, height)
gshape.rounded_rect(cr, width, height, dpi(6))
end,
bg = "#00000000",
fg = color["Grey100"],
hover_border = color["Red800"],
@@ -525,6 +530,10 @@ Theme_config.titlebar = {
},
minimize_button = {
border_color = "#00000000",
border_width = dpi(2),
shape = function(cr, width, height)
gshape.rounded_rect(cr, width, height, dpi(6))
end,
fg = color["Grey100"],
bg = "#00000000",
hover_border = color["Orange800"],
@@ -533,6 +542,10 @@ Theme_config.titlebar = {
},
maximize_button = {
border_color = "#00000000",
border_width = dpi(2),
shape = function(cr, width, height)
gshape.rounded_rect(cr, width, height, dpi(6))
end,
fg = color["Grey100"],
bg = "#00000000",
hover_border = color["Green800"],

View File

@@ -55,6 +55,14 @@ User_config = {
]] --
battery_path = nil,
--[[
The brightness increase/decrease step in percent.
Example:
brightness_step = 5
Will increase the brightness by 5% at a time
]]
brightness_step = 2,
--[[
DnD or 'Do not Disturb' will prevent notifications from poping up.
This is just a default value, you can toggle it in the notification-center, but it won't be saved.
@@ -213,7 +221,7 @@ User_config = {
--[[
This is the default terminal, Alacritty is the default.
]] --
terminal = "alacritty",
terminal = "kitty",
text_editor = "code",

View File

@@ -0,0 +1,87 @@
local cairo = require("lgi").cairo
local gcolor = require("gears.color")
local gdk = require("lgi").Gdk
local gsurface = require("gears.surface")
local gtable = require("gears.table")
local color_helper = { mt = {} }
color_helper.color_rules = {}
function color_helper.set_color_rule(c, color)
color_helper.color_rules[c.instance] = color
end
function color_helper.get_color_rule(c)
return color_helper.color_rules[c.instance]
end
function color_helper.lighten(color, amount)
local r, g, b
r, g, b = gcolor.parse_color(color)
r = 255 * r
g = 255 * g
b = 255 * b
r = r + math.floor(2.55 * amount)
g = g + math.floor(2.55 * amount)
b = b + math.floor(2.55 * amount)
r = r > 255 and 255 or r
g = g > 255 and 255 or g
b = b > 255 and 255 or b
return ("#%02x%02x%02x"):format(r, g, b)
end
function color_helper.duotone_gradient_vertical(color_1, color_2, height, offset_1, offset_2)
local fill_pattern = cairo.Pattern.create_linear(0, 0, 0, height)
local r, g, b, a
r, g, b, a = gcolor.parse_color(color_1)
fill_pattern:add_color_stop_rgba(offset_1 or 0, r, g, b, a)
r, g, b, a = gcolor.parse_color(color_2)
fill_pattern:add_color_stop_rgba(offset_2 or 1, r, g, b, a)
return fill_pattern
end
function color_helper.get_dominant_color(client)
local color, pb, bytes
local tally, content, cgeo = {}, gsurface(client.content), client:geometry()
local x_offset, y_offset, x_lim = 2, 2, math.floor(cgeo.width / 2)
for x_pos = 0, x_lim, 2 do
for y_pos = 0, 8, 1 do
pb = gdk.pixbuf_get_from_surface(content, x_offset + x_pos, y_offset + y_pos, 1, 1)
bytes = pb:get_pixels()
color = "#" .. bytes:gsub(".", function(c)
return ("%02x"):format(c:byte())
end)
if not tally[color] then
tally[color] = 1
else
tally[color] = tally[color] + 1
end
end
end
local mode
local mode_c = 0
for k, v in pairs(tally) do
if v > mode_c then
mode_c = v
mode = k
end
end
color = mode
color_helper.set_color_rule(client, color)
return color
end
function color_helper.new(args)
local ret = {}
gtable.crush(ret, color_helper, true)
return ret
end
function color_helper.mt:__call(...)
return color_helper.new(...)
end
return setmetatable(color_helper, color_helper.mt)

View File

@@ -1,6 +1,6 @@
local awful = require("awful")
local gears = require("gears")
local dbus_proxy = require("dbus_proxy")
local dbus_proxy = require("src.lib.lua-dbus_proxy.src.dbus_proxy")
local lgi = require("lgi")
local capi = {

View File

@@ -2,14 +2,18 @@
-- This is the bluetooth widget --
----------------------------------
-- Awesome Libs
-- Awesome libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
-- Own libs
local bt_module = require("src.modules.bluetooth.init")
local capi = {
awesome = awesome,
mouse = mouse
}
-- Icon directory path
@@ -18,21 +22,9 @@ local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/bl
-- Returns the bluetooth widget
return function(s)
local bt_widget = require("src.modules.bluetooth.init") { screen = s }
local bluetooth_container = awful.popup {
widget = bt_widget:get_widget(),
ontop = true,
bg = Theme_config.bluetooth_controller.container_bg,
stretch = false,
visible = false,
forced_width = dpi(400),
screen = s,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(12))
end
}
-- Get the bluetooth module
local bt_widget = bt_module { screen = s }
-- Create the bluetooth widget
local bluetooth_widget = wibox.widget {
{
{
@@ -60,6 +52,25 @@ return function(s)
widget = wibox.container.background
}
-- If bt_widget is nil then there is no bluetooth adapter and there shouldn't be done
-- anything besides returning the widget without any logic behind
if not bt_widget then
return bluetooth_widget
end
-- Create the awful.popup container for the module
local bluetooth_container = awful.popup {
widget = bt_widget,
ontop = true,
stretch = false,
visible = false,
screen = s,
border_color = Theme_config.bluetooth_controller.container_border_color,
border_width = Theme_config.bluetooth_controller.container_border_width,
bg = Theme_config.bluetooth_controller.container_bg
}
-- When the status changes update the icon
bt_widget:connect_signal("bluetooth::status", function(status)
bluetooth_widget:get_children_by_id("icon")[1].image = gears.color.recolor_image(status._private.Adapter1.Powered and
icondir .. "bluetooth-on.svg" or icondir .. "bluetooth-off.svg", Theme_config.bluetooth.fg)
@@ -68,19 +79,17 @@ return function(s)
-- Hover signal to change color when mouse is over
Hover_signal(bluetooth_widget)
bluetooth_widget:connect_signal(
"button::press",
function(_, _, _, key)
if key == 1 then
local geo = mouse.current_wibox:geometry()
bluetooth_container.x = geo.x
bluetooth_container.y = geo.y + dpi(55)
bluetooth_container.visible = not bluetooth_container.visible
else
capi.awesome.emit_signal("toggle_bluetooth")
end
-- On left click toggle the bluetooth container else toggle the bluetooth on/off
bluetooth_widget:connect_signal("button::press", function(_, _, _, key)
if key == 1 then
local geo = capi.mouse.current_wibox:geometry()
bluetooth_container.x = geo.x
bluetooth_container.y = geo.y + dpi(55)
bluetooth_container.visible = not bluetooth_container.visible
else
capi.awesome.emit_signal("toggle_bluetooth")
end
)
end)
return bluetooth_widget
end

View File

@@ -16,6 +16,14 @@
- Algorithm to select the best search match
- Keep track of most launched applications and serve them over others
### Backlight [100% Done]
#### Features
- Change backlight with your backlight keys
- See the change on a OSD that pops up
- Works with all devices by writing into /usr/class/backlight/`device`
### Bluetooth [95% Done]
#### Features
@@ -37,4 +45,42 @@
- Getting and asking for a passcode
- "Greying out" non avaiable options in the dropdown
### Calendar [60% Done]
#### Features
- Read .ical files and put them into the calendar
- Create tasks for every day
- Month/Year switcher
- Saved accross restarts
- Popup with the task informations
#### TODO
- Create a new task for a calendar
- Create an alert that notifies the user
- Week numbers
- Remove a calendar
- Remove a task
### Desktop [40% Done]
- Create desktop icons, folders or files
- Drag and drop desktop icons
- Context menu
- Saves accross restart
- Desktop context menu
TODO
- Actions for the context menu
- Open width in context menu
- Drag across multiple screens
- Proper size calculation for desktop icons and desktop
- Multiscreen support in general
- MIME types for files
- xdg folder types
- Drag-select
- Cross-DE support (e.g. use the same desktop icons as used in KDE or Mate ...)
## Widgets