8 changed files with 2188 additions and 1785 deletions
Binary file not shown.
@ -0,0 +1,100 @@
|
||||
local wibox = require("wibox") |
||||
local awful = require("awful") |
||||
local beautiful = require("beautiful") |
||||
local gears = require("gears") |
||||
local naughty = require("naughty") |
||||
|
||||
local xresources = require("beautiful.xresources") |
||||
local dpi = xresources.apply_dpi |
||||
|
||||
local dockbox = require("lib.dockbox") |
||||
|
||||
local countIndicator = function() |
||||
return wibox.widget { |
||||
bg = beautiful.fg_normal, |
||||
shape = function(cr, width, height) |
||||
gears.shape.partially_rounded_rect(cr, width, height, false, true, true, false, dpi(50)) |
||||
end, |
||||
forced_height = dpi(6), |
||||
widget = wibox.container.background |
||||
} |
||||
end |
||||
|
||||
return function(fg, fg_hover, text, app) |
||||
local count = 0 |
||||
local countWidget = wibox.layout.fixed.vertical() |
||||
countWidget.forced_width = dpi(5) |
||||
countWidget.spacing = dpi(2) |
||||
|
||||
local clientIsApp = function(c) |
||||
-- returns if the client c is the same as the sidebarbox-app (e.g. firefox, kitty, ...) |
||||
-- some fiddling needed, is kinda hacky |
||||
|
||||
if app == "intellij-idea-ultimate-edition" and c.class == "jetbrains-idea" then |
||||
-- hmm |
||||
return true |
||||
elseif c.class ~= nil then |
||||
return string.lower(c.class) == string.lower(app) |
||||
elseif c.instance ~= nil then |
||||
return string.lower(c.instance) == string.lower(app) |
||||
elseif c.name ~= nil then |
||||
return string.lower(c.name) == string.lower(app) |
||||
else |
||||
return false |
||||
end |
||||
end |
||||
|
||||
client.connect_signal("manage", function(c) |
||||
if clientIsApp(c) then |
||||
count = count + 1 |
||||
|
||||
-- don't add unlimited indicators |
||||
if count < 6 then |
||||
countWidget:insert(1, countIndicator()) |
||||
end |
||||
end |
||||
end) |
||||
|
||||
client.connect_signal("unmanage", function(c) |
||||
if clientIsApp(c) then |
||||
count = count - 1 |
||||
if count < 5 then |
||||
countWidget:remove(1) |
||||
end |
||||
end |
||||
end) |
||||
|
||||
local findApp = function() |
||||
-- open client if at already exists |
||||
-- spawn new client otherwise |
||||
if count > 0 then |
||||
for _, tag in pairs(root.tags()) do |
||||
for _, c in pairs(tag:clients()) do |
||||
if clientIsApp(c) then |
||||
c:jump_to(false) |
||||
return |
||||
end |
||||
end |
||||
end |
||||
else |
||||
awful.spawn(app) |
||||
end |
||||
end |
||||
|
||||
return wibox.widget { |
||||
{ |
||||
nil, |
||||
countWidget, |
||||
nil, |
||||
expand = "none", |
||||
widget = wibox.layout.align.vertical |
||||
}, |
||||
dockbox(fg, fg_hover, text, function() |
||||
findApp() |
||||
|
||||
awesome.emit_signal("dashboard::close") |
||||
end), |
||||
spacing = dpi(2), |
||||
layout = wibox.layout.fixed.horizontal |
||||
} |
||||
end |
||||
@ -0,0 +1,141 @@
|
||||
local awful = require("awful") |
||||
local wibox = require("wibox") |
||||
local gears = require("gears") |
||||
local beautiful = require("beautiful") |
||||
local dpi = require("beautiful.xresources").apply_dpi |
||||
|
||||
local dock = require("widgets.dock.dock") |
||||
|
||||
local width = 68 |
||||
local openerWidth = 8 |
||||
local height = 376 |
||||
|
||||
local dock_container = wibox({ |
||||
visible = true, |
||||
ontop = true, |
||||
type = "dock", |
||||
screen = screen.primary, |
||||
x = 0, |
||||
y = beautiful.bar_height + (awful.screen.focused().geometry.height - height - beautiful.bar_height) / 2, |
||||
width = dpi(width + openerWidth), |
||||
height = dpi(height), |
||||
bg = "#00000000" |
||||
}) |
||||
|
||||
local dock_opener = wibox.widget { |
||||
bg = beautiful.bg_normal, |
||||
forced_width = dpi(openerWidth), |
||||
input_passthrough = true, |
||||
bg = "#00000000", |
||||
widget = wibox.container.background |
||||
} |
||||
|
||||
local mouse_in_dock = false |
||||
|
||||
local get_fullscreen = function() |
||||
tag = awful.screen.focused().selected_tag |
||||
|
||||
for _, client in pairs(tag:clients()) do |
||||
if client.fullscreen then |
||||
return true |
||||
end |
||||
end |
||||
|
||||
return false |
||||
end |
||||
|
||||
local get_auto_hide = function(tag) |
||||
if tag == nil then tag = awful.screen.focused().selected_tag end |
||||
|
||||
-- auto hiding if any client on the current tag overlaps the dock |
||||
for _, client in pairs(tag:clients()) do |
||||
if client.x < width then |
||||
return true |
||||
end |
||||
end |
||||
|
||||
return false |
||||
end |
||||
|
||||
local show_cb = function() |
||||
if not mouse_in_dock and get_auto_hide() then return false end |
||||
|
||||
local delta = 2 |
||||
|
||||
if dock_container.x < 0 then |
||||
dock_container.x = dock_container.x + delta |
||||
return true |
||||
else |
||||
return false |
||||
end |
||||
end |
||||
|
||||
local hide_cb = function() |
||||
if mouse_in_dock or not get_auto_hide() then return false end |
||||
|
||||
local delta = 2 |
||||
|
||||
if dock_container.x > -width then |
||||
dock_container.x = dock_container.x - delta |
||||
return true |
||||
else |
||||
return false |
||||
end |
||||
end |
||||
|
||||
local show = function() |
||||
gears.timer.start_new(0.002, show_cb) |
||||
end |
||||
|
||||
local hide = function() |
||||
gears.timer.start_new(0.002, hide_cb) |
||||
end |
||||
|
||||
dock_opener:connect_signal("mouse::enter", function() |
||||
if get_fullscreen() then return end |
||||
|
||||
mouse_in_dock = true |
||||
show() |
||||
end) |
||||
dock_opener:connect_signal("mouse::leave", function() |
||||
mouse_in_dock = false |
||||
hide() |
||||
end) |
||||
|
||||
dock:connect_signal("mouse::leave", function() |
||||
mouse_in_dock = false |
||||
hide() |
||||
end) |
||||
|
||||
dock:connect_signal("mouse::enter", function() |
||||
mouse_in_dock = true |
||||
show() |
||||
end) |
||||
|
||||
local update = function(tag) |
||||
if tag == nil then |
||||
tag = awful.screen.focused().selected_tag |
||||
end |
||||
|
||||
if get_auto_hide(tag) and not mouse_in_dock then |
||||
hide() |
||||
else |
||||
show() |
||||
end |
||||
end |
||||
|
||||
client.connect_signal("manage", function() update() end) |
||||
client.connect_signal("unmanage", function() update() end) |
||||
client.connect_signal("property::size", function() update() end) |
||||
client.connect_signal("property::position", function() update() end) |
||||
client.connect_signal("tagged", function() update() end) |
||||
tag.connect_signal("property::layout", function(t) update(t) end) |
||||
tag.connect_signal("property::selected", function(t) update(t) end) |
||||
|
||||
dock_container:setup { |
||||
dock, |
||||
dock_opener, |
||||
layout = wibox.layout.fixed.horizontal |
||||
} |
||||
|
||||
update() |
||||
|
Before Width: | Height: | Size: 235 KiB After Width: | Height: | Size: 235 KiB |
Loading…
Reference in new issue