add new context_menu and rework dock, programs can now be added to the dock my right clicking any program in the application launcher an choosing Add to Dock

This commit is contained in:
Rene
2022-08-15 15:18:51 +02:00
parent 9cea2f98cc
commit 268cb29a6b
22 changed files with 507 additions and 167 deletions

View File

@@ -1 +1 @@
Lutris;Steam;Io.elementary.appcenter;Repoman;Com.github.donadigo.eddy;Sysmontask;join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=Gnome-calculator;Virt-manager;Gwe;whatsdesk;Totem;steam_app_431960;Viewer,;Viewer,;Nvidia-settings;openrgb;Minecraft;Pavucontrol;jamesdsp; Lutris;Io.elementary.appcenter;Repoman;Com.github.donadigo.eddy;Sysmontask;join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=Gnome-calculator;Virt-manager;Gwe;whatsdesk;Totem;steam_app_431960;Viewer,;Viewer,;Nvidia-settings;openrgb;Minecraft;Pavucontrol;jamesdsp;

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z" /></svg>

After

Width:  |  Height:  |  Size: 160 B

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21,16H3V4H21M21,2H3C1.89,2 1,2.89 1,4V16C1,17.1 1.9,18 3,18H10V20H8V22H16V20H14V18H21C22.1,18 23,17.1 23,16V4C23,2.89 22.1,2 21,2Z" /></svg>

After

Width:  |  Height:  |  Size: 210 B

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10,17L15,12L10,7V17Z" /></svg>

After

Width:  |  Height:  |  Size: 100 B

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z" /></svg>

After

Width:  |  Height:  |  Size: 212 B

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M16,12V4H17V2H7V4H8V12L6,14V16H11.2V22H12.8V16H18V14L16,12Z" /></svg>

After

Width:  |  Height:  |  Size: 138 B

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M2,5.27L3.28,4L20,20.72L18.73,22L12.8,16.07V22H11.2V16H6V14L8,12V11.27L2,5.27M16,12L18,14V16H17.82L8,6.18V4H7V2H17V4H16V12Z" /></svg>

After

Width:  |  Height:  |  Size: 202 B

View File

@@ -0,0 +1 @@
[{"actions":["New"],"categories":"System;TerminalEmulator;","comment":"A fast, cross-platform, OpenGL terminal emulator","desktop_file":"/usr/share/applications/com.alacritty.Alacritty.desktop","exec":"alacritty","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/com.alacritty.Alacritty.svg","keywords":"","name":"Alacritty","terminal":""},{"actions":["new-window","new-private-window"],"categories":"Network;WebBrowser;","comment":"Access the Internet","desktop_file":"/var/lib/flatpak/exports/share/applications/com.brave.Browser.desktop","exec":"/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=brave --file-forwarding com.brave.Browser @@u %U @@","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/com.brave.Browser.svg","keywords":"","name":"Brave","terminal":""},{"actions":["new-empty-window"],"categories":"TextEditor;Development;IDE;","comment":"Code Editing. Redefined.","desktop_file":"/usr/share/applications/code.desktop","exec":"/usr/share/code/code --unity-launch %F","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/com.visualstudio.code.svg","keywords":"vscode;","name":"Visual Studio Code","terminal":""},{"actions":[],"categories":"Audio;Music;Player;AudioVideo;","comment":"","desktop_file":"/usr/local/share/applications/spotify.desktop","exec":"spotify %U","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/spotify-client.svg","keywords":"","name":"Spotify","terminal":""},{"actions":[],"categories":"Network;InstantMessaging;","comment":"All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.","desktop_file":"/usr/share/applications/discord.desktop","exec":"/usr/share/discord/Discord","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/discord.svg","keywords":"","name":"Discord","terminal":""},{"actions":["Store","Community","Library","Servers","Screenshots","News","Settings","BigPicture","Friends"],"categories":"Network;FileTransfer;Game;","comment":"Application for managing and playing games on Steam","desktop_file":"/usr/share/applications/steam.desktop","exec":"/usr/games/steam %U","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/steam.svg","keywords":"Games","name":"Steam","terminal":""},{"actions":["Remove"],"categories":"Graphics;","comment":"Cura converts 3D models into paths for a 3D printer. It prepares your print for maximum accuracy, minimum printing time and good reliability with many extra features that make your print come out great.","desktop_file":"/home/crylia/.local/share/applications/appimagekit_5de59b772d786d6e98102a035c80e40c-Ultimaker_Cura.desktop","exec":"/home/crylia/Applications/Ultimaker-Cura-5.0.0-linux_07ecc3f54905e865167d2bcd7cfe459c.AppImage %F","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/appimagekit-cura-icon.svg","keywords":"3D;Printing;","name":"Ultimaker Cura (5.0.0)","terminal":""},{"actions":[],"categories":"Game;","comment":"video game preservation platform","desktop_file":"/usr/share/applications/net.lutris.Lutris.desktop","exec":"lutris %U","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/lutris.svg","keywords":"gaming;wine;emulator;","name":"Lutris","terminal":""},{"actions":[],"categories":"Graphics;Science;Engineering","comment":"Feature based Parametric Modeler","desktop_file":"/usr/share/applications/freecad.desktop","exec":"/usr/bin/freecad --single-instance %F","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/freecad.svg","keywords":"","name":"FreeCAD","terminal":""},{"actions":[],"categories":"Graphics;3DGraphics;","comment":"3D modeling, animation, rendering and post-production","desktop_file":"/usr/share/applications/blender.desktop","exec":"blender %f","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/blender.svg","keywords":"3d;cg;modeling;animation;painting;sculpting;texturing;video editing;video tracking;rendering;render engine;cycles;game engine;python;","name":"Blender","terminal":""},{"actions":[],"categories":"Game;","comment":"Play this game on Steam","desktop_file":"/home/crylia/.local/share/applications/The Witcher 3 Wild Hunt.desktop","exec":"steam steam://rungameid/292030","icon":"/usr/share/icons/Papirus-Dark/64x64/categories/steam_icon_292030.svg","keywords":"","name":"The Witcher 3: Wild Hunt","terminal":""},{"actions":[],"categories":"Game;","comment":"Play this game on Steam","desktop_file":"/home/crylia/.local/share/applications/Hearts of Iron IV.desktop","exec":"steam steam://rungameid/394360","icon":"/home/crylia/.local/share/icons/hicolor/64x64/apps/steam_icon_394360.png","keywords":"","name":"Hearts of Iron IV","terminal":""}]

View File

@@ -36,7 +36,10 @@ awful.rules.rules = {
role = { role = {
"AlarmWindow", "AlarmWindow",
"ConfigManager", "ConfigManager",
"pop-up" "pop-up",
"dialog",
"modal",
"utility"
} }
}, },
properties = { properties = {

View File

@@ -34,6 +34,9 @@ client.connect_signal(
if c.class == "Brave-browser" then if c.class == "Brave-browser" then
c.floating = false c.floating = false
end end
if c.transient_for then
c.floating = true
end
end end
) )
@@ -75,15 +78,20 @@ client.connect_signal(
"request::activate", "request::activate",
"mouse_enter", "mouse_enter",
{ {
raise = false raise = true
} }
) )
end end
) )
--- Takes a wibox.container.background and connects four signals to it --- Takes a wibox.container.background and connects four signals to it
---@param widget wibox.container.background ---@param widget wibox.container.background a background widget
function Hover_signal(widget, bg_override) ---@param bg_override string | nil overrides the default bg hover color
---@param fg_override string | nil overrides the default fg hover color
---@param border_override string | nil overrides the default border hover color
---@param icon_override string | nil the old icon color
---@param icon_override_hover string | nil the hover effect color
function Hover_signal(widget, bg_override, fg_override, border_override, icon_override, icon_override_hover)
local old_wibox, old_cursor, old_bg, old_fg, old_border local old_wibox, old_cursor, old_bg, old_fg, old_border
local r, g, b local r, g, b
@@ -91,6 +99,11 @@ function Hover_signal(widget, bg_override)
widget.bg = widget.bg or "" widget.bg = widget.bg or ""
widget.fg = widget.fg or "" widget.fg = widget.fg or ""
widget.border_color = widget.border_color or "" widget.border_color = widget.border_color or ""
local icon = nil
if icon_override and icon_override_hover then
icon = widget:get_children_by_id("icon")[1].icon
widget.icon = widget:get_children_by_id("icon")[1]
end
local mouse_enter = function() local mouse_enter = function()
_, r, g, b, _ = widget.bg:get_rgba() _, r, g, b, _ = widget.bg:get_rgba()
@@ -100,12 +113,15 @@ function Hover_signal(widget, bg_override)
end end
_, r, g, b, _ = widget.fg:get_rgba() _, r, g, b, _ = widget.fg:get_rgba()
old_fg = RGB_to_hex(r, g, b) old_fg = RGB_to_hex(r, g, b)
if old_fg then if fg_override or old_fg then
widget.fg = old_fg .. "dd" widget.fg = fg_override or old_fg .. "dd"
end end
old_border = widget.border_color old_border = widget.border_color
if old_border then if border_override or old_border then
widget.border_color = old_border .. "dd" widget.border_color = border_override or old_border .. "dd"
end
if icon and widget.icon and icon_override and icon_override_hover then
widget.icon.image = gears.color.recolor_image(icon, icon_override_hover)
end end
local w = mouse.current_wibox local w = mouse.current_wibox
if w then if w then
@@ -114,23 +130,35 @@ function Hover_signal(widget, bg_override)
end end
end end
local button_press = function() --[[ local button_press = function()
if old_bg or bg_override then if old_bg or bg_override then
if bg_override then
bg_override = bg_override .. "bb"
end
widget.bg = bg_override or old_bg .. "bb" widget.bg = bg_override or old_bg .. "bb"
end end
if old_fg then if fg_override or old_fg then
widget.fg = old_fg .. "bb" if fg_override then
fg_override = fg_override .. "bb"
end
widget.fg = fg_override or old_fg .. "bb"
end end
end end
local button_release = function() local button_release = function()
if old_bg or bg_override then if old_bg or bg_override then
if bg_override then
bg_override = bg_override .. "dd"
end
widget.bg = bg_override or old_bg .. "dd" widget.bg = bg_override or old_bg .. "dd"
end end
if old_fg then if fg_override or old_fg then
widget.fg = old_fg .. "dd" if fg_override then
fg_override = fg_override .. "dd"
end end
widget.fg = fg_override or old_fg .. "dd"
end end
end ]]
local mouse_leave = function() local mouse_leave = function()
if old_bg then if old_bg then
@@ -146,10 +174,13 @@ function Hover_signal(widget, bg_override)
old_wibox.cursor = old_cursor old_wibox.cursor = old_cursor
old_wibox = nil old_wibox = nil
end end
if widget.icon and icon_override and icon_override_hover then
widget.icon.image = gears.color.recolor_image(icon, icon_override)
end
end end
widget:connect_signal("mouse::enter", mouse_enter) widget:connect_signal("mouse::enter", mouse_enter)
widget:connect_signal("button::press", button_press) --widget:connect_signal("button::press", button_press)
widget:connect_signal("button::release", button_release) --widget:connect_signal("button::release", button_release)
widget:connect_signal("mouse::leave", mouse_leave) widget:connect_signal("mouse::leave", mouse_leave)
end end

Submodule awesome/src/lib/lgi-async-extra added at 45281ceaf4

View File

@@ -9,6 +9,12 @@ local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears") local gears = require("gears")
local wibox = require("wibox") local wibox = require("wibox")
local json = require("src.lib.json-lua.json-lua")
local cm = require("src.modules.context_menu")
local icondir = awful.util.getdir("config") .. "src/assets/icons/context_menu/"
return function() return function()
local application_grid = wibox.widget { local application_grid = wibox.widget {
@@ -34,7 +40,6 @@ return function()
---@return table widgets Unsorted widget table ---@return table widgets Unsorted widget table
local function get_applications_from_file() local function get_applications_from_file()
local list = {} local list = {}
--for _, file in ipairs(desktop_files) do
local app_info = Gio.AppInfo local app_info = Gio.AppInfo
local apps = app_info.get_all() local apps = app_info.get_all()
for _, app in ipairs(apps) do for _, app in ipairs(apps) do
@@ -83,8 +88,9 @@ return function()
comment = Gio.DesktopAppInfo.get_string(desktop_app_info, "Comment") or "", comment = Gio.DesktopAppInfo.get_string(desktop_app_info, "Comment") or "",
exec = Gio.DesktopAppInfo.get_string(desktop_app_info, "Exec"), exec = Gio.DesktopAppInfo.get_string(desktop_app_info, "Exec"),
keywords = Gio.DesktopAppInfo.get_string(desktop_app_info, "Keywords") or "", keywords = Gio.DesktopAppInfo.get_string(desktop_app_info, "Keywords") or "",
categories = Gio.DesktopAppInfo.get_string(desktop_app_info, "Cathegory") or "", categories = Gio.DesktopAppInfo.get_categories(desktop_app_info) or "",
terminal = Gio.DesktopAppInfo.get_string(desktop_app_info, "Terminal") == "true", terminal = Gio.DesktopAppInfo.get_string(desktop_app_info, "Terminal") == "true",
actions = Gio.DesktopAppInfo.list_actions(desktop_app_info),
border_color = Theme_config.application_launcher.application.border_color, border_color = Theme_config.application_launcher.application.border_color,
border_width = Theme_config.application_launcher.application.border_width, border_width = Theme_config.application_launcher.application.border_width,
bg = Theme_config.application_launcher.application.bg, bg = Theme_config.application_launcher.application.bg,
@@ -95,18 +101,84 @@ return function()
widget = wibox.container.background widget = wibox.container.background
} }
local context_menu = cm({
entries = {
{
name = "Execute as sudo",
icon = gears.color.recolor_image(icondir .. "launch.svg", Theme_config.context_menu.icon_color),
callback = function()
awesome.emit_signal("application_launcher::show")
awful.spawn("/home/crylia/.config/awesome/src/scripts/start_as_admin.sh " .. app_widget.exec)
end
},
{
name = "Pin to dock",
icon = gears.color.recolor_image(icondir .. "pin.svg", Theme_config.context_menu.icon_color),
callback = function()
local handler = io.open("/home/crylia/.config/awesome/src/config/dock.json", "r")
if not handler then
return
end
local dock_table = json:decode(handler:read("a")) or {}
handler:close()
---@diagnostic disable-next-line: param-type-mismatch
table.insert(dock_table, {
name = app_widget.name or "",
icon = Get_gicon_path(app_info.get_icon(app)) or "",
comment = app_widget.comment or "",
exec = app_widget.exec or "",
keywords = app_widget.keywords or "",
categories = app_widget.categories or "",
terminal = app_widget.terminal or "",
actions = app_widget.actions or "",
desktop_file = Gio.DesktopAppInfo.get_filename(desktop_app_info) or ""
})
local dock_encoded = json:encode(dock_table)
handler = io.open("/home/crylia/.config/awesome/src/config/dock.json", "w")
if not handler then
return
end
handler:write(dock_encoded)
handler:close()
awesome.emit_signal("dock::changed")
end
},
{
name = "Add to desktop",
icon = gears.color.recolor_image(icondir .. "desktop.svg", Theme_config.context_menu.icon_color),
callback = function()
awesome.emit_signal("application_launcher::show")
--!TODO: Add to desktop
end
}
}
})
-- Execute command on left click and hide launcher -- Execute command on left click and hide launcher
app_widget:buttons( app_widget:buttons(
gears.table.join( gears.table.join(
awful.button( awful.button({
{}, modifiers = {},
1, button = 1,
nil, on_release = function()
function() Gio.AppInfo.launch_uris_async(app)
awful.spawn.with_shell(app_widget.exec)
awesome.emit_signal("application_launcher::show") awesome.emit_signal("application_launcher::show")
end end
) }),
awful.button({
modifiers = {},
button = 3,
on_release = function()
if not context_menu then
return
end
-- add offset so mouse is above widget, this is so the mouse::leave event triggers always
context_menu.x = mouse.coords().x - 10
context_menu.y = mouse.coords().y - 10
context_menu.visible = not context_menu.visible
end
})
) )
) )
Hover_signal(app_widget) Hover_signal(app_widget)
@@ -220,15 +292,7 @@ return function()
awesome.emit_signal("searchbar::stop") awesome.emit_signal("searchbar::stop")
local selected_widget = application_grid:get_widgets_at(curser.y, curser.x)[1] local selected_widget = application_grid:get_widgets_at(curser.y, curser.x)[1]
if selected_widget.terminal then Gio.AppInfo.launch_uris_async(Gio.AppInfo.create_from_commandline(selected_widget.exec, nil, 0))
awful.spawn(User_config.terminal ..
" -e " ..
selected_widget.exec:gsub("%%F", ""):gsub("%%u", ""):gsub("%%U", ""):gsub("%%f", ""):gsub("%%i", ""):gsub("%%c"
, ""):gsub("%%k", ""))
else
awful.spawn.with_shell(selected_widget.exec:gsub("%%F", ""):gsub("%%u", ""):gsub("%%U", ""):gsub("%%f", ""):gsub("%%i"
, ""):gsub("%%c", ""):gsub("%%k", ""))
end
end end
) )

View File

@@ -62,6 +62,9 @@ return function(s)
function() function()
if mouse.screen == s then if mouse.screen == s then
application_container.visible = not application_container.visible application_container.visible = not application_container.visible
if application_container.visible == false then
awesome.emit_signal("searchbar::stop")
end
end end
if application_container.visible then if application_container.visible then
awesome.emit_signal("searchbar::start") awesome.emit_signal("searchbar::start")

View File

@@ -243,7 +243,6 @@ return function()
searchbar.s_background.fg = Theme_config.application_launcher.searchbar.fg searchbar.s_background.fg = Theme_config.application_launcher.searchbar.fg
search_text:set_markup(promt_text_with_cursor("", 1)) search_text:set_markup(promt_text_with_cursor("", 1))
end end
end end
) )

View File

@@ -0,0 +1,112 @@
---------------------------------------
-- This is the brightness_osd module --
---------------------------------------
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
return function(args)
if not args then
return
end
local function get_entries()
local menu_entries = { layout = wibox.layout.fixed.vertical, spacing = dpi(10) }
if args.entries then
for _, entry in ipairs(args.entries) do
local menu_entry = wibox.widget {
{
{
{
{ -- Icon
widget = wibox.widget.imagebox,
image = gears.color.recolor_image(entry.icon, Theme_config.context_menu.entry.icon_color),
valign = "center",
halign = "center",
resize = true,
icon = entry.icon,
id = "icon"
},
widget = wibox.container.constraint,
stragety = "exact",
width = dpi(24),
height = dpi(24),
id = "const"
},
{ -- Text
widget = wibox.widget.textbox,
text = entry.name,
id = "name"
},
id = "lay",
spacing = dpi(5),
layout = wibox.layout.fixed.horizontal
},
margins = dpi(10),
widget = wibox.container.margin,
id = "mar"
},
bg = Theme_config.context_menu.entry.bg,
fg = Theme_config.context_menu.entry.fg,
shape = Theme_config.context_menu.entry.shape,
border_width = Theme_config.context_menu.entry.border_width,
border_color = Theme_config.context_menu.entry.border_color,
widget = wibox.container.background,
id = "menu_entry"
}
menu_entry:buttons(gears.table.join(
awful.button({
modifiers = {},
button = 1,
on_release = function()
awesome.emit_signal("context_menu::hide")
entry.callback()
end
})
))
Hover_signal(menu_entry, nil, Theme_config.context_menu.entry.hover_fg,
Theme_config.context_menu.entry.hover_border, Theme_config.context_menu.entry.icon_color,
Theme_config.context_menu.entry.icon_color_hover)
table.insert(menu_entries, menu_entry)
end
end
return menu_entries
end
local menu = awful.popup {
widget = {
get_entries(),
margins = dpi(10),
widget = wibox.container.margin
},
bg = Theme_config.context_menu.bg,
fg = Theme_config.context_menu.fg,
border_width = Theme_config.context_menu.border_width,
border_color = Theme_config.context_menu.border_color,
shape = Theme_config.context_menu.shape,
x = mouse.coords().x,
y = mouse.coords().y,
visible = false,
ontop = true,
placement = awful.placement.no_offscreen,
}
menu:connect_signal("mouse::leave", function()
awesome.emit_signal("context_menu::hide")
end)
awesome.connect_signal(
"context_menu::hide",
function()
menu.visible = false
end
)
return menu
end

View File

@@ -3,30 +3,29 @@
-------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------
-- Awesome Libs -- Awesome Libs
local awful = require("awful") local awful = require("awful")
local async = require("async")
local dpi = require("beautiful").xresources.apply_dpi local dpi = require("beautiful").xresources.apply_dpi
local Gio = require("lgi").Gio local Gio = require("lgi").Gio
local gears = require("gears") local gears = require("gears")
local wibox = require("wibox") local wibox = require("wibox")
return function(screen, programs) local json = require("src.lib.json-lua.json-lua")
local icondir = awful.util.getdir("config") .. "src/assets/icons/context_menu/"
local cm = require("src.modules.context_menu")
return function(screen)
local cm_open = false
local dock_element_ammount = 0
---Creates a new program widget for the dock ---Creates a new program widget for the dock
---@param program string | nil The name of the .desktop file ---@param program string | function The name of the .desktop file
---@param size number The size of the widget ---@param size number The size of the widget
---@return widox.widget | nil The widget or nil if the program is not found ---@return widox.widget | nil The widget or nil if the program is not found
local function create_dock_element(program, size) local function create_dock_element(program, size)
if not program then
return
end
local desktop_app_info = Gio.DesktopAppInfo.new_from_filename(program)
if not desktop_app_info then
return
end
local gicon = Gio.Icon.new_for_string(Gio.DesktopAppInfo.get_string(desktop_app_info, "Icon"))
if not gicon then
return
end
local dock_element = wibox.widget { local dock_element = wibox.widget {
{ {
@@ -35,7 +34,7 @@ return function(screen, programs)
{ {
resize = true, resize = true,
widget = wibox.widget.imagebox, widget = wibox.widget.imagebox,
image = Get_gicon_path(gicon) or "", image = program.icon or "",
valign = "center", valign = "center",
halign = "center", halign = "center",
id = "icon", id = "icon",
@@ -64,36 +63,153 @@ return function(screen, programs)
widget = wibox.container.margin widget = wibox.container.margin
} }
for _, c in ipairs(client.get()) do
if string.lower(c.class):match(Get_gicon_path(gicon) or "") and c == client.focus then
dock_element.background.bg = Theme_config.dock.element_focused_bg
end
end
Hover_signal(dock_element.background, Theme_config.dock.element_focused_bg .. "dd") Hover_signal(dock_element.background, Theme_config.dock.element_focused_bg .. "dd")
dock_element:connect_signal( local DAI = Gio.DesktopAppInfo.new_from_filename(program.desktop_file)
"button::press",
function(_, _, _, button) local action_entries = {}
if button == 1 then for _, action in ipairs(program.actions) do
awful.spawn(Gio.DesktopAppInfo.get_string(desktop_app_info, "Exec"):gsub("%%F", ""):gsub("%%u", ""):gsub("%%U" table.insert(action_entries, {
, ""):gsub("%%f", ""):gsub("%%i", ""):gsub("%%c" name = Gio.DesktopAppInfo.get_action_name(DAI, action) or "",
, ""):gsub("%%k", "")) icon = action.icon or icondir .. "entry.svg",
callback = function()
Gio.DesktopAppInfo.launch_action(DAI, action)
end end
})
end
table.insert(action_entries, {
name = "Remove from Dock",
icon = icondir .. "entry.svg",
callback = function()
local data = io.open("/home/crylia/.config/awesome/src/config/dock.json", "r")
if not data then
return
end
local dock = json:decode(data:read("a"))
data:close()
for i, v in ipairs(dock) do
if v.desktop_file == program.desktop_file then
if type(dock) == "table" then
table.remove(dock, i)
end
break
end
end
data = io.open("/home/crylia/.config/awesome/src/config/dock.json", "w")
if not data then
return
end
data:write(json:encode(dock))
data:close()
awesome.emit_signal("dock::changed")
end
})
local context_menu = cm({
entries = action_entries
})
dock_element:buttons(gears.table.join(
awful.button({
modifiers = {},
button = 1,
on_release = function()
Gio.AppInfo.launch_uris_async(Gio.AppInfo.create_from_commandline(program.exec, nil, 0))
end
}),
awful.button({
modifiers = {},
button = 3,
on_release = function()
if not context_menu then
return
end
-- add offset so mouse is above widget, this is so the mouse::leave event triggers always
context_menu.x = mouse.coords().x - 10
context_menu.y = mouse.coords().y + 10 - context_menu.height
context_menu.visible = not context_menu.visible
cm_open = context_menu.visible
end
})
))
awesome.connect_signal(
"context_menu::hide",
function()
cm_open = false
awesome.emit_signal("dock::check_for_dock_hide")
end end
) )
awful.tooltip { awful.tooltip {
objects = { dock_element }, objects = { dock_element },
text = Gio.DesktopAppInfo.get_string(desktop_app_info, "Name"), text = program.name,
mode = "outside", mode = "outside",
preferred_alignments = "middle", preferred_alignments = "middle",
margins = dpi(10) margins = dpi(10)
} }
dock_element_ammount = dock_element_ammount + 1
return dock_element return dock_element
end end
--- Indicators under the elements to indicate various open states
local function create_incicator_widget()
local container = { layout = wibox.layout.flex.horizontal }
local data = io.open("/home/crylia/.config/awesome/src/config/dock.json", "r")
if not data then
return
end
local prog = json:decode(data:read("a"))
for _, pr in ipairs(prog) do
local indicators = { layout = wibox.layout.flex.horizontal, spacing = dpi(5) }
local col = Theme_config.dock.indicator_bg
for _, c in ipairs(client.get()) do
local icon_name = pr.icon
if icon_name:match(string.lower(c.class or c.name)) or c.class:match(string.lower(icon_name)) or
c.name:match(string.lower(icon_name)) then
if c == client.focus then
col = Theme_config.dock.indicator_focused_bg
elseif c.urgent then
col = Theme_config.dock.indicator_urgent_bg
elseif c.maximized then
col = Theme_config.dock.indicator_maximized_bg
elseif c.minimized then
col = Theme_config.dock.indicator_minimized_bg
elseif c.fullscreen then
col = Theme_config.dock.indicator_fullscreen_bg
else
col = Theme_config.dock.indicator_bg
end
table.insert(indicators, wibox.widget {
widget = wibox.container.background,
shape = gears.shape.rounded_rect,
forced_height = dpi(3),
bg = col,
forced_width = dpi(5),
})
end
end
table.insert(container, wibox.widget {
indicators,
forced_height = dpi(5),
forced_width = dpi(User_config.dock_icon_size),
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin,
})
end
return wibox.widget {
container,
bottom = dpi(5),
widget = wibox.container.margin,
}
end
--- The container bar where the elements/program widgets sit in --- The container bar where the elements/program widgets sit in
local dock = awful.popup { local dock = awful.popup {
widget = wibox.container.background, widget = wibox.container.background,
@@ -122,27 +238,37 @@ return function(screen, programs)
placement = function(c) awful.placement.bottom(c) end, placement = function(c) awful.placement.bottom(c) end,
} }
--- This function creates a list with all dock elements/program widgets --- List of all elements/program widgets
---@param pr table A list of .desktop files
---@return table string list of widgets
local function get_dock_elements(pr)
local dock_elements = { layout = wibox.layout.fixed.horizontal } local dock_elements = { layout = wibox.layout.fixed.horizontal }
for i, p in ipairs(pr) do --- This function creates a list with all dock elements/program widgets
dock_elements[i] = create_dock_element(Get_desktop_values(p), User_config.dock_icon_size) ---@return table|nil string list of widgets
local function get_dock_elements()
dock_element_ammount = 0
dock_elements = { layout = wibox.layout.fixed.horizontal }
local data = io.open("/home/crylia/.config/awesome/src/config/dock.json", "r")
if not data then
return
end
local dock_data = json:decode(data:read("a"))
for _, program in ipairs(dock_data) do
table.insert(dock_elements, create_dock_element(program, User_config.dock_icon_size))
end
dock:setup {
dock_elements,
create_incicator_widget(),
layout = wibox.layout.fixed.vertical
}
end end
return dock_elements get_dock_elements()
end
--- List of all elements/program widgets
local dock_elements = get_dock_elements(programs)
--- Function to get an empty list with the same ammount as dock_element --- Function to get an empty list with the same ammount as dock_element
local function get_fake_elements(amount) local function get_fake_elements()
local fake_elements = { layout = wibox.layout.fixed.horizontal } local fake_elements = { layout = wibox.layout.fixed.horizontal }
for i = 0, amount, 1 do for i = 0, dock_element_ammount, 1 do
fake_elements[i] = wibox.widget { fake_elements[i] = wibox.widget {
bg = '00000000', bg = '00000000',
forced_width = User_config.dock_icon_size + dpi(20), forced_width = User_config.dock_icon_size + dpi(20),
@@ -154,64 +280,8 @@ return function(screen, programs)
return fake_elements return fake_elements
end end
--- Indicators under the elements to indicate various open states
local function create_incicator_widget(prog)
local container = { layout = wibox.layout.flex.horizontal }
local clients = client.get()
for index, pr in ipairs(prog) do
local desktop_app_info = Gio.DesktopAppInfo.new_from_filename(Get_desktop_values(pr))
if desktop_app_info then
local gicon = Gio.Icon.new_for_string(Gio.DesktopAppInfo.get_string(desktop_app_info, "Icon"))
if gicon then
local indicators = { layout = wibox.layout.flex.horizontal, spacing = dpi(5) }
local col = Theme_config.dock.indicator_bg
for i, c in ipairs(clients) do
local icon_name = Get_gicon_path(gicon) or ""
if icon_name:match(string.lower(c.class or c.name)) or c.class:match(string.lower(icon_name)) or
c.name:match(string.lower(icon_name)) then
if c == client.focus then
col = Theme_config.dock.indicator_focused_bg
elseif c.urgent then
col = Theme_config.dock.indicator_urgent_bg
elseif c.maximized then
col = Theme_config.dock.indicator_maximized_bg
elseif c.minimized then
col = Theme_config.dock.indicator_minimized_bg
elseif c.fullscreen then
col = Theme_config.dock.indicator_fullscreen_bg
else
col = Theme_config.dock.indicator_bg
end
indicators[i] = wibox.widget {
widget = wibox.container.background,
shape = gears.shape.rounded_rect,
forced_height = dpi(3),
bg = col,
forced_width = dpi(5),
}
end
end
container[index] = wibox.widget {
indicators,
forced_height = dpi(5),
forced_width = dpi(User_config.dock_icon_size),
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin,
}
end
end
end
return wibox.widget {
container,
bottom = dpi(5),
widget = wibox.container.margin,
}
end
fakedock:setup { fakedock:setup {
get_fake_elements(#programs), get_fake_elements(),
type = 'dock', type = 'dock',
layout = wibox.layout.fixed.vertical layout = wibox.layout.fixed.vertical
} }
@@ -302,7 +372,12 @@ return function(screen, programs)
check_for_dock_hide(screen) check_for_dock_hide(screen)
dock:setup { dock:setup {
dock_elements, dock_elements,
create_incicator_widget(programs), create_incicator_widget(),
layout = wibox.layout.fixed.vertical
}
fakedock:setup {
get_fake_elements(),
type = 'dock',
layout = wibox.layout.fixed.vertical layout = wibox.layout.fixed.vertical
} }
end end
@@ -314,7 +389,12 @@ return function(screen, programs)
check_for_dock_hide(screen) check_for_dock_hide(screen)
dock:setup { dock:setup {
dock_elements, dock_elements,
create_incicator_widget(programs), create_incicator_widget(),
layout = wibox.layout.fixed.vertical
}
fakedock:setup {
get_fake_elements(),
type = 'dock',
layout = wibox.layout.fixed.vertical layout = wibox.layout.fixed.vertical
} }
end end
@@ -326,7 +406,12 @@ return function(screen, programs)
check_for_dock_hide(screen) check_for_dock_hide(screen)
dock:setup { dock:setup {
dock_elements, dock_elements,
create_incicator_widget(programs), create_incicator_widget(),
layout = wibox.layout.fixed.vertical
}
fakedock:setup {
get_fake_elements(),
type = 'dock',
layout = wibox.layout.fixed.vertical layout = wibox.layout.fixed.vertical
} }
end end
@@ -338,9 +423,38 @@ return function(screen, programs)
check_for_dock_hide(screen) check_for_dock_hide(screen)
dock:setup { dock:setup {
dock_elements, dock_elements,
create_incicator_widget(programs), create_incicator_widget(),
layout = wibox.layout.fixed.vertical layout = wibox.layout.fixed.vertical
} }
fakedock:setup {
get_fake_elements(),
type = 'dock',
layout = wibox.layout.fixed.vertical
}
end
)
awesome.connect_signal(
"dock::changed",
function()
get_dock_elements()
dock:setup {
dock_elements,
create_incicator_widget(),
layout = wibox.layout.fixed.vertical
}
fakedock:setup {
get_fake_elements(),
type = 'dock',
layout = wibox.layout.fixed.vertical
}
end
)
awesome.connect_signal(
"dock::check_for_dock_hide",
function()
dock_intelligent_hide:again()
end end
) )
@@ -354,13 +468,16 @@ return function(screen, programs)
dock:connect_signal( dock:connect_signal(
"mouse::leave", "mouse::leave",
function() function()
if cm_open then
return
end
check_for_dock_hide(screen) check_for_dock_hide(screen)
dock_intelligent_hide:again() dock_intelligent_hide:again()
end end
) )
dock:setup { dock:setup {
dock_elements, dock_elements,
create_incicator_widget(programs), create_incicator_widget(),
layout = wibox.layout.fixed.vertical layout = wibox.layout.fixed.vertical
} }
end end

View File

@@ -67,5 +67,5 @@ return function(s)
end end
end end
end end
require("src.modules.crylia_bar.dock")(s, User_config.dock_programs) require("src.modules.crylia_bar.dock")(s)
end end

View File

@@ -48,6 +48,7 @@ return function()
id = "icon", id = "icon",
--!ADD FALLBACK ICON!-- --!ADD FALLBACK ICON!--
image = Get_icon(client.class, client.name) or client.icon, image = Get_icon(client.class, client.name) or client.icon,
--image = gears.surface(client.content),
valign = "center", valign = "center",
halign = "center", halign = "center",
widget = wibox.widget.imagebox widget = wibox.widget.imagebox

View File

@@ -0,0 +1,5 @@
#!/bin/bash
PROGRAM=$1
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY $PROGRAM

View File

@@ -468,6 +468,29 @@ Theme_config.application_launcher = {
end, end,
} }
} }
Theme_config.context_menu = {
bg = color["Grey900"],
border_color = color["Grey800"],
border_width = dpi(4),
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(8))
end,
fg = color["Grey100"],
entry = {
bg = color["Grey900"],
fg = color["Grey100"],
border_color = color["Grey800"],
border_width = dpi(2),
hover_fg = color["Teal200"],
hover_border = color["Teal200"],
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(4))
end,
icon_color = color["Grey100"],
icon_color_hover = color["Teal200"]
}
}
--#endregion --#endregion
--[[ --[[

View File

@@ -70,32 +70,6 @@ User_config = {
]] -- ]] --
dock_icon_size = dpi(64), dock_icon_size = dpi(64),
--[[
Add your programs to the dock. You need to provide the name of the .desktop file
You can find those in the /usr/share/applications or $HOME/.local/share/applications directory.
Some .desktop files are more hidden, for more information look at: $XDG_DATA_DIRS/applications
Example:
"com.alacritty.Alacritty.desktop",
"com.spotify.Client.desktop",
"firefox.desktop",
]] --
dock_programs = {
"com.alacritty.Alacritty.desktop",
"com.brave.Browser.desktop",
"steam.desktop",
"discord.desktop",
"spotify.desktop",
"code.desktop",
"arduino-arduinoide.desktop",
"us.zoom.Zoom.desktop",
"thunderbird.desktop",
"appimagekit_5de59b772d786d6e98102a035c80e40c-Ultimaker_Cura.desktop",
"blender.desktop",
"freecad.desktop",
"The Witcher 3 Wild Hunt.desktop",
"Microsoft Flight Simulator.desktop"
},
--[[ --[[
This is the program that will be started when clicking on the battery widget This is the program that will be started when clicking on the battery widget
If you don't want any just leave it as nil If you don't want any just leave it as nil

View File

@@ -2,6 +2,6 @@ local awful = require("awful")
return function(table) return function(table)
for _, t in ipairs(table) do for _, t in ipairs(table) do
awful.spawn(t); --awful.spawn(t);
end end
end end