123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- local awful = require("awful")
- local gears = require("gears")
- local beautiful = require("beautiful")
- local wibox = require("wibox")
- local naughty = require("naughty")
- local dpi = require("beautiful.xresources").apply_dpi
- local HOME = os.getenv('HOME')
- local ICON_DIR = HOME .. '/.config/awesome/widgets/dock/icons/'
- local rows = { layout = wibox.layout.fixed.vertical }
- local menu_items = {
- { name = 'Blender', icon_name = 'blender.svg', command = function() awful.spawn("blender") end },
- { name = 'Krita', icon_name = 'blender.svg', command = function() awful.spawn("krita") end },
- }
- --blender:connect_signal("button::press", function() awful.spawn("blender") end)
- function update_dock(s)
- -- How do I access and modify dock_items (id = "dock_items") from here?
- -- I can access the dock_bar itself: s.dock_bar,
- -- because it's part of the screen object I get from func arguments.
- end
- function create_dock(s)
- s.dockheight = (55 * s.workarea.height)/100
- s.dock_bar = awful.wibar({
- position = "left",
- screen = s,
- x=0,
- y=s.workarea.height/2 - s.dockheight/2,
- --ontop = true,
- width = dpi(9),
- height = s.dockheight,
- type = "dock"
- })
- local dock_items = {
- layout = wibox.layout.fixed.horizontal,
- id = "dock_items",
- {
- markup = "Sample Text",
- widget = wibox.widget.textbox
- },
- offset = {
- y = 10,
- },
- widget = wibox.container.rotate
- }
- if s.index > 1 and s.dock_bar.y == 0 then
- s.dock_bar.y = screen[1].dock_bar.y
- end
- s.dock_bar:setup {
- layout = wibox.layout.align.horizontal,
- expand = "outside",
- nil, -- Left
- dock_items -- Middle
- }
- -- Add toggling functionalities
- s.docktimer = gears.timer{ timeout = 2 }
- s.docktimer:connect_signal("timeout", function()
- local s = awful.screen.focused()
- s.dock_bar.width = dpi(9)
- if s.docktimer.started then
- s.docktimer:stop()
- end
- end)
- tag.connect_signal("property::selected", function(t)
- local s = t.screen or awful.screen.focused()
- s.dock_bar.width = dpi(38)
- if not s.docktimer.started then
- s.docktimer:start()
- end
- end)
- s.dock_bar:connect_signal("mouse::leave", function()
- local s = awful.screen.focused()
- s.dock_bar.width = dpi(9)
- end)
- s.dock_bar:connect_signal("mouse::enter", function()
- local s = awful.screen.focused()
- s.dock_bar.width = dpi(38)
- end)
- end
- -- Add dock only to the first screen
- --create_dock(screen[1])
- awful.screen.connect_for_each_screen(create_dock)
- -- Call update_dock when adding/removeing clients
- client.connect_signal("list", function(c) update_dock(screen[1]) end)
|