awesome-navbar/init.lua

73 lines
2.2 KiB
Lua
Raw Permalink Normal View History

2022-08-25 15:10:36 +10:00
local gears = require("gears")
local awful = require("awful")
local wibox = require("wibox")
local switcherpopup = require("awesome-switcherpopup")
local launcherpopup = require("awesome-launcherpopup")
local longpress = require("awesome-longpress")
2022-08-25 16:25:43 +10:00
local vkbd = require("vkbd")
2022-08-25 15:10:36 +10:00
2022-08-25 15:07:44 +10:00
local navbar = {
iconSize = 96,
iconPath = gears.filesystem.get_configuration_dir() .. "/awesome-navbar/",
launcher = launcher or "xfce4-appfinder"
2022-08-25 15:07:44 +10:00
}
2022-08-25 15:10:36 +10:00
2022-08-25 15:07:44 +10:00
function navbar.new(s)
local landscape = s.geometry.width > s.geometry.height
local portrait = not landscape
s.tasklist = switcherpopup.new(s)
s.launcher = launcherpopup.new(s)
2022-08-25 15:07:44 +10:00
local switcher_button = wibox.container.place(awful.widget.button({image = navbar.iconPath .. "/switcher.svg"}), "center", "center")
switcher_button:buttons(gears.table.join(
switcher_button:buttons(),
awful.button({}, 1, nil, function()
s.launcher:hide()
s.tasklist:toggle()
2022-08-25 15:07:44 +10:00
end)
))
local kb_button = wibox.container.place(awful.widget.button({image = navbar.iconPath .. "/keyboard.svg"}), "center", "center")
kb_button:buttons(gears.table.join(
kb_button:buttons(),
awful.button({}, 1, nil, function()
s.keyboard.visible = not s.keyboard.visible
end)
))
local launcher_button = wibox.container.place(awful.widget.button({image = navbar.iconPath .. "/launcher.svg"}), "center", "center")
longpress.add(launcher_button,function()
s.tasklist:hide()
s.launcher:toggle()
2022-08-25 15:07:44 +10:00
end,
function()
awful.spawn(navbar.launcher)
end)
2022-08-25 15:15:00 +10:00
local rnavbar = awful.wibar({
2022-08-25 16:25:43 +10:00
position = landscape and "left" or "bottom",
height = (portrait and 96) or nil,
width = (landscape and 96) or nil,
2022-08-25 15:07:44 +10:00
ontop = true,
screen = s
})
2022-08-25 16:25:43 +10:00
rnavbar:setup({
layout = landscape and wibox.layout.ratio.vertical or wibox.layout.ratio.horizontal, launcher_button, switcher_button, kb_button
})
2022-08-25 15:07:44 +10:00
s.keyboard = awful.wibar({
height = s.geometry.height * 0.25,
opacity = 0.75,
position = "bottom",
visible = false,
ontop = true,
screen = s
})
2022-08-25 15:10:36 +10:00
vkbd.spacing = 1
2022-08-25 16:25:43 +10:00
vkbd.init("ansi")
2022-08-25 15:07:44 +10:00
s.keyboard:setup ({
layout = wibox.layout.ratio.horizontal,
vkbd
})
2022-08-25 15:15:00 +10:00
return rnavbar
2022-08-25 15:07:44 +10:00
end
2022-08-25 15:17:20 +10:00
return navbar