diff --git a/.config/awesome/.gitignore b/.config/awesome/.gitignore index 8a7ff70..9bbbeea 100644 --- a/.config/awesome/.gitignore +++ b/.config/awesome/.gitignore @@ -1,2 +1 @@ -libs .luarc.json diff --git a/.config/awesome/components/keybinds/client.lua b/.config/awesome/components/keybinds/client.lua deleted file mode 100644 index 35680c4..0000000 --- a/.config/awesome/components/keybinds/client.lua +++ /dev/null @@ -1,15 +0,0 @@ -local awful = require "awful" - -client.connect_signal("request::default_mousebindings", function() - awful.mouse.append_client_mousebindings({ - awful.button({ }, 1, function (c) - c:activate { context = "mouse_click" } - end), - awful.button({ modkey }, 1, function (c) - c:activate { context = "mouse_click", action = "mouse_move" } - end), - awful.button({ modkey }, 3, function (c) - c:activate { context = "mouse_click", action = "mouse_resize" } - end) - }) -end) diff --git a/.config/awesome/components/keybinds/global.lua b/.config/awesome/components/keybinds/global.lua deleted file mode 100644 index 56e4ea0..0000000 --- a/.config/awesome/components/keybinds/global.lua +++ /dev/null @@ -1,149 +0,0 @@ -local awful = require "awful" -local gears = require "gears" -local naughty = require "naughty" -local hkp = require "awful.hotkeys_popup.widget" -local vars = require "themes.prismite.vars" - -local labels = { - Control = "Ctrl", - Mod1 = "Alt", - ISO_Level3_Shift = "Alt Gr", - Mod4 = "Super", - Insert = "Ins", - Delete = "Del", - Next = "PgDn", - Prior = "PgUp", - Left = "", - Up = "", - Right = "", - Down = "", - KP_End = "Num1", - KP_Down = "Num2", - KP_Next = "Num3", - KP_Left = "Num4", - KP_Begin = "Num5", - KP_Right = "Num6", - KP_Home = "Num7", - KP_Up = "Num8", - KP_Prior = "Num9", - KP_Insert = "Num0", - KP_Delete = "Num.", - KP_Divide = "Num/", - KP_Multiply = "Num*", - KP_Subtract = "Num-", - KP_Add = "Num+", - KP_Enter = "NumEnter", - -- Some "obvious" entries are necessary for the Escape sequence - -- and whitespace characters: - Escape = "Esc", - Tab = "Tab", - space = "Space", - Return = "Enter", - -- Dead keys aren't distinct from non-dead keys because no sane - -- layout should have both of the same kind: - dead_acute = "´", - dead_circumflex = "^", - dead_grave = "`", - -- Basic multimedia keys: - XF86MonBrightnessUp = "🔆+", - XF86MonBrightnessDown = "🔅-", - XF86AudioRaiseVolume = "ﱛ", - XF86AudioLowerVolume = "ﱜ", - XF86AudioMute = "ﱝ", - XF86AudioPlay = "⏯", - XF86AudioPrev = "⏮", - XF86AudioNext = "⏭", - XF86AudioStop = "⏹", -} - -local globalkeys = gears.table.join( - -- awesome - awful.key { - modifiers = { modkey, "Control" }, - key = "r", - on_press = awesome.restart, - group = "awesome", - description = "restart awesome" - }, - awful.key { - modifiers = { modkey, "Control" }, - key = "s", - on_press = function() - hkp.new { - shape = vars.shape, - modifiers_fg = "#8893a5", - labels = labels - }:show_help() - end, - group = "awesome", - description = "toggle help" - }, - - -- general - awful.key { - modifiers = {}, - key = "XF86AudioMute", - on_press = function() - naughty.notification { - message = "mute" - } - end, - group = "general", - description = "mute audio" - }, - - -- launcher - awful.key { - modifiers = { modkey }, - key = "Return", - on_press = function () - awful.spawn("kitty") - end, - group = "launcher", - description = "launch kitty" - }, - - -- client - awful.key { - modifiers = { modkey, "Control" }, - key = "q", - on_press = function() - local c = client.focus - if c then - c:kill() - end - end, - group = "client", - description = "kill client" - }, - awful.key { - modifiers = { modkey, "Control" }, - key = "f", - on_press = function() - local c = client.focus - if c then - c.fullscreen = not c.fullscreen - end - end, - group = "client", - description = "toggle fullscreen" - }, - - -- tag - awful.key { - modifiers = { modkey }, - key = "Up", - on_press = awful.tag.viewprev, - group = "tag", - description = "switch to previous tag" - }, - awful.key { - modifiers = { modkey }, - key = "Down", - on_press = awful.tag.viewnext, - group = "tag", - description = "switch to next tag" - } -) - -root.keys(globalkeys) diff --git a/.config/awesome/components/keybinds/init.lua b/.config/awesome/components/keybinds/init.lua deleted file mode 100644 index 25b8942..0000000 --- a/.config/awesome/components/keybinds/init.lua +++ /dev/null @@ -1,4 +0,0 @@ -modkey = "Mod4" - -require "components.keybinds.global" -require "components.keybinds.client" diff --git a/.config/awesome/components/signals/awesome.lua b/.config/awesome/components/signals/awesome.lua deleted file mode 100644 index 37b9bdb..0000000 --- a/.config/awesome/components/signals/awesome.lua +++ /dev/null @@ -1,32 +0,0 @@ --- Taken from https://www.reddit.com/r/awesomewm/comments/syjolb/comment/hy0xy35/ - -awesome.connect_signal('exit', function(reason_restart) - if not reason_restart then return end - - local file = io.open('/tmp/awesomewm-last-selected-tags', 'w+') - - for s in screen do - file:write(s.selected_tag.index, '\n') - end - - file:close() -end) - -awesome.connect_signal('startup', function() - local file = io.open('/tmp/awesomewm-last-selected-tags', 'r') - if not file then return end - - local selected_tags = {} - - for line in file:lines() do - table.insert(selected_tags, tonumber(line)) - end - - for s in screen do - local i = selected_tags[s.index] - local t = s.tags[i] - t:view_only() - end - - file:close() -end) diff --git a/.config/awesome/components/signals/client.lua b/.config/awesome/components/signals/client.lua deleted file mode 100644 index 0b44d62..0000000 --- a/.config/awesome/components/signals/client.lua +++ /dev/null @@ -1,104 +0,0 @@ -local awful = require "awful" -local beautiful = require "beautiful" --- local cairo = require "lgi".cairo -local gears = require "gears" -local xresources = require "beautiful.xresources" -local dpi = xresources.apply_dpi -local wibox = require "wibox" - -client.connect_signal("property::name", function(c) - if not c then return end -- Sometimes c is nil for some reason - if not c.pid then return end - - local out = io.popen("readlink /proc/" .. c.pid .. "/exe") - local name = c.name - if out ~= nil then - name = out:read("*a"):sub(0, -2):match("[^\\/]+$") or name - end - c.name = string.lower(name) -end) - -client.connect_signal("property::urgent", function(c) - if c.class ~= "kitty" then - c:activate({ - switch_to_tag = true - }) - c.urgent = false - end -end) - -client.connect_signal("request::manage", function (c) - local parent = c.transient_for - if parent then - c:move_to_tag(parent.first_tag) - end - - if not c.pid then return end - - awful.spawn.easy_async({ "readlink", "/proc/" .. c.pid .. "/exe" }, function(name) - c.name = string.lower(name:match("[^\\/]+$") or name) - end) - - -- Forcefully set the correct icon for a client - -- Taken from https://discord.com/channels/702548301299580939/893586726885425163/947173452073287722 (Author: Orlando#0171) and modified a little bit - -- local icon_cache = Get_icon(beautiful.get().icon_theme, c) - - -- if type(icon_cache) ~= "userdata" then - -- local s = gears.surface(icon_cache) - -- local img = cairo.ImageSurface.create(cairo.Format.ARGB32, s:get_width(), s:get_height()) - -- local cr = cairo.Context(img) - -- cr:set_source_surface(s, 0, 0) - -- cr:paint() - - -- c.icon = img._native - -- end -end) - -client.connect_signal("property::maximized", function(c) - c.border_width = beautiful.border_width -end) - -client.connect_signal("request::titlebars", function(c) - local buttons = gears.table.join( - awful.button({ }, 1, function() - c:emit_signal("request::activate", "titlebar", {raise = true}) - awful.mouse.client.move(c) - end), - awful.button({ }, 3, function() - c:emit_signal("request::activate", "titlebar", {raise = true}) - awful.mouse.client.resize(c) - end) - ) - - awful.titlebar.enable_tooltip = false - - awful.titlebar(c) : setup { - -- { - -- widget = wibox.container.margin, - -- left = dpi(8), - -- awful.titlebar.widget.titlewidget(c), - -- buttons = buttons - -- }, - nil, - - { - widget = wibox.widget.base.empty_widget(), - buttons = buttons - }, - { - - { - awful.titlebar.widget.maximizedbutton (c), - awful.titlebar.widget.minimizebutton (c), - awful.titlebar.widget.closebutton (c), - - spacing = dpi(4), - layout = wibox.layout.fixed.horizontal - }, - - margins = dpi(5), - widget = wibox.container.margin, - }, - layout = wibox.layout.align.horizontal - } -end) diff --git a/.config/awesome/components/signals/init.lua b/.config/awesome/components/signals/init.lua deleted file mode 100644 index 6e42252..0000000 --- a/.config/awesome/components/signals/init.lua +++ /dev/null @@ -1,5 +0,0 @@ -require "components.signals.naughty" -require "components.signals.awesome" -require "components.signals.client" -require "components.signals.rules" -require "components.signals.screen" diff --git a/.config/awesome/components/signals/naughty.lua b/.config/awesome/components/signals/naughty.lua deleted file mode 100644 index bab4712..0000000 --- a/.config/awesome/components/signals/naughty.lua +++ /dev/null @@ -1,64 +0,0 @@ -local awful = require "awful" -local vars = require "themes.prismite.vars" -local wibox = require "wibox" -local naughty = require "naughty" -local xresources = require "beautiful.xresources" -local dpi = xresources.apply_dpi - -function build_notification(n) - - - local popup = awful.popup { - widget = { - { - { - widget = naughty.widget.icon, - image = n.image, - forced_height = 64, - forced_width = 64, - clip_shape = vars.shape - }, - { - { - widget = wibox.widget.textbox, - text = n.title - }, - { - widget = wibox.widget.textbox, - text = n.message - }, - layout = wibox.layout.fixed.vertical - }, - layout = wibox.layout.fixed.horizontal - }, - widget = wibox.container.margin, - margins = dpi(4) - }, - border_color = vars.colors.bright.black, - border_width = vars.border_width, - ontop = true, - placement = function(d) - return awful.placement.bottom_right(d, { - honor_padding = true - }) - end, - bg = vars.colors.bg, - shape = vars.shape, - } - - -- popup.y = screen[1].tiling_area.height - - dpi(4) -end - --- naughty.connect_signal("request::display", build_notification) - -naughty.connect_signal("request::display", function(n) - naughty.layout.box { notification = n } -end) - -naughty.connect_signal("request::display_error", function(message, startup) - naughty.notification { - urgency = "critical", - title = "Oops, an error happened"..(startup and " during startup!" or "!"), - message = message - } -end) diff --git a/.config/awesome/components/signals/screen.lua b/.config/awesome/components/signals/screen.lua deleted file mode 100644 index 3e49a68..0000000 --- a/.config/awesome/components/signals/screen.lua +++ /dev/null @@ -1,79 +0,0 @@ -local awful = require "awful" -local wibox = require "wibox" -local beautiful = require "beautiful" -local xresources = require "beautiful.xresources" -local dpi = xresources.apply_dpi - -screen.connect_signal("request::wallpaper", function(s) - awful.wallpaper { - screen = s, - widget = { - { - image = beautiful.wallpaper, - upscale = true, - downscale = true, - widget = wibox.widget.imagebox, - }, - valign = "center", - halign = "center", - tiled = false, - widget = wibox.container.tile, - } - } -end) - -screen.connect_signal("request::desktop_decoration", function(s) - -- s.padding = dpi(4) - - awful.tag.add( - "", - { - screen = s, - layout = awful.layout.suit.floating, - selected = true - } - ) - - awful.tag.add( - "󰈹", - { - screen = s, - layout = awful.layout.suit.floating, - - } - ) - - awful.tag.add( - "󰡠", - { - screen = s, - layout = awful.layout.suit.tile.left, - master_width_factor = 0.7 - } - ) - - awful.tag.add( - "", - { - screen = s, - layout = awful.layout.suit.tile - } - ) - - awful.tag.add( - "", - { - screen = s, - layout = awful.layout.suit.tile.right, - master_width_factor = 0.7 - } - ) - - awful.tag.add( - "", - { - screen = s, - layout = awful.layout.suit.floating, - } - ) -end) diff --git a/.config/awesome/components/statusbar/brightness.lua b/.config/awesome/components/statusbar/brightness.lua deleted file mode 100644 index eb37f06..0000000 --- a/.config/awesome/components/statusbar/brightness.lua +++ /dev/null @@ -1,33 +0,0 @@ -local awful = require "awful" -local xresources = require "beautiful.xresources" -local dpi = xresources.apply_dpi -local vars = require "themes.prismite.vars" -local wibox = require "wibox" - - -local brightness = wibox.widget { - widget = wibox.container.place, - { - widget = wibox.widget.textbox, - font = vars.font, - text = "" - }, -} - -awful.tooltip { - objects = { brightness }, - timer_function = function() - return math.floor(tonumber(io.popen("brightnessctl g"):read("*a"):sub(0, -2)) / 255 * 100) .. "%" - end, - timeout = 0.5, - bg = vars.colors.bg, - fg = vars.colors.fg, - border_color = vars.colors.bright.black, - border_width = vars.border_width, - font = vars.font, - shape = vars.shape, - margin_leftright = dpi(6), - margin_topbottom = dpi(6) -} - -return brightness diff --git a/.config/awesome/components/statusbar/clock.lua b/.config/awesome/components/statusbar/clock.lua deleted file mode 100644 index c88ea62..0000000 --- a/.config/awesome/components/statusbar/clock.lua +++ /dev/null @@ -1,32 +0,0 @@ -local awful = require "awful" -local xresources = require "beautiful.xresources" -local dpi = xresources.apply_dpi -local vars = require "themes.prismite.vars" -local wibox = require "wibox" - - -local clock = wibox.widget { - widget = wibox.container.place, - { - format = "%H\n%M", - widget = wibox.widget.textclock, - font = vars.font - }, -} - -awful.tooltip { - objects = { clock }, - timer_function = function() - return os.date("%a %d/%m/%y") - end, - bg = vars.colors.bg, - fg = vars.colors.fg, - border_color = vars.colors.bright.black, - border_width = vars.border_width, - font = vars.font, - shape = vars.shape, - margin_leftright = dpi(6), - margin_topbottom = dpi(6) -} - -return clock diff --git a/.config/awesome/components/statusbar/init.lua b/.config/awesome/components/statusbar/init.lua deleted file mode 100644 index c798669..0000000 --- a/.config/awesome/components/statusbar/init.lua +++ /dev/null @@ -1,57 +0,0 @@ -local awful = require "awful" -local beautiful = require "beautiful" -local xresources = require "beautiful.xresources" -local dpi = xresources.apply_dpi -local vars = require "themes.prismite.vars" -local wibox = require "wibox" - -local taglist = require "components.statusbar.taglist" -local clock = require "components.statusbar.clock" -local wifi = require "components.statusbar.wifi" -local battery = require "components.statusbar.battery" -local brightness = require "components.statusbar.brightness" - -screen.connect_signal("request::desktop_decoration", function(s) - local bar = awful.wibar({ - -- placement = function(d) - -- local place = awful.placement.left + awful.placement.maximize_vertically - -- return place(d, { - -- margins = beautiful.useless_gap - -- }) - -- end, - margins = dpi(4), - position = "left", - screen = s, - restrict_workarea = true, - height = s.geometry.height - (beautiful.useless_gap * 4 + vars.border_width * 2) - 2, - width = dpi(32), - border_width = vars.border_width, - border_color = vars.colors.bright.black, - shape = vars.shape, - bg = vars.colors.bg, - widget = { - { - margins = dpi(4), - widget = wibox.container.margin, - { - layout = wibox.layout.fixed.vertical, - taglist - } - }, - nil, - { - margins = dpi(4), - widget = wibox.container.margin, - { - layout = wibox.layout.fixed.vertical, - spacing = dpi(8), - brightness, - battery, - wifi, - clock - } - }, - layout = wibox.layout.align.vertical, - } - }) -end) diff --git a/.config/awesome/lib/bling b/.config/awesome/lib/bling new file mode 160000 index 0000000..57786e0 --- /dev/null +++ b/.config/awesome/lib/bling @@ -0,0 +1 @@ +Subproject commit 57786e08f403d855a6ffa4ed34995cba155da23a diff --git a/.config/awesome/lib/rubato b/.config/awesome/lib/rubato new file mode 160000 index 0000000..a918170 --- /dev/null +++ b/.config/awesome/lib/rubato @@ -0,0 +1 @@ +Subproject commit a9181708863265eb4a36c722f664978ee50fe8a0 diff --git a/.config/awesome/misc/autostart/init.lua b/.config/awesome/misc/autostart/init.lua new file mode 100644 index 0000000..e0d4efb --- /dev/null +++ b/.config/awesome/misc/autostart/init.lua @@ -0,0 +1,4 @@ +local awful = require "awful" +local gfs = require "gears.filesystem" + +awful.spawn.once("bash " .. gfs.get_configuration_dir() .. "/misc/autostart/programs.sh") diff --git a/.config/awesome/misc/autostart/programs.sh b/.config/awesome/misc/autostart/programs.sh new file mode 100644 index 0000000..dbafe44 --- /dev/null +++ b/.config/awesome/misc/autostart/programs.sh @@ -0,0 +1,22 @@ +function exe () { + local cmd=$@ + if ! pgrep -x $(echo $cmd | cut -d " " -f1); then + $cmd & + fi +} + +function exe_lax () { + local cmd=$@ + if ! pgrep $(echo $cmd | cut -d " " -f1); then + $cmd & + fi +} + +exe "picom -b" +exe sxhkd +exe clipcatd +exe_lax wezterm +exe_lax "wezterm start --class code_term" +exe firefox +exe spotify +exe discord diff --git a/.config/awesome/misc/cfg.lua b/.config/awesome/misc/cfg.lua new file mode 100644 index 0000000..0d9bcba --- /dev/null +++ b/.config/awesome/misc/cfg.lua @@ -0,0 +1,6 @@ +local c = { + titlebars_enabled = false, + terminal = "wezterm" +} + +return c diff --git a/.config/awesome/misc/helpers.lua b/.config/awesome/misc/helpers.lua new file mode 100644 index 0000000..132a4df --- /dev/null +++ b/.config/awesome/misc/helpers.lua @@ -0,0 +1,121 @@ +local awful = require "awful" +local gears = require "gears" +local xresources = require "beautiful.xresources" +local n = require "naughty".notification +local dpi = xresources.apply_dpi +local vars = require "misc.vars" +local wibox = require "wibox" + +local h = {} + +-- utils + +function h.debug(message) + n { message = tostring(message) } +end + +function h.map(t, f) + local nt = {} + for k,v in pairs(t) do + nt[k] = f(v) + end + return nt +end + +function h.filter(t, f, dict) + local nt = {} + for k,v in pairs(t) do + if not f(v) then goto continue end + if dict then + nt[k] = v + else + table.insert(nt, v) + end + ::continue:: + end + return nt +end + +-- This is taken from http://lua-users.org/wiki/SortedIteration +-- This version is stripped of comments and empty lines + some stuff is renamed + +local function __gen_oindex( t ) + local oindex = {} + for key in pairs(t) do + table.insert(oindex, key) + end + table.sort(oindex) + return oindex +end + +local function onext(t, state) + local key = nil + if state == nil then + t.__oindex = __gen_oindex(t) + key = t.__oindex[1] + else + for i = 1,#t.__oindex do + if t.__oindex[i] == state then + key = t.__oindex[i+1] + end + end + end + if key then + return key, t[key] + end + t.__oindex = nil +end + +function h.opairs(t) + return onext, t, nil +end + +-- markup + +function h.markup_fg(color, text) + return "" .. text .. "" +end + +function h.markup_bg(color, text) + return "" .. text .. "" +end + +-- ui + +function h.font(factor) + return vars.text_font .. " " .. vars.font_size * (factor or 1) +end + +function h.symbol_font(factor) + return vars.symbol_font .. " " .. vars.font_size * (factor or 1) +end + +function h.styled(target) + return gears.table.crush({ + bg = vars.colors.bg, + border_color = vars.colors.bright.black, + border_width = vars.border_width, + shape = vars.shape + }, target) +end + +function h.popup(args) + args.widget = { + widget = wibox.container.margin, + margins = vars.big_padding, + args.widget + } + + return awful.popup(h.styled(args)) +end + +function h.tooltip(objects, callback) + awful.tooltip(h.styled { + objects = objects, + timer_function = callback, + margin_leftright = vars.padding, + margin_topbottom = vars.padding + }) +end + +return h diff --git a/.config/awesome/misc/init.lua b/.config/awesome/misc/init.lua new file mode 100644 index 0000000..ce17c05 --- /dev/null +++ b/.config/awesome/misc/init.lua @@ -0,0 +1,5 @@ +require "misc.setup" +require "misc.signals" +require "misc.keys" +require "misc.rules" +require "misc.autostart" diff --git a/.config/awesome/misc/keys.lua b/.config/awesome/misc/keys.lua new file mode 100644 index 0000000..6d83ec4 --- /dev/null +++ b/.config/awesome/misc/keys.lua @@ -0,0 +1,318 @@ +local awful = require "awful" +local gears = require "gears" +local naughty = require "naughty" +local cfg = require "misc.cfg" +local insightful = require "ui.insightful" +local archaic = require "ui.archaic" +local fresnel = require "ui.fresnel" +local vars = require "misc.vars" +local btn = awful.button.names + +local recording = { false, "" } + +client.connect_signal("request::default_mousebindings", function() + awful.mouse.append_client_mousebindings { + insightful:bind { + mods = {}, + triggers = btn.LEFT, + press = function (c) + c:activate { + context = "mouse_click" + } + end, + group = "client", + desc = "raise client" + }, + insightful:bind { + mods = vars.mods.M, + triggers = btn.LEFT, + press = function (c) + c:activate { + context = "mouse_click", + action = "mouse_move" + } + end, + group = "client", + desc = "move client" + }, + insightful:bind { + mods = vars.mods.M, + triggers = btn.RIGHT, + press = function (c) + c:activate { + context = "mouse_click", + action = "mouse_resize" + } + end, + group = "client", + desc = "resize client" + } + } +end) + +local globalkeys = gears.table.join( + insightful:bind { + mods = vars.mods.MC, + triggers = "r", + press = awesome.restart, + group = "awesome", + desc = "restart awesome" + }, + insightful:bind { + mods = vars.mods.MC, + triggers = "s", + press = function() + insightful:toggle() + end, + group = "awesome", + desc = "toggle insightful" + }, + insightful:bind { + mods = vars.mods.MC, + triggers = "a", + press = function() + archaic:toggle() + end, + group = "awesome", + desc = "toggle notification center" + }, + insightful:bind { + mods = vars.mods.M, + triggers = " ", + press = function() + fresnel:show() + end, + group = "awesome", + desc = "toggle fresnel" + }, + + insightful:bind { + mods = {}, + triggers = "XF86AudioMute", + press = function() + awful.spawn("wpctl set-mute @DEFAULT_SINK@ toggle") + end, + group = "audio", + desc = "mute" + }, + insightful:bind { + mods = {}, + triggers = { + { "XF86AudioRaiseVolume", true }, + { "XF86AudioLowerVolume", false } + }, + press = function(up) + if up then + awful.spawn("wpctl set-volume @DEFAULT_SINK@ 5%+") + else + awful.spawn("wpctl set-volume @DEFAULT_SINK@ 5%-") + end + end, + group = "audio", + desc = "increase/decrease volume" + }, + insightful:bind { + mods = {}, + triggers = { + { "XF86AudioNext", true }, + { "XF86AudioPrev", false } + }, + press = function(next) + if next then + archaic.playerctl:next() + else + archaic.playerctl:previous() + end + end, + group = "audio", + desc = "previous/next song" + }, + insightful:bind { + mods = {}, + triggers = "XF86AudioPlay", + press = function() + archaic.playerctl:play_pause() + end, + group = "audio", + desc = "(un)pause song" + }, + + insightful:bind { + mods = {}, + triggers = { + { "XF86MonBrightnessUp", true }, + { "XF86MonBrightnessDown", false } + }, + press = function(up) + if up then + awful.spawn("brightnessctl set +51") + else + awful.spawn("brightnessctl set 51-") + end + end, + group = "brightness", + desc = "increase/decrease brightness" + }, + + insightful:bind { + mods = vars.mods.M, + triggers = "Return", + press = function() + awful.spawn(cfg.terminal) + end, + group = "launcher", + desc = "launch terminal" + }, + + insightful:bind { + mods = vars.mods.MC, + triggers = "q", + press = function() + local c = client.focus + if c then + c:kill() + end + end, + group = "client", + desc = "close" + }, + insightful:bind { + mods = vars.mods.M, + triggers = "m", + press = function() + local c = client.focus + if c then + c.maximized = not c.maximized + end + end, + group = "client", + desc = "(un)maximize" + }, + insightful:bind { + mods = vars.mods.M, + triggers = "n", + press = function() + local c = client.focus + if c then + gears.timer.delayed_call(function() + c.minimized = true + end) + end + end, + group = "client", + desc = "minimize" + }, + insightful:bind { + mods = vars.mods.M, + triggers = "f", + press = function() + local c = client.focus + if c then + c.fullscreen = not c.fullscreen + end + end, + group = "client", + desc = "toggle fullscreen" + }, + + insightful:bind { + mods = {}, + triggers = "Print", + press = function() + local date = os.date("%Y%m%d_%H%M%S") + local path = os.getenv("HOME") .. "/Pictures/" .. date .. ".png" + + awful.spawn.with_shell("maim --hidecursor " .. path .. " && xclip -selection clipboard -t image/png " .. path) + naughty.notification { + app_name = "Maim", + title = "Screenshot taken", + message = "Saved at " .. path + } + end, + group = "screenshot", + desc = "take fullscreen screenshot" + }, + insightful:bind { + mods = vars.mods.S, + triggers = "Print", + press = function() + local date = os.date("%Y%m%d_%H%M%S") + local path = os.getenv("HOME") .. "/Pictures/" .. date .. ".png" + + awful.spawn.with_shell("maim --hidecursor -s " .. path .. " && xclip -selection clipboard -t image/png " .. path .. [[ && notify-send -a "Maim" "Screenshot taken" "Saved at ]] .. path .. [["]]) + -- naughty.notification { + -- app_name = "Maim",r + -- title = "Screenshot taken", + -- message = "Saved at " .. path + -- } + end, + group = "screenshot", + desc = "take region screenshot" + }, + + insightful:bind { + mods = vars.mods.M, + triggers = "Print", + press = function() + if recording[1] then + awful.spawn("giph --stop") + naughty.notification { + app_name = "Giph", + title = "Recording stopped", + message = "Saved at " .. recording[2] + } + recording[1] = false + recording[2] = "" + else + recording[1] = true + recording[2] = os.getenv("HOME") .. "/Videos/" .. os.date("%Y%m%d_%H%M%S") .. ".mp4" + awful.spawn("giph --format mp4 --framerate 30 " .. recording[2]) + naughty.notification { + app_name = "Giph", + title = "Recording started" + } + end + end, + group = "video", + desc = "toggle recording" + }, + + insightful:bind { + mods = vars.mods.M, + triggers = "k", + press = function() + awful.spawn("xkblayout-state set +1") + end, + group = "keyboard", + desc = "next keyboard layout" + }, + insightful:bind { + mods = vars.mods.MS, + triggers = "k", + press = function() + awful.spawn("xkblayout-state set -1") + end, + group = "keyboard", + desc = "previous keyboard layout" + }, + + insightful:bind { + mods = vars.mods.M, + triggers = "Up", + press = awful.tag.viewprev, + group = "tag", + desc = "switch to previous" + }, + insightful:bind { + mods = vars.mods.M, + triggers = "Down", + press = awful.tag.viewnext, + group = "tag", + desc = "switch to next" + } +) + +-- gears.debug.dump(insightful:bind.hottriggerss) + +root.keys(globalkeys) + diff --git a/.config/awesome/components/signals/rules.lua b/.config/awesome/misc/rules.lua similarity index 91% rename from .config/awesome/components/signals/rules.lua rename to .config/awesome/misc/rules.lua index 65db501..803d49a 100644 --- a/.config/awesome/components/signals/rules.lua +++ b/.config/awesome/misc/rules.lua @@ -1,7 +1,7 @@ local ruled = require "ruled" local beautiful = require "beautiful" local awful = require "awful" -local vars = require "themes.prismite.vars" +local vars = require "misc.vars" ruled.client.connect_signal("request::rules", function() ruled.client.append_rule({ @@ -15,7 +15,7 @@ ruled.client.connect_signal("request::rules", function() screen = awful.screen.preferred, placement = awful.placement.centered+awful.placement.no_offscreen, floating = false, - shape = vars.shape, + -- shape = vars.shape, honor_padding = true -- tag = "1" } @@ -35,13 +35,12 @@ ruled.client.connect_signal("request::rules", function() }) ruled.client.append_rule({ - id = "steam", - rule_any = { - class = { "Steam" } + id = "pip", + rule = { + name = "Picture-in-Picture" }, properties = { - screen = 1, - tag = screen[1].tags[6] + ontop = true } }) @@ -75,14 +74,15 @@ ruled.client.connect_signal("request::rules", function() }, properties = { screen = 1, - tag = screen[1].tags[4] + tag = screen[1].tags[4], + titlebars_enabled = false } }) ruled.client.append_rule({ id = "code_tag", rule_any = { - class = { "lite-xl", "code_kitty" } + class = { "lite-xl", "code_term" } }, properties = { screen = 1, @@ -91,12 +91,13 @@ ruled.client.connect_signal("request::rules", function() }) ruled.client.append_rule({ - id = "pip", - rule = { - name = "Picture-in-Picture" + id = "steam", + rule_any = { + class = { "Steam" } }, properties = { - ontop = true + screen = 1, + tag = screen[1].tags[6] } }) end) diff --git a/.config/awesome/misc/setup.lua b/.config/awesome/misc/setup.lua new file mode 100644 index 0000000..aeee19a --- /dev/null +++ b/.config/awesome/misc/setup.lua @@ -0,0 +1,65 @@ +local naughty = require "naughty" +local beautiful = require "beautiful" +-- local notif_overlay = require "ui.notifs" +local wicked = require "ui.wicked" +local awful = require "awful" +local rubato = require "lib.rubato" +local vars = require "misc.vars" + +-- naughty.connect_signal("request::display", function(n) +-- notif_overlay:notify(n) +-- end) + +naughty.connect_signal("request::display", function(n) + naughty.layout.box { + notification = n, + placement = function(d) + return awful.placement.right(d, { + margins = beautiful.useless_gap * 2 + }) + end + } + + -- wicked:.notify(n) +end) + +naughty.connect_signal("request::display_error", function(message, startup) + naughty.notification { + urgency = "critical", + title = "Oops, an error happened"..(startup and " during startup!" or "!"), + message = message + } +end) + +-- Taken from https://www.reddit.com/r/awesomewm/comments/syjolb/comment/hy0xy35/ + +awesome.connect_signal('exit', function(reason_restart) + if not reason_restart then return end + + local file = io.open('/tmp/awesomewm-last-selected-tags', 'w+') + + for s in screen do + file:write(s.selected_tag.index, '\n') + end + + file:close() +end) + +awesome.connect_signal('startup', function() + local file = io.open('/tmp/awesomewm-last-selected-tags', 'r') + if not file then return end + + local selected_tags = {} + + for line in file:lines() do + table.insert(selected_tags, tonumber(line)) + end + + for s in screen do + local i = selected_tags[s.index] + local t = s.tags[i] + t:view_only() + end + + file:close() +end) diff --git a/.config/awesome/misc/signals.lua b/.config/awesome/misc/signals.lua new file mode 100644 index 0000000..a65ca43 --- /dev/null +++ b/.config/awesome/misc/signals.lua @@ -0,0 +1,89 @@ +local vars = require "misc.vars" +local awful = require "awful" +local rectangle = require "gears.shape".rectangle +local bling = require "lib.bling" + +client.connect_signal("property::name", function(c) + local out = io.popen("readlink /proc/" .. c.pid .. "/exe") + local name = c.name + if out ~= nil then + name = out:read("*a"):sub(0, -2):match("[^\\/]+$") or name + end + c.name = string.lower(name) +end) + +client.connect_signal("request::manage", function (c) + c.shape = vars.shape + if c.maximized then + c.maximized = false + c.maximized = true + end +end) + +local function handle_corners(c) + if c.maximized then + c.shape = rectangle + c.border_width = 0 + else + c.shape = vars.shape + c.border_width = vars.border_width + end +end + +client.connect_signal("property::maximized", handle_corners) +client.connect_signal("property::fullscreen", handle_corners) + +screen.connect_signal("request::desktop_decoration", function(s) + awful.tag.add( + "1", + { + screen = s, + layout = awful.layout.suit.floating, + selected = true + } + ) + + awful.tag.add( + "2", + { + screen = s, + layout = awful.layout.suit.floating, + + } + ) + + awful.tag.add( + "3", + { + screen = s, + layout = awful.layout.suit.tile.left, + master_width_factor = 0.7 + } + ) + + awful.tag.add( + "4", + { + screen = s, + layout = awful.layout.suit.tile.top, + master_width_factor = 0.2 + } + ) + + awful.tag.add( + "5", + { + screen = s, + layout = awful.layout.suit.tile.right, + master_width_factor = 0.7 + } + ) + + awful.tag.add( + "6", + { + screen = s, + layout = awful.layout.suit.floating, + } + ) +end) diff --git a/.config/awesome/misc/vars.lua b/.config/awesome/misc/vars.lua new file mode 100644 index 0000000..7a5f9c8 --- /dev/null +++ b/.config/awesome/misc/vars.lua @@ -0,0 +1,81 @@ +local gears = require "gears" +local xresources = require "beautiful.xresources" +local x_col = xresources.get_current_theme() +local dpi = xresources.apply_dpi +local wibox = require "wibox" + +local v = {} + +v.notif_timeout = 3 + +v.anim_duration = 0.15 +v.anim_intro = v.anim_duration / 2 + +function v.shape(cr,w,h) + gears.shape.rounded_rect(cr,w,h,dpi(4)) +end + +v.border_width = dpi(1.5) + +v.padding = dpi(4) +v.big_padding = dpi(8) + +v.text_font = "Fira Code Nerd Font Mono Medium" +v.symbol_font = "Symbols Nerd Font:style=1000-em" +v.font_size = 8 +v.font = v.text_font .. " " .. v.font_size + +local char_width, char_height = wibox.widget { + widget = wibox.widget.textbox, + text = "a" +}:get_preferred_size_at_dpi(screen[1].dpi) + +v.char_height = char_height +v.char_width = char_width + +v.bar_size = dpi(16) + +v.button_size = dpi(12) + +v.colors = { + fg = x_col.foreground, + bg = x_col.background, + + black = x_col.color0, + red = x_col.color1, + green = x_col.color2, + yellow = x_col.color3, + blue = x_col.color4, + pink = x_col.color5, + cyan = x_col.color6, + white = x_col.color7, + + bright = { + black = x_col.color8, + red = x_col.color9, + green = x_col.color10, + yellow = x_col.color11, + blue = x_col.color12, + pink = x_col.color13, + cyan = x_col.color14, + white = x_col.color15, + }, + + dim = { + fg = "#8893a5", + bg = "#20262e" + } +} + +-- taken from https://github.com/bew/dotfiles/blob/ab9bb1935783f7a31ef777b1d7e26d53f35df864/gui/wezterm/cfg_utils.lua +v.mods = setmetatable({ _SHORT_MAP = { C = "Control", S = "Shift", A = "Mod1", M = "Mod4" } }, { + __index = function(self, key) + local resolved_mods = {} + for i = 1, #key do + resolved_mods[i] = self._SHORT_MAP[key:sub(i, i)] + end + return resolved_mods + end +}) + +return v diff --git a/.config/awesome/themes/prismite/prismite.lua b/.config/awesome/prismite.lua similarity index 87% rename from .config/awesome/themes/prismite/prismite.lua rename to .config/awesome/prismite.lua index d0009c3..194254d 100644 --- a/.config/awesome/themes/prismite/prismite.lua +++ b/.config/awesome/prismite.lua @@ -1,11 +1,10 @@ -local theme_assets = require("beautiful.theme_assets") local xresources = require "beautiful.xresources" local dpi = xresources.apply_dpi local g = require("gears") local naughty = require("naughty") -local vars = require "themes.prismite.vars" +local vars = require "misc.vars" local theme = {} @@ -40,23 +39,16 @@ theme.titlebar_minimize_button_focus_hover = g.surface.load_from_shape(15, 15, g theme.titlebar_maximized_button_normal_inactive = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.green, "transparent", 4) theme.titlebar_maximized_button_focus_inactive = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.green, "transparent", 4) +theme.titlebar_maximized_button_normal_inactive_hover = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.bright.green, "transparent", 4) theme.titlebar_maximized_button_normal_active = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.bright.green, "transparent", 4) theme.titlebar_maximized_button_focus_active = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.bright.green, "transparent", 4) - -theme.menu_submenu_icon = "/usr/share/awesome/themes/default/submenu.png" -theme.menu_height = dpi(15) -theme.menu_width = dpi(100) - -theme.wallpaper = vars.theme_path.."wallpaper.png" - -theme.awesome_icon = theme_assets.awesome_icon( - theme.menu_height, vars.colors.yellow, vars.colors.red -) +theme.titlebar_maximized_button_normal_active_hover = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.green, "transparent", 4) theme.notification_icon_size = dpi(32) theme.notification_border_width = vars.border_width theme.notification_border_color = theme.border_normal theme.notification_shape = vars.shape +theme.notification_spacing = theme.useless_gap * 2 naughty.config.presets.critical.bg = theme.bg_normal naughty.config.presets.critical.timeout = 3 @@ -66,8 +58,7 @@ naughty.config.defaults.position = "bottom_right" naughty.config.defaults.border_width = vars.border_width theme.tasklist_plain_task_name = true - -theme.icon_theme = "Papirus-Dark" +theme.enable_spawn_cursor = false return theme diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 129c931..d48d7f7 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -1,19 +1,17 @@ pcall(require, "luarocks.loader") -local gears = require "gears" -local awful = require "awful" +-- ___ ___ ___ ___ ___ ___ ___ ___ +-- /\ \ /\ \ /\ \ /\ \ /\__\ /\ \ /\ \ /\ \ +-- /::\ \ /::\ \ _\:\ \ /::\ \ /::L_L_ _\:\ \ \:\ \ /::\ \ +-- /::\:\__\ /::\:\__\ /\/::\__\ /\:\:\__\ /:/L:\__\ /\/::\__\ /::\__\ /::\:\__\ +-- \/\::/ / \;:::/ / \::/\/__/ \:\:\/__/ \/_/:/ / \::/\/__/ /:/\/__/ \:\:\/ / +-- \/__/ |:\/__/ \:\__\ \::/ / /:/ / \:\__\ \/__/ \:\/ / +-- \|__| \/__/ \/__/ \/__/ \/__/ \/__/ +-- +--=-=-=-=-=-=-=-=-=-=-=-= A colorful and comfy AWM theme =-=-=-=-=-=-=-=-=-=-=-=-- local beautiful = require "beautiful" -beautiful.init(gears.filesystem.get_configuration_dir() .. "/themes/prismite/prismite.lua") +beautiful.init(require("gears").filesystem.get_configuration_dir() .. "/prismite.lua") - -require "components.signals" -require "components.window_switcher" -require "components.keybinds" -require "components.statusbar" - -tag.connect_signal("request::default_layouts", function() - awful.layout.append_default_layouts({ - awful.layout.suit.floating - }) -end) +require "misc" +require "ui" diff --git a/.config/awesome/scripts/maimtake b/.config/awesome/scripts/maimtake new file mode 100755 index 0000000..4b7f9e3 --- /dev/null +++ b/.config/awesome/scripts/maimtake @@ -0,0 +1,26 @@ +#!/bin/sh + +date=$(date +%Y%m%d_%H%M%S) +path=~/Pictures/Screenshot_$date.png +rootid=$(xwininfo -root -int | grep -iPo --color=never "(?<=id:\s)[0-9]*?\s") + +if [[ $1 -eq 1 ]] +then + # fullscreen + maim $path && xclip -selection clipboard -t image/png $path + notify-send -a "Maim" "Screenshot taken" "Saved at $path" +elif [[ $1 -eq 2 ]] +then + # region + maim -s $path && xclip -selection clipboard -t image/png $path + if [[ $? -eq 0 ]] + then + notify-send -a "Maim" "Screenshot taken" "Saved at $path" + fi +elif [[ $1 -eq 3 ]] +then + # current window + maim -i $(xdotool getactivewindow) $path && xclip -selection clipboard -t image/png $path +fi + + diff --git a/.config/awesome/themes/prismite/lotus_wallpaper.png b/.config/awesome/themes/prismite/lotus_wallpaper.png deleted file mode 100644 index ea4fe38..0000000 Binary files a/.config/awesome/themes/prismite/lotus_wallpaper.png and /dev/null differ diff --git a/.config/awesome/themes/prismite/old_wallpaper.png b/.config/awesome/themes/prismite/old_wallpaper.png deleted file mode 100644 index 7469165..0000000 Binary files a/.config/awesome/themes/prismite/old_wallpaper.png and /dev/null differ diff --git a/.config/awesome/themes/prismite/prismite_logo.png b/.config/awesome/themes/prismite/prismite_logo.png deleted file mode 100644 index 9a2a659..0000000 Binary files a/.config/awesome/themes/prismite/prismite_logo.png and /dev/null differ diff --git a/.config/awesome/themes/prismite/sd_wallpaper.png b/.config/awesome/themes/prismite/sd_wallpaper.png deleted file mode 100644 index 49f7fbf..0000000 Binary files a/.config/awesome/themes/prismite/sd_wallpaper.png and /dev/null differ diff --git a/.config/awesome/themes/prismite/sd_wallpaper_new.png b/.config/awesome/themes/prismite/sd_wallpaper_new.png deleted file mode 100644 index 6df8125..0000000 Binary files a/.config/awesome/themes/prismite/sd_wallpaper_new.png and /dev/null differ diff --git a/.config/awesome/themes/prismite/vars.lua b/.config/awesome/themes/prismite/vars.lua deleted file mode 100644 index c5b938d..0000000 --- a/.config/awesome/themes/prismite/vars.lua +++ /dev/null @@ -1,51 +0,0 @@ -local gears = require "gears" -local gfs = require("gears.filesystem") -local xresources = require "beautiful.xresources" -local x_col = xresources.get_current_theme() -local dpi = xresources.apply_dpi - - -local shape = function(cr,w,h) - gears.shape.rounded_rect(cr,w,h,8) -end - -local border_width = dpi(1.5) - -local font = "FiraCode Nerd Font Mono SemiBold 8" - -local theme_path = gfs.get_configuration_dir() .. "themes/prismite/" - -local colors = { - fg = x_col.foreground, - bg = x_col.background, - - black = x_col.color0, - red = x_col.color1, - green = x_col.color2, - yellow = x_col.color3, - blue = x_col.color4, - magenta = x_col.color5, - cyan = x_col.color6, - white = x_col.color7, - - bright = { - black = x_col.color8, - red = x_col.color9, - green = x_col.color10, - yellow = x_col.color11, - blue = x_col.color12, - magenta = x_col.color13, - cyan = x_col.color14, - white = x_col.color15, - } -} - -local vars = { - ["shape"] = shape, - ["colors"] = colors, - ["border_width"] = border_width, - ["font"] = font, - ["theme_path"] = theme_path -} - -return vars diff --git a/.config/awesome/themes/prismite/wallpaper.png b/.config/awesome/themes/prismite/wallpaper.png deleted file mode 100644 index f4b1a23..0000000 Binary files a/.config/awesome/themes/prismite/wallpaper.png and /dev/null differ diff --git a/.config/awesome/themes/prismite/wallpaper_clean.png b/.config/awesome/themes/prismite/wallpaper_clean.png deleted file mode 100644 index adbe6be..0000000 Binary files a/.config/awesome/themes/prismite/wallpaper_clean.png and /dev/null differ diff --git a/.config/awesome/ui/archaic/init.lua b/.config/awesome/ui/archaic/init.lua new file mode 100644 index 0000000..eace674 --- /dev/null +++ b/.config/awesome/ui/archaic/init.lua @@ -0,0 +1,239 @@ +local awful = require "awful" +local btn = awful.button.names +local gc = require "gears.color" +local gs = require "gears.surface" +local vars = require "misc.vars" +local h = require "misc.helpers" +local wibox = require "wibox" +local beautiful = require "beautiful" +local rubato = require "lib.rubato" +local playerctl = require "lib.bling.signal.playerctl".lib { + -- ignore = "firefox", + player = { "spotify", "cmus", "%any" } +} + +local height = screen[1].geometry.height - (beautiful.useless_gap * 4 + vars.border_width * 2) +local inside_width = vars.bar_size * 20 - (vars.big_padding * 4 + vars.border_width * 4 + vars.bar_size * 4) + +local cover = wibox.widget { + { + widget = wibox.widget.imagebox, + clip_shape = vars.shape, + forced_width = vars.bar_size * 4, + forced_height = vars.bar_size * 4, + visible = false, + id = "cover" + }, + { + widget = wibox.container.background, + forced_width = vars.bar_size * 4, + forced_height = vars.bar_size * 4, + bg = vars.colors.black, + fg = vars.colors.dim.fg, + shape = vars.shape, + { + widget = wibox.container.place, + { + widget = wibox.widget.textbox, + text = "󰝚", + font = h.font(4) + } + }, + id = "no_cover" + }, + layout = wibox.layout.stack +} + +local song = wibox.widget { + widget = wibox.widget.textbox, + text = "Nothing Playing ", + id = "song" +} + +local artist = wibox.widget { + widget = wibox.widget.textbox, + markup = h.markup_fg(vars.colors.dim.fg, "Nothing Playing "), + font = h.font(0.8), +} + +local back = wibox.widget { + widget = wibox.widget.textbox, + text = "", + font = h.symbol_font(1.5), + forced_height = beautiful.get_font_height(h.symbol_font(0.5)) +} +back:add_button(awful.button { + modifiers = {}, + button = btn.LEFT, + on_press = function() + playerctl:previous() + end +}) + +local play_pause = wibox.widget { + widget = wibox.widget.textbox, + text = "", + font = h.font(1.5), + forced_height = beautiful.get_font_height(h.font(0.5)) +} +play_pause:add_button(awful.button { + modifiers = {}, + button = btn.LEFT, + on_press = function() + playerctl:play_pause() + end +}) +playerctl:connect_signal("playback_status", function(_, playing) + if playing then + play_pause:set_text("") + else + play_pause:set_text("") + end +end) + +local forward = wibox.widget { + widget = wibox.widget.textbox, + text = "", + font = h.font(1.5), + forced_height = beautiful.get_font_height(h.font(0.5)) +} +forward:add_button(awful.button { + + modifiers = {}, + button = btn.LEFT, + on_press = function() + playerctl:next() + end +}) + +local progress_bar = wibox.widget { + widget = wibox.widget.progressbar, + max_value = 1, + value = 0, + shape = vars.shape, + bar_shape = vars.shape, + forced_height = beautiful.get_font_height(h.font(0.5)), + forced_width = inside_width - (vars.padding * 2 + vars.big_padding + back:get_preferred_size_at_dpi(screen[1].dpi) * 3), + color = vars.colors.yellow, + background_color = vars.colors.black +} +local progress_smoothing = rubato.timed { + duration = vars.anim_duration, + intro = vars.anim_intro, + pos = 0, + subscribed = function(pos) + progress_bar.value = pos + end +} +playerctl:connect_signal("position", function(_, pos, len) + -- progress_bar.value = pos + progress_smoothing.target = pos + progress_bar.max_value = len +end) + +local archaic = {} + +archaic.playerctl = playerctl + +archaic.widget = h.popup { + placement = function(d) + return awful.placement.right(d, { + margins = beautiful.useless_gap * 2 + }) + end, + ontop = true, + minimum_width = vars.bar_size * 20, + maximum_width = vars.bar_size * 20, + minimum_height = height, + maximum_height = height, + widget = { + h.styled { + widget = wibox.container.background, + { + widget = wibox.container.margin, + margins = vars.big_padding, + { + cover, + { + { + { + { + widget = wibox.container.scroll.horizontal, + speed = 40, + fps = 60, + step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth, + song + }, + { + widget = wibox.container.scroll.horizontal, + speed = 40, + fps = 60, + step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth, + artist + }, + layout = wibox.layout.fixed.vertical + }, + { + widget = wibox.container.background, + bg = gc { + type = "linear", + from = { 0, 0 }, + to = { inside_width, 0 }, + -- ^-------------------------------------------------------------------------------------- 270px + stops = { + { 0, "#0000000" }, + { 0.95, "#0000000" }, + { 0.95, vars.colors.bg .. "1a" }, + { 1, vars.colors.bg } + } + } + }, + layout = wibox.layout.stack + }, + nil, + { + progress_bar, + { + back, + play_pause, + forward, + + spacing = vars.padding, + layout = wibox.layout.fixed.horizontal + }, + spacing = vars.big_padding, + layout = wibox.layout.fixed.horizontal + }, + layout = wibox.layout.align.vertical + }, + spacing = vars.big_padding - vars.border_width, -- for some reason awesome adds border_width here + layout = wibox.layout.fixed.horizontal + } + } + }, + layout = wibox.layout.fixed.vertical + } +} + +playerctl:connect_signal("metadata", function(_, _song, _artist, _cover) + -- n { message = "sus" } + song:set_text(_song .. " ") + -- ic.widget:emit_signal("widget::redraw_needed") + artist:set_markup(h.markup_fg(vars.colors.dim.fg, _artist .. " ")) + if _cover == "" then + cover.cover.visible = false + cover.no_cover.visible = true + return + end + cover.cover.image = gs.load_uncached(_cover) + cover.cover.visible = true + cover.no_cover.visible = false +end) + +function archaic:toggle() + self.widget.visible = not self.widget.visible +end + +archaic:toggle() + +return archaic diff --git a/.config/awesome/ui/decorations/init.lua b/.config/awesome/ui/decorations/init.lua new file mode 100644 index 0000000..9493a67 --- /dev/null +++ b/.config/awesome/ui/decorations/init.lua @@ -0,0 +1,2 @@ +require "ui.decorations.titlebar" +require "ui.decorations.wallpaper" diff --git a/.config/awesome/ui/decorations/titlebar.lua b/.config/awesome/ui/decorations/titlebar.lua new file mode 100644 index 0000000..8451817 --- /dev/null +++ b/.config/awesome/ui/decorations/titlebar.lua @@ -0,0 +1,84 @@ +local awful = require "awful" +local vars = require "misc.vars" +local gears = require "gears" +local wibox = require "wibox" +local rubato = require "lib.rubato" +local cfg = require "misc.cfg" + +local function button(color, color_focus, callback) + local widget = wibox.widget { + widget = wibox.container.background, + forced_height = vars.button_size, + forced_width = vars.button_size, + bg = color, + shape = vars.shape, + buttons = { callback } + } + + widget:connect_signal("mouse::enter", function() + local timed = rubato.timed { + duration = 0.1, + intro = 0.05, + pos = vars.button_size, + subscribed = function(pos) + widget.forced_width = pos + end + } + + timed.target = vars.button_size * 2 + widget.bg = color_focus + end) + + widget:connect_signal("mouse::leave", function() + local timed = rubato.timed { + duration = 0.1, + intro = 0.05, + pos = vars.button_size * 2, + subscribed = function(pos) + widget.forced_width = pos + end + } + + timed.target = vars.button_size + widget.bg = color + end) + + return widget +end + +client.connect_signal("request::titlebars", function(c) + if not cfg.draw_titlebar then return end + + local titlebar = awful.titlebar(c, { + position = "top", + size = vars.button_size + vars.padding * 2 + }) + + awful.titlebar.enable_tooltip = false + + titlebar.widget = { + widget = wibox.container.margin, + margins = vars.padding, + { + nil, + nil, + { + button(vars.colors.green, vars.colors.bright.green, awful.button({}, 1, function() + c.maximized = not c.maximized + end)), + button(vars.colors.yellow, vars.colors.bright.yellow, awful.button({}, 1, function() + gears.timer.delayed_call(function() + c.minimized = true + end) + end)), + button(vars.colors.red, vars.colors.bright.red, awful.button({}, 1, function() + c:kill() + end)), + + spacing = vars.padding, + layout = wibox.layout.fixed.horizontal + }, + layout = wibox.layout.align.horizontal + } + } +end) diff --git a/.config/awesome/ui/decorations/wallpaper.lua b/.config/awesome/ui/decorations/wallpaper.lua new file mode 100644 index 0000000..f7104ff --- /dev/null +++ b/.config/awesome/ui/decorations/wallpaper.lua @@ -0,0 +1,28 @@ +local wallpaper = require "awful.wallpaper" +local wibox = require "wibox" +local vars = require "misc.vars" +local h = require "misc.helpers" + +screen.connect_signal("request::wallpaper", function(s) + wallpaper { + bg = vars.colors.dim.bg, + screen = s, + widget = { + widget = wibox.container.place, + valign = "center", + halign = "center", + { + widget = wibox.widget.textbox, + font = h.font(1.5), + markup = table.concat({ + h.markup_fg(vars.colors.red, " ___"), + h.markup_fg(vars.colors.green, " /\\ \\"), + h.markup_fg(vars.colors.yellow, " /::\\ \\"), + h.markup_fg(vars.colors.blue, "/::\\:\\__\\"), + h.markup_fg(vars.colors.pink, "\\/\\::/ /"), + h.markup_fg(vars.colors.cyan, " \\/__/") + }, "\n") + } + } + } +end) diff --git a/.config/awesome/ui/fresnel/init.lua b/.config/awesome/ui/fresnel/init.lua new file mode 100644 index 0000000..cf1357a --- /dev/null +++ b/.config/awesome/ui/fresnel/init.lua @@ -0,0 +1,276 @@ +local awful = require "awful" +local gtable = require "gears.table" +local gdebug = require "gears.debug" +local gfs = require "gears.filesystem" +local h = require "misc.helpers" +local cfg = require "misc.cfg" +local vars = require "misc.vars" +local wibox = require "wibox" +local beautiful = require "beautiful" +local rubato = require "lib.rubato" +local al_prompt = require "lib.bling.widget.app_launcher.prompt" +local btn = awful.button.names + +package.cpath = package.cpath .. ";" .. gfs.get_configuration_dir() .. "ui/fresnel/lenses/target/debug/lib?.so" + +local lenses = require "lenses" +local max_entries = 10 + +local fresnel = {} + +fresnel._toggled = false +fresnel._entries_exec = {} +fresnel._entries_offset = 0 +fresnel._entries_count = 0 +fresnel._visible_entries = 0 +fresnel._selected_index = 1 + +function fresnel:_exec_entry(entry_index) + local exec = self._entries_exec[entry_index] + if type(exec) ~= "userdata" then + awful.spawn((exec[2] and cfg.terminal .. " -e " or "") .. exec[1]) + end +end + +function fresnel:_update(query, scrolled) + query = query or "" + scrolled = scrolled or false + + if not scrolled then + self._selected_index = 1 + self._entries_offset = 0 + end + + local layout = self._widget.widget:get_children_by_id("entry_layout")[1] + local status = self._widget.widget:get_children_by_id("status")[1] + local all_providers = {} + local entries_count = 0 + + self._entries_exec = {} + layout:reset() + + for _, provider in h.opairs(lenses) do + local entries = provider(query) + + table.sort(entries, function(a, b) + return a.message < b.message + end) + + all_providers = gtable.join(all_providers, entries) + end + + self._entries_count = #all_providers + + for i, entry in ipairs(all_providers) do + if i <= self._entries_offset then + goto continue + end + if entries_count == max_entries then break end + table.insert(self._entries_exec, entry.exec) + + local entry_widget = wibox.widget { + widget = wibox.container.background, + shape = vars.shape, + { + widget = wibox.container.margin, + margins = vars.padding, + { + widget = wibox.container.constraint, + strategy = "max", + height = vars.char_height, + { + { + widget = wibox.container.background, + fg = vars.colors.dim.fg, + { + widget = wibox.widget.textbox, + text = entry.provider .. " | " + } + }, + { + widget = wibox.widget.textbox, + text = entry.message + }, + spacing = vars.padding, + layout = wibox.layout.fixed.horizontal + } + } + }, + buttons = { + awful.button { + modifiers = {}, + button = btn.LEFT, + on_press = function() + self:_exec_entry(i) + end + } + }, + _selected = false + } + + if self._selected_index + self._entries_offset == i then + entry_widget._selected = true + entry_widget.bg = vars.colors.black + end + + entry_widget:connect_signal("mouse::enter", function() + if entry_widget._selected == true then return end + entry_widget.bg = vars.colors.black + end) + + entry_widget:connect_signal("mouse::leave", function() + if entry_widget._selected == true then return end + entry_widget.bg = vars.colors.bg + end) + + layout:add(entry_widget) + + entries_count = entries_count + 1 + self._visible_entries = entries_count + ::continue:: + end + + status.text = self._entries_offset + self._selected_index .. "/" .. self._entries_count +end + +fresnel._text = "" +fresnel._prompt = al_prompt { + prompt = "", + reset_on_stop = true, + ul_cursor = "low", + bg_cursor = vars.colors.black, + changed_callback = function(text) + if fresnel._text == text then return end + if fresnel._toggled == false then return end + fresnel:_update(text) + fresnel._text = text + end, + keypressed_callback = function(mod, key) + if key == "Escape" or key == " " and mod.Mod4 then + fresnel:hide() + elseif key == "Return" then + fresnel:_exec_entry(fresnel._selected_index) + fresnel:hide() + elseif key == "Up" then + local next_index = fresnel._selected_index - 1 + if next_index < 1 and fresnel._entries_offset == 0 then + return + elseif next_index < 1 and fresnel._entries_offset > 0 then + fresnel._entries_offset = fresnel._entries_offset - 1 + else + fresnel._selected_index = next_index + end + + fresnel:_update(fresnel._text, true) + elseif key == "Down" then + local next_index = fresnel._selected_index + 1 + if next_index > fresnel._visible_entries and fresnel._entries_offset + fresnel._visible_entries == fresnel._entries_count then + return + elseif next_index > fresnel._visible_entries and fresnel._entries_offset + fresnel._visible_entries < fresnel._entries_count then + fresnel._entries_offset = fresnel._entries_offset + 1 + else + fresnel._selected_index = next_index + end + + fresnel:_update(fresnel._text, true) + end + end +} + +fresnel._widget = h.popup { + visible = false, + ontop = true, + placement = function(d) + awful.placement.top(d, { + margins = { + top = beautiful.useless_gap * 2 + } + }) + end, + minimum_width = screen[1].geometry.width / 2, + maximum_width = screen[1].geometry.width / 2, + widget = { + { + widget = wibox.container.background, + bg = vars.colors.black, + fg = vars.colors.dim.fg, + shape = vars.shape, + { + widget = wibox.container.margin, + margins = vars.padding, + { + { + widget = wibox.widget.textbox, + text = ">" + }, + { + widget = wibox.container.margin, + margins = { + left = vars.padding, + right = vars.padding + }, + { + widget = wibox.container.constraint, + strategy = "max", + height = vars.char_height, + { + widget = wibox.container.background, + fg = vars.colors.fg, + fresnel._prompt.textbox + } + } + }, + { + widget = wibox.widget.textbox, + text = "0/0", + id = "status" + }, + layout = wibox.layout.align.horizontal + } + } + }, + { + widget = wibox.container.margin, + margins = { + top = vars.padding + }, + { + spacing = vars.padding, + layout = wibox.layout.fixed.vertical, + id = "entry_layout" + } + }, + layout = wibox.layout.align.vertical + } +} +fresnel._widget.maximum_height = vars.big_padding * 2 + (vars.padding * 2 + vars.char_height) * (1 + 10) + vars.padding + vars.padding * 9 + +function fresnel:show() + self._toggled = true + self._timed.target = 1 + self:_update() + self._prompt:start() +end + +function fresnel:hide() + self._toggled = false + self._timed.target = 0 + self._prompt:stop() +end + +fresnel._timed = rubato.timed { + duration = vars.anim_duration, + intro = vars.anim_intro, + pos = 0, + subscribed = function(pos) + fresnel._widget.opacity = pos + + if pos == 0 then + fresnel._widget.visible = false + else + fresnel._widget.visible = true + end + end +} + +return fresnel diff --git a/.config/awesome/ui/fresnel/lenses/.gitignore b/.config/awesome/ui/fresnel/lenses/.gitignore new file mode 100644 index 0000000..4fffb2f --- /dev/null +++ b/.config/awesome/ui/fresnel/lenses/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/.config/awesome/ui/fresnel/lenses/Cargo.toml b/.config/awesome/ui/fresnel/lenses/Cargo.toml new file mode 100644 index 0000000..4dcb8bc --- /dev/null +++ b/.config/awesome/ui/fresnel/lenses/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "lenses" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +freedesktop_entry_parser = "1.3.0" +meval = "0.2.0" +mlua = { version = "0.8.7", features = [ "module", "lua54", "serialize" ] } +parking_lot = "0.12.1" +rayon = "1.6.1" +serde = { version = "1.0.152", features = [ "derive" ] } +url = "2.3.1" + +[lib] +crate-type = ["cdylib"] diff --git a/.config/awesome/ui/fresnel/lenses/install.log b/.config/awesome/ui/fresnel/lenses/install.log new file mode 100644 index 0000000..c0f5d63 --- /dev/null +++ b/.config/awesome/ui/fresnel/lenses/install.log @@ -0,0 +1,10 @@ +[03:45:24 2023-02-24] FETCHING Version 2.16.1 +[03:45:24 2023-02-24] CREATING /home/delta/.spicetify +[03:45:24 2023-02-24] DOWNLOADING https://github.com/spicetify/spicetify-cli/releases/download/v2.16.1/spicetify-2.16.1-linux-amd64.tar.gz +[03:45:34 2023-02-24] EXTRACTING /home/delta/.spicetify/spicetify.tar.gz +[03:45:34 2023-02-24] SETTING EXECUTABLE PERMISSIONS TO /home/delta/.spicetify/spicetify +[03:45:34 2023-02-24] REMOVING /home/delta/.spicetify/spicetify.tar.gz +[03:45:34 2023-02-24] APPENDING /home/delta/.spicetify to PATH in /home/delta/.config/fish/config.fish +[03:45:34 2023-02-24] Restart your shell to have spicetify in your PATH. +[03:45:34 2023-02-24] spicetify v2.16.1 was installed successfully to /home/delta/.spicetify +[03:45:34 2023-02-24] Run 'spicetify --help' to get started diff --git a/.config/awesome/ui/fresnel/lenses/liblenses.so b/.config/awesome/ui/fresnel/lenses/liblenses.so new file mode 120000 index 0000000..5f7fc45 --- /dev/null +++ b/.config/awesome/ui/fresnel/lenses/liblenses.so @@ -0,0 +1 @@ +target/liblenses.so \ No newline at end of file diff --git a/.config/awesome/ui/fresnel/lenses/rustfmt.toml b/.config/awesome/ui/fresnel/lenses/rustfmt.toml new file mode 100644 index 0000000..36afbbd --- /dev/null +++ b/.config/awesome/ui/fresnel/lenses/rustfmt.toml @@ -0,0 +1,3 @@ +imports_layout = "Vertical" +unstable_features = true +group_imports = "StdExternalCrate" diff --git a/.config/awesome/ui/fresnel/lenses/src/application.rs b/.config/awesome/ui/fresnel/lenses/src/application.rs new file mode 100644 index 0000000..0cf6c1a --- /dev/null +++ b/.config/awesome/ui/fresnel/lenses/src/application.rs @@ -0,0 +1,107 @@ +use std::{ + fs::read_dir, + path::PathBuf, +}; + +use freedesktop_entry_parser as fd; +use mlua::prelude::*; +use parking_lot::Mutex; +use rayon::prelude::*; +use url::Url; + +use crate::entry::{ + entries_to_lua_table, + Entry, +}; + +fn parse_entry<'a>(entry: fd::Entry, path: PathBuf) -> Result { + let section = entry.section("Desktop Entry"); + let name = section.attr("Name").ok_or(())?.to_string(); + + if section.attr("Type").ok_or(())? != "Application" { + return Err(()); + } + + match section.attr("OnlyShowIn") { + Some(_) => return Err(()), + None => {} + } + + match section.attr("Hidden") { + Some(_) => return Err(()), + None => {} + } + + match section.attr("NoDisplay") { + Some(_) => return Err(()), + None => {} + } + + let exec = section.attr("Exec").ok_or(())?.to_string(); + let mut new_exec = exec.clone(); + for (index, _) in exec.match_indices("%") { + match exec.chars().nth(index + 1).unwrap().to_ascii_lowercase() { + 'i' => match section.attr("Icon") { + Some(icon) => new_exec.replace_range(index..index + 2, &format!("--icon {}", icon)), + None => {} + }, + 'c' => new_exec.replace_range(index..index + 2, &name), + 'k' => new_exec.replace_range(index..index + 2, Url::from_file_path(&path)?.as_str()), + + 'f' | 'u' | 'v' | 'm' | 'd' | 'n' => new_exec.replace_range(index..index + 2, ""), + _ => continue, + } + } + + Ok(Entry { + message: name, + exec: Some(( + new_exec, + section + .attr("Terminal") + .unwrap_or("false") + .parse() + .map_err(drop)?, + )), + provider: "Application".to_string(), + }) +} + +pub fn query(lua: &Lua, input: String) -> LuaResult { + let applications_dir = "/usr/share/applications"; + let entries = read_dir(applications_dir)? + .map(|result| result.map(|e| e.path())) + .collect::, std::io::Error>>()?; + + let entries = entries + .into_iter() + .filter(|e| match e.extension() { + Some(ext) if ext == "desktop" => true, + None | _ => false, + }) + .collect::>(); + + let mut parsed_entries: Mutex> = Mutex::new(Vec::new()); + + entries.into_par_iter().for_each(|path| { + let entry = match fd::parse_entry(&path) { + Ok(entry) => entry, + Err(_) => return, + }; + + match parse_entry(entry, path) { + Ok(parsed_entry) => parsed_entries.lock().push(parsed_entry), + Err(_) => return, + } + }); + + Ok(entries_to_lua_table( + parsed_entries + .get_mut() + .iter() + .filter(|entry| entry.message.to_lowercase().contains(&input)) + .map(|entry| (*entry).clone()) + .collect(), + lua, + )) +} diff --git a/.config/awesome/ui/fresnel/lenses/src/calculator.rs b/.config/awesome/ui/fresnel/lenses/src/calculator.rs new file mode 100644 index 0000000..792985d --- /dev/null +++ b/.config/awesome/ui/fresnel/lenses/src/calculator.rs @@ -0,0 +1,25 @@ +use meval::eval_str; +use mlua::prelude::*; + +use crate::entry::{ + entries_to_lua_table, + Entry, +}; + +pub fn query(lua: &Lua, input: String) -> LuaResult { + println!("{:?}", input); + let result = match eval_str(input.trim()) { + Ok(ok) => ok.to_string(), + Err(_) => return Ok(lua.create_table()?), + }; + + Ok(entries_to_lua_table( + vec![Entry { + message: result, + exec: None, + // icon: '', + provider: "Calculator".to_string(), + }], + lua, + )) +} diff --git a/.config/awesome/ui/fresnel/lenses/src/entry.rs b/.config/awesome/ui/fresnel/lenses/src/entry.rs new file mode 100644 index 0000000..d6e7467 --- /dev/null +++ b/.config/awesome/ui/fresnel/lenses/src/entry.rs @@ -0,0 +1,20 @@ +use mlua::{ + prelude::*, + LuaSerdeExt, +}; +use serde::Serialize; + +#[derive(Serialize, Clone)] +pub struct Entry { + pub message: String, + pub exec: Option<(String, bool)>, + // pub icon: char, + pub provider: String, +} + +pub fn entries_to_lua_table(entries: Vec, lua: &Lua) -> LuaTable { + match lua.to_value(&entries).unwrap() { + LuaValue::Table(t) => t, + _ => unreachable!(), + } +} diff --git a/.config/awesome/ui/fresnel/lenses/src/lib.rs b/.config/awesome/ui/fresnel/lenses/src/lib.rs new file mode 100644 index 0000000..e4fc881 --- /dev/null +++ b/.config/awesome/ui/fresnel/lenses/src/lib.rs @@ -0,0 +1,16 @@ +mod application; +mod calculator; +mod entry; + +use mlua::prelude::*; + +#[mlua::lua_module] +fn lenses(lua: &Lua) -> LuaResult { + let exports = lua.create_table()?; + // lua.create_fun + // exports.push(application::query)?; + exports.set("1", lua.create_function(calculator::query)?)?; + exports.set("2", lua.create_function(application::query)?)?; + + Ok(exports) +} diff --git a/.config/awesome/components/info_center/init.lua b/.config/awesome/ui/info_center/init.lua similarity index 84% rename from .config/awesome/components/info_center/init.lua rename to .config/awesome/ui/info_center/init.lua index d1c78f2..e7f59cc 100644 --- a/.config/awesome/components/info_center/init.lua +++ b/.config/awesome/ui/info_center/init.lua @@ -1,5 +1,5 @@ local awful = require "awful" -local vars = require "themes.prismite.vars" +local vars = require "misc.vars" local wibox = require "wibox" local obj = require "gears.object" local debug = require "gears.debug" diff --git a/.config/awesome/ui/init.lua b/.config/awesome/ui/init.lua new file mode 100644 index 0000000..4e6d98e --- /dev/null +++ b/.config/awesome/ui/init.lua @@ -0,0 +1,4 @@ +-- require "ui.window_switcher" +require "ui.statusbar" +-- require "ui.info_center" +require "ui.decorations" diff --git a/.config/awesome/ui/insightful/init.lua b/.config/awesome/ui/insightful/init.lua new file mode 100644 index 0000000..4ed6099 --- /dev/null +++ b/.config/awesome/ui/insightful/init.lua @@ -0,0 +1,273 @@ +local awful = require "awful" +local gtable = require "gears.table" +local h = require "misc.helpers" +local vars = require "misc.vars" +local wibox = require "wibox" +local rubato = require "lib.rubato" +local btn = awful.button.names + +local first_time = true +local mouse = "󰍽 " + +local insightful = {} + +insightful._toggled = false +insightful._bindings = {} +insightful._selected_group = "" + +insightful._keymap = { + Control = "Control", + Mod1 = "Alt", + ISO_Level3_Shift = "Alt Gr", + Mod4 = "Super", + Insert = "Insert", + Delete = "Delete", + Next = "Page Up", + Prior = "Page Down", + Left = "", + Up = "", + Right = "", + Down = "", + KP_End = "1", + KP_Down = "#2", + KP_Next = "#3", + KP_Left = "#4", + KP_Begin = "#5", + KP_Right = "#6", + KP_Home = "#7", + KP_Up = "#8", + KP_Prior = "#9", + KP_Insert = "#0", + KP_Delete = "#.", + KP_Divide = "#/", + KP_Multiply = "#*", + KP_Subtract = "#-", + KP_Add = "#+", + KP_Enter = "#Enter", + Escape = "Esc", + Tab = "Tab", + space = "Space", + Return = "Enter", + dead_acute = "´", + dead_circumflex = "^", + dead_grave = "`", + XF86MonBrightnessUp = "🔆+", + XF86MonBrightnessDown = "🔅-", + XF86AudioRaiseVolume = "ﱛ", + XF86AudioLowerVolume = "ﱜ", + XF86AudioMute = "ﱝ", + XF86AudioPlay = "⏯", + XF86AudioPrev = "⏮", + XF86AudioNext = "⏭", + XF86AudioStop = "⏹", + [tostring(btn.LEFT)] = mouse .. "Left", + [tostring(btn.MIDDLE)] = mouse .. "Middle", + [tostring(btn.RIGHT)] = mouse .. "Right" +} + +insightful._widget = h.popup { + visible = false, + ontop = true, + placement = awful.placement.centered, + minimum_height = screen[1].geometry.height / 2, + minimum_width = screen[1].geometry.width / 2, + widget = { + layout = wibox.layout.fixed.vertical, + spacing = vars.big_padding, + id = "layout_container" + } +} + +function insightful:_generate() + local grouped_binds = {} + local layout_container = insightful._widget.widget.layout_container + + for _, keybind in ipairs(self._bindings) do + local group = keybind.group or "general" + local group_exists = grouped_binds[group] ~= nil + + if not group_exists then + grouped_binds[group] = {} + end + + table.insert(grouped_binds[group], { + mods = keybind.mods, + triggers = keybind.triggers, + desc = keybind.desc + }) + end + + for group, keybinds in h.opairs(grouped_binds) do + local group_layout = { + spacing = vars.padding, + layout = wibox.layout.fixed.vertical + } + + for _, keybind in ipairs(keybinds) do + local key_layout = { + layout = wibox.layout.fixed.horizontal + } + + local key_and_desc_layout = { + nil, -- key + nil, + nil, -- description? + layout = wibox.layout.align.horizontal + } + + for _, mod in ipairs(keybind.mods) do + table.insert(key_layout, 1, h.styled { + widget = wibox.container.background, + bg = vars.colors.bright.black, + border_width = 0, + { + widget = wibox.container.margin, + margins = vars.padding, + { + widget = wibox.widget.textbox, + text = insightful._keymap[mod] or mod + } + } + }) + table.insert(key_layout, 2, { + widget = wibox.widget.textbox, + text = " + " + }) + end + + if type(keybind.triggers) == "string" or type(keybind.triggers) == "number" then + table.insert(key_layout, { + widget = wibox.widget.textbox, + text = insightful._keymap[tostring(keybind.triggers)] or keybind.triggers + }) + elseif type(keybind.triggers) == "table" then + local display_trigger = {} + for _, trigger in ipairs(keybind.triggers) do + table.insert(display_trigger, insightful._keymap[trigger[1]] or trigger[1]) + end + table.insert(key_layout, { + widget = wibox.widget.textbox, + text = table.concat(display_trigger, "/") + }) + end + + if keybind.desc then + key_and_desc_layout[3] = { + widget = wibox.container.background, + fg = vars.colors.dim.fg, + { + widget = wibox.widget.textbox, + text = keybind.desc + } + } + end + + key_and_desc_layout[1] = key_layout + + table.insert(group_layout, key_and_desc_layout) + end + + layout_container:add { + { + { + widget = wibox.container.background, + bg = vars.colors.yellow, + fg = vars.colors.bg, + shape = vars.shape, + { + widget = wibox.container.margin, + margins = vars.padding, + { + widget = wibox.widget.textbox, + text = group + } + } + }, + nil, + layout = wibox.layout.align.horizontal + }, + group_layout, + spacing = vars.padding, + layout = wibox.layout.fixed.vertical + } + end +end + +local timed = rubato.timed { + duration = vars.anim_duration, + intro = vars.anim_intro, + pos = 0, + subscribed = function(pos) + insightful._widget.opacity = pos + + if pos == 0 then + insightful._widget.visible = false + else + insightful._widget.visible = true + end + end +} + +function insightful:toggle() + if first_time then + insightful:_generate_widget() + first_time = false + end + + timed.target = insightful._toggled and 0 or 1 + insightful._toggled = not insightful._toggled +end + +local function get_binding_function(trigger) + if type(trigger) == "number" and trigger <= 5 and trigger > 0 then + return "button" + elseif type(trigger) == "string" then + return "key" + end + error("trigger can only be a mouse button or a key", 2) +end + +local function translate_binding(binding, trigger, multiple) + local value = nil + if multiple then + value = trigger[2] + trigger = trigger[1] + end + + local awful_binding = { + modifiers = binding.mods, + [get_binding_function(trigger)] = trigger, + on_press = multiple and function(...) binding.press(value, ...) end or binding.press + } + + if binding.desc then + awful_binding.description = binding.desc + end + if binding.group then + awful_binding.group = binding.group + end + + return awful[get_binding_function(trigger)](awful_binding) +end + +function insightful:bind(binding) + local awful_bindings = {} + table.insert(self._bindings, binding) + + if type(binding.triggers) == "table" then + for _, trigger in ipairs(binding.triggers) do + table.insert(awful_bindings, translate_binding(binding, trigger, true)) + end + elseif type(binding.triggers) == "string" or type(binding.triggers) == "number" then + return translate_binding(binding, binding.triggers, false) + else + error("binding.triggers can only be a string or a table") + end + + -- for some reason multi-trigger bindings only work if i do this + -- i spent a day debugging this + -- thanks awesome + return gtable.join(table.unpack(awful_bindings)) +end + +return insightful diff --git a/.config/awesome/ui/statusbar/init.lua b/.config/awesome/ui/statusbar/init.lua new file mode 100644 index 0000000..dfe2868 --- /dev/null +++ b/.config/awesome/ui/statusbar/init.lua @@ -0,0 +1,75 @@ +local awful = require "awful" +local beautiful = require "beautiful" +local xresources = require "beautiful.xresources" +local dpi = xresources.apply_dpi +local vars = require "misc.vars" +local wibox = require "wibox" +local h = require "misc.helpers" + +local taglist = require "ui.statusbar.widgets.taglist" +local clock = require "ui.statusbar.widgets.clock" +local wifi = require "ui.statusbar.widgets.wifi" +local battery = require "ui.statusbar.widgets.battery" +local brightness = require "ui.statusbar.widgets.brightness" +local keyboardlayout = require "ui.statusbar.widgets.keyboardlayout" + +screen.connect_signal("request::desktop_decoration", function(s) + local bar = h.popup { + placement = function(d) + local place = awful.placement.left + return place(d, { + margins = beautiful.useless_gap * 2 + }) + end, + -- ontop = true, + minimum_width = vars.bar_size, + maximum_width = vars.bar_size * 20, + minimum_height = s.geometry.height - (beautiful.useless_gap * 4 + vars.border_width * 2), + widget = { + { + { + widget = wibox.container.place, + valign = "top", + { + widget = wibox.widget.textbox, + text = "", + font = h.font(1.5) + } + }, + taglist, + { + widget = wibox.container.place, + valign = "bottom", + { + layout = wibox.layout.fixed.vertical, + spacing = vars.padding * 2, + brightness, + battery, + wifi, + keyboardlayout, + clock + }, + }, + layout = wibox.layout.align.vertical, + expand = "outside", + }, + -- { + -- widget = wibox.container.background, + -- bg = vars.colors.fg, + -- fg = vars.colors.bg, + -- visible = false, + -- { + -- widget = wibox.widget.textbox, + -- text = "this is gay" + -- } + -- }, + -- spacing = vars.big_padding, + spacing = nil, + layout = wibox.layout.fixed.horizontal + } + } + + bar:struts { + left = dpi(16) + vars.big_padding * 2 + beautiful.useless_gap * 4 + } +end) diff --git a/.config/awesome/ui/statusbar/widgets/app_launcher.lua b/.config/awesome/ui/statusbar/widgets/app_launcher.lua new file mode 100644 index 0000000..2e1e10a --- /dev/null +++ b/.config/awesome/ui/statusbar/widgets/app_launcher.lua @@ -0,0 +1,6 @@ +local awful = require "awful" +local wibox = require "wibox" +local vars = require "misc.vars" +local h = require "misc.helpers" + + diff --git a/.config/awesome/components/statusbar/battery.lua b/.config/awesome/ui/statusbar/widgets/battery.lua similarity index 77% rename from .config/awesome/components/statusbar/battery.lua rename to .config/awesome/ui/statusbar/widgets/battery.lua index 670b200..b041c3a 100644 --- a/.config/awesome/components/statusbar/battery.lua +++ b/.config/awesome/ui/statusbar/widgets/battery.lua @@ -1,8 +1,8 @@ local awful = require "awful" local xresources = require "beautiful.xresources" -local dpi = xresources.apply_dpi -local vars = require "themes.prismite.vars" +local vars = require "misc.vars" local wibox = require "wibox" +local h = require "misc.helpers" local battery_inner = awful.widget.watch("cat /sys/class/power_supply/BAT0/capacity", 1, function(widget, stdout) local icon = "" @@ -60,19 +60,8 @@ local battery = wibox.widget { battery_inner } -awful.tooltip { - objects = { battery }, - timer_function = function() - return io.popen("cat /sys/class/power_supply/BAT0/capacity"):read("*a"):sub(0, -2) .. "%" - end, - bg = vars.colors.bg, - fg = vars.colors.fg, - border_color = vars.colors.bright.black, - border_width = vars.border_width, - font = vars.font, - shape = vars.shape, - margin_leftright = dpi(6), - margin_topbottom = dpi(6) -} +h.tooltip({ battery }, function() + return io.popen("cat /sys/class/power_supply/BAT0/capacity"):read("*a"):sub(0, -2) .. "%" +end) return battery diff --git a/.config/awesome/ui/statusbar/widgets/brightness.lua b/.config/awesome/ui/statusbar/widgets/brightness.lua new file mode 100644 index 0000000..cceba89 --- /dev/null +++ b/.config/awesome/ui/statusbar/widgets/brightness.lua @@ -0,0 +1,18 @@ +local vars = require "misc.vars" +local wibox = require "wibox" +local h = require "misc.helpers" + +local brightness = wibox.widget { + widget = wibox.container.place, + { + widget = wibox.widget.textbox, + font = vars.font, + text = "" + }, +} + +h.tooltip({ brightness }, function() + return math.floor(tonumber(io.popen("brightnessctl g"):read("*a"):sub(0, -2)) / 255 * 100) .. "%" +end) + +return brightness diff --git a/.config/awesome/ui/statusbar/widgets/clock.lua b/.config/awesome/ui/statusbar/widgets/clock.lua new file mode 100644 index 0000000..c7b3c29 --- /dev/null +++ b/.config/awesome/ui/statusbar/widgets/clock.lua @@ -0,0 +1,18 @@ +local vars = require "misc.vars" +local wibox = require "wibox" +local h = require "misc.helpers" + +local clock = wibox.widget { + widget = wibox.container.place, + { + format = "%H\n%M", + widget = wibox.widget.textclock, + font = vars.font + }, +} + +h.tooltip({ clock }, function() + return os.date("%a %d/%m/%y") +end) + +return clock diff --git a/.config/awesome/ui/statusbar/widgets/keyboardlayout.lua b/.config/awesome/ui/statusbar/widgets/keyboardlayout.lua new file mode 100644 index 0000000..0bbbf14 --- /dev/null +++ b/.config/awesome/ui/statusbar/widgets/keyboardlayout.lua @@ -0,0 +1,327 @@ +-- Slightly modified to not take up as much space + +--------------------------------------------------------------------------- +-- Display the current keyboard layout name in a widget. +-- +-- +-- @author Aleksey Fedotov <lexa@cfotr.com> +-- @copyright 2015 Aleksey Fedotov +-- @widgetmod awful.widget.keyboardlayout +-- @supermodule wibox.widget.base +--------------------------------------------------------------------------- + +local capi = {awesome = awesome} +local setmetatable = setmetatable +local textbox = require("wibox.widget.textbox") +local button = require("awful.button") +local widget_base = require("wibox.widget.base") +local gdebug = require("gears.debug") + +--- Keyboard Layout widget. +-- awful.widget.keyboardlayout +local keyboardlayout = { mt = {} } + +-- As to the country-code-like symbols below, refer to the names of XKB's +-- data files in /.../xkb/symbols/*. +keyboardlayout.xkeyboard_country_code = { + ["ad"] = true, -- Andorra + ["af"] = true, -- Afganistan + ["al"] = true, -- Albania + ["am"] = true, -- Armenia + ["ara"] = true, -- Arabic + ["at"] = true, -- Austria + ["az"] = true, -- Azerbaijan + ["ba"] = true, -- Bosnia and Herzegovina + ["bd"] = true, -- Bangladesh + ["be"] = true, -- Belgium + ["bg"] = true, -- Bulgaria + ["br"] = true, -- Brazil + ["bt"] = true, -- Bhutan + ["bw"] = true, -- Botswana + ["by"] = true, -- Belarus + ["ca"] = true, -- Canada + ["cd"] = true, -- Congo + ["ch"] = true, -- Switzerland + ["cm"] = true, -- Cameroon + ["cn"] = true, -- China + ["cz"] = true, -- Czechia + ["de"] = true, -- Germany + ["dk"] = true, -- Denmark + ["ee"] = true, -- Estonia + ["epo"] = true, -- Esperanto + ["es"] = true, -- Spain + ["et"] = true, -- Ethiopia + ["eu"] = true, -- EurKey + ["fi"] = true, -- Finland + ["fo"] = true, -- Faroe Islands + ["fr"] = true, -- France + ["gb"] = true, -- United Kingdom + ["ge"] = true, -- Georgia + ["gh"] = true, -- Ghana + ["gn"] = true, -- Guinea + ["gr"] = true, -- Greece + ["hr"] = true, -- Croatia + ["hu"] = true, -- Hungary + ["ie"] = true, -- Ireland + ["il"] = true, -- Israel + ["in"] = true, -- India + ["iq"] = true, -- Iraq + ["ir"] = true, -- Iran + ["is"] = true, -- Iceland + ["it"] = true, -- Italy + ["jp"] = true, -- Japan + ["ke"] = true, -- Kenya + ["kg"] = true, -- Kyrgyzstan + ["kh"] = true, -- Cambodia + ["kr"] = true, -- Korea + ["kz"] = true, -- Kazakhstan + ["la"] = true, -- Laos + ["latam"] = true, -- Latin America + ["latin"] = true, -- Latin + ["lk"] = true, -- Sri Lanka + ["lt"] = true, -- Lithuania + ["lv"] = true, -- Latvia + ["ma"] = true, -- Morocco + ["mao"] = true, -- Maori + ["me"] = true, -- Montenegro + ["mk"] = true, -- Macedonia + ["ml"] = true, -- Mali + ["mm"] = true, -- Myanmar + ["mn"] = true, -- Mongolia + ["mt"] = true, -- Malta + ["mv"] = true, -- Maldives + ["ng"] = true, -- Nigeria + ["nl"] = true, -- Netherlands + ["no"] = true, -- Norway + ["np"] = true, -- Nepal + ["ph"] = true, -- Philippines + ["pk"] = true, -- Pakistan + ["pl"] = true, -- Poland + ["pt"] = true, -- Portugal + ["ro"] = true, -- Romania + ["rs"] = true, -- Serbia + ["ru"] = true, -- Russia + ["se"] = true, -- Sweden + ["si"] = true, -- Slovenia + ["sk"] = true, -- Slovakia + ["sn"] = true, -- Senegal + ["sy"] = true, -- Syria + ["th"] = true, -- Thailand + ["tj"] = true, -- Tajikistan + ["tm"] = true, -- Turkmenistan + ["tr"] = true, -- Turkey + ["tw"] = true, -- Taiwan + ["tz"] = true, -- Tanzania + ["ua"] = true, -- Ukraine + ["us"] = true, -- USA + ["uz"] = true, -- Uzbekistan + ["vn"] = true, -- Vietnam + ["za"] = true, -- South Africa +} + +-- Callback for updating current layout. +local function update_status (self) + self._current = awesome.xkb_get_layout_group() + local text = "" + if #self._layout > 0 then + -- Please note that the group number reported by xkb_get_layout_group + -- is lower by one than the group numbers reported by xkb_get_group_names. + local name = self._layout[self._current+1] + if name then + text = name + end + end + self.widget:set_text(text) +end + +--- Auxiliary function for the local function update_layout(). +-- Create an array whose element is a table consisting of the four fields: +-- vendor, file, section and group_idx, which all correspond to the +-- xkb_symbols pattern "vendor/file(section):group_idx". +-- @tparam string group_names The string `awesome.xkb_get_group_names()` returns. +-- @treturn table An array of tables whose keys are vendor, file, section, and group_idx. +-- @staticfct awful.keyboardlayout.get_groups_from_group_names +function keyboardlayout.get_groups_from_group_names(group_names) + if group_names == nil then + return nil + end + + -- Pattern elements to be captured. + local word_pat = "([%w_]+)" + local sec_pat = "(%b())" + local idx_pat = ":(%d)" + -- Pairs of a pattern and its callback. In callbacks, set 'group_idx' to 1 + -- and return it if there's no specification on 'group_idx' in the given + -- pattern. + local pattern_and_callback_pairs = { + -- vendor/file(section):group_idx + ["^" .. word_pat .. "/" .. word_pat .. sec_pat .. idx_pat .. "$"] + = function(token, pattern) + local vendor, file, section, group_idx = string.match(token, pattern) + return vendor, file, section, group_idx + end, + -- vendor/file(section) + ["^" .. word_pat .. "/" .. word_pat .. sec_pat .. "$"] + = function(token, pattern) + local vendor, file, section = string.match(token, pattern) + return vendor, file, section, 1 + end, + -- vendor/file:group_idx + ["^" .. word_pat .. "/" .. word_pat .. idx_pat .. "$"] + = function(token, pattern) + local vendor, file, group_idx = string.match(token, pattern) + return vendor, file, nil, group_idx + end, + -- vendor/file + ["^" .. word_pat .. "/" .. word_pat .. "$"] + = function(token, pattern) + local vendor, file = string.match(token, pattern) + return vendor, file, nil, 1 + end, + -- file(section):group_idx + ["^" .. word_pat .. sec_pat .. idx_pat .. "$"] + = function(token, pattern) + local file, section, group_idx = string.match(token, pattern) + return nil, file, section, group_idx + end, + -- file(section) + ["^" .. word_pat .. sec_pat .. "$"] + = function(token, pattern) + local file, section = string.match(token, pattern) + return nil, file, section, 1 + end, + -- file:group_idx + ["^" .. word_pat .. idx_pat .. "$"] + = function(token, pattern) + local file, group_idx = string.match(token, pattern) + return nil, file, nil, group_idx + end, + -- file + ["^" .. word_pat .. "$"] + = function(token, pattern) + local file = string.match(token, pattern) + return nil, file, nil, 1 + end + } + + -- Split 'group_names' into 'tokens'. The separator is "+". + local tokens = {} + string.gsub(group_names, "[^+]+", function(match) + table.insert(tokens, match) + end) + + -- For each token in 'tokens', check if it matches one of the patterns in + -- the array 'pattern_and_callback_pairs', where the patterns are used as + -- key. If a match is found, extract captured strings using the + -- corresponding callback function. Check if those extracted is country + -- specific part of a layout. If so, add it to 'layout_groups'; otherwise, + -- ignore it. + local layout_groups = {} + for i = 1, #tokens do + for pattern, callback in pairs(pattern_and_callback_pairs) do + local vendor, file, section, group_idx = callback(tokens[i], pattern) + if file then + if not keyboardlayout.xkeyboard_country_code[file] then + break + end + + if section then + section = string.gsub(section, "%(([%w-_]+)%)", "%1") + end + + table.insert(layout_groups, { vendor = vendor, + file = file, + section = section, + group_idx = tonumber(group_idx) }) + break + end + end + end + + return layout_groups +end + +-- Callback for updating list of layouts +local function update_layout(self) + self._layout = {}; + local layouts = keyboardlayout.get_groups_from_group_names(awesome.xkb_get_group_names()) + if layouts == nil or layouts[1] == nil then + gdebug.print_error("Failed to get list of keyboard groups") + return + end + if #layouts == 1 then + layouts[1].group_idx = 1 + end + for _, v in ipairs(layouts) do + self._layout[v.group_idx] = self.layout_name(v) + end + update_status(self) +end + +--- Select the next layout. +-- @noreturn +-- @method next_layout + +--- Create a keyboard layout widget. +-- +-- It shows current keyboard layout name in a textbox. +-- +-- @constructorfct awful.widget.keyboardlayout +-- @treturn awful.widget.keyboardlayout A keyboard layout widget. +function keyboardlayout.new() + local widget = textbox() + local self = widget_base.make_widget(widget, nil, {enable_properties=true}) + + self.widget = widget + + self.layout_name = function(v) + local name = v.file + if v.section ~= nil then + name = name .. "(" .. v.section .. ")" + end + return name + end + + self.next_layout = function() + self.set_layout((self._current + 1) % (#self._layout + 1)) + end + + self.set_layout = function(group_number) + if (0 > group_number) or (group_number > #self._layout) then + error("Invalid group number: " .. group_number .. + "expected number from 0 to " .. #self._layout) + return; + end + awesome.xkb_set_layout_group(group_number); + end + + update_layout(self); + + -- callback for processing layout changes + capi.awesome.connect_signal("xkb::map_changed", + function () update_layout(self) end) + capi.awesome.connect_signal("xkb::group_changed", + function () update_status(self) end); + + -- Mouse bindings + self.buttons = { + button({ }, 1, self.next_layout) + } + + return self +end + +local _instance = nil; + +function keyboardlayout.mt:__call(...) + if _instance == nil then + _instance = keyboardlayout.new(...) + end + return _instance +end + + +return setmetatable(keyboardlayout, keyboardlayout.mt) + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 + diff --git a/.config/awesome/ui/statusbar/widgets/power_menu.lua b/.config/awesome/ui/statusbar/widgets/power_menu.lua new file mode 100644 index 0000000..e69de29 diff --git a/.config/awesome/components/statusbar/taglist.lua b/.config/awesome/ui/statusbar/widgets/taglist.lua similarity index 51% rename from .config/awesome/components/statusbar/taglist.lua rename to .config/awesome/ui/statusbar/widgets/taglist.lua index 8eb8d17..751cbf0 100644 --- a/.config/awesome/components/statusbar/taglist.lua +++ b/.config/awesome/ui/statusbar/widgets/taglist.lua @@ -1,9 +1,7 @@ local awful = require "awful" -local xresources = require "beautiful.xresources" -local dpi = xresources.apply_dpi -local vars = require "themes.prismite.vars" +local vars = require "misc.vars" local wibox = require "wibox" -local naughty = require "naughty" +local timed = require "lib.rubato".timed return awful.widget.taglist({ screen = screen[1], @@ -12,41 +10,40 @@ return awful.widget.taglist({ shape = vars.shape }, layout = { - spacing = 8, + spacing = vars.padding, layout = wibox.layout.fixed.vertical }, widget_template = { { - { - { - id = "text_role", - widget = wibox.widget.textbox, - }, - widget = wibox.container.place, - }, - { - widget = wibox.container.background, - bg = vars.colors.bright.black, - shape = vars.shape, - forced_height = dpi(2), - forced_width = dpi(16), - id = "indicator_role" - }, - layout = wibox.layout.fixed.vertical + widget = wibox.container.background, + bg = vars.colors.bright.black, + shape = vars.shape, + forced_height = vars.button_size, + forced_width = vars.button_size, + id = "indicator_role" }, widget = wibox.container.place, create_callback = function(self, tag) local indicator = self:get_children_by_id("indicator_role")[1] - local text = self:get_children_by_id("text_role")[1] - -- naughty.notification { - -- message = "b ".. tostring(text.font) - -- } - - -- text.font = "FiraCode Nerd Font Mono SemiBold 12" - -- naughty.notification { - -- message = "a " .. tostring(text.font) - -- } + self._anim = timed { + duration = vars.anim_duration, + intro = vars.anim_intro, + pos = indicator.height, + subscribed = function(pos) + indicator.forced_height = pos + end + } + + if tag.selected then + indicator.bg = vars.colors.yellow + self._anim.target = vars.button_size * 2 + elseif next(tag:clients()) then + indicator.bg = vars.colors.bright.black + self._anim.target = vars.button_size * 1.5 + else + self._anim.target = vars.button_size + end self:connect_signal("mouse::enter", function() if tag.selected then return end @@ -57,26 +54,32 @@ return awful.widget.taglist({ self:connect_signal("mouse::leave", function() if tag.selected then return end + if next(tag:clients()) then + indicator.bg = vars.colors.bright.black + return + end + indicator.bg = vars.colors.bright.black end) - - if tag.selected then - indicator.bg = vars.colors.yellow - end end, update_callback = function(self, tag) local indicator = self:get_children_by_id("indicator_role")[1] if tag.selected then indicator.bg = vars.colors.yellow + self._anim.target = vars.button_size * 2 + elseif next(tag:clients()) then + indicator.bg = vars.colors.bright.black + self._anim.target = vars.button_size * 1.5 else indicator.bg = vars.colors.bright.black + self._anim.target = vars.button_size end end }, buttons = { awful.button({ }, 1, function(t) t:view_only() end), - awful.button({ modkey }, 1, function(t) + awful.button(vars.mods.M, 1, function(t) if client.focus then client.focus:move_to_tag(t) end diff --git a/.config/awesome/components/statusbar/wifi.lua b/.config/awesome/ui/statusbar/widgets/wifi.lua similarity index 68% rename from .config/awesome/components/statusbar/wifi.lua rename to .config/awesome/ui/statusbar/widgets/wifi.lua index e6431ce..d0b7116 100644 --- a/.config/awesome/components/statusbar/wifi.lua +++ b/.config/awesome/ui/statusbar/widgets/wifi.lua @@ -1,8 +1,7 @@ local awful = require "awful" -local xresources = require "beautiful.xresources" -local dpi = xresources.apply_dpi -local vars = require "themes.prismite.vars" +local vars = require "misc.vars" local wibox = require "wibox" +local h = require "misc.helpers" local wifi_inner = awful.widget.watch("awk 'NR==3 {printf(\"%.0f\", $3*10/7)}' /proc/net/wireless", 1, function(widget, stdout) widget.font = "DejaVu Sans Mono wifi ramp Normal 8" @@ -42,19 +41,8 @@ local wifi = wibox.widget { wifi_inner } -awful.tooltip { - objects = { wifi }, - timer_function = function() - return io.popen("iwgetid -r"):read("*a"):sub(0, -2) - end, - bg = vars.colors.bg, - fg = vars.colors.fg, - border_color = vars.colors.bright.black, - border_width = vars.border_width, - font = vars.font, - shape = vars.shape, - margin_leftright = dpi(6), - margin_topbottom = dpi(6) -} +h.tooltip({ wifi }, function() + return io.popen("iwgetid -r"):read("*a"):sub(0, -2) +end) return wifi diff --git a/.config/awesome/ui/wicked/_default.lua b/.config/awesome/ui/wicked/_default.lua new file mode 100644 index 0000000..25283f9 --- /dev/null +++ b/.config/awesome/ui/wicked/_default.lua @@ -0,0 +1,94 @@ +---------------------------------------------------------------------------- +--- The default widget template for the notifications. +-- +-- @author Emmanuel Lepage Vallee <elv1313@gmail.com> +-- @copyright 2019 Emmanuel Lepage Vallee +-- @classmod naughty.widget._default +---------------------------------------------------------------------------- + +local wibox = require("wibox") +local actionlist = require("naughty.list.actions") +local wtitle = require("naughty.widget.title") +local wmessage = require("naughty.widget.message") +local wicon = require("naughty.widget.icon") +local wbg = require("naughty.container.background") +local beautiful = require("beautiful") +local dpi = require("beautiful").xresources.apply_dpi + +-- It is not worth doing a special widget for this. +local function notif_size() + local constraint = wibox.container.constraint() + constraint:set_strategy("max") + constraint:set_width(beautiful.notification_max_width or dpi(500)) + + rawset(constraint, "set_notification", function(_, notif) + constraint._private.notification = setmetatable({notif}, {__mode = "v"}) + local s = false + + if notif.width and notif.width ~= beautiful.notification_max_width then + constraint.width = notif.width + s = true + end + if notif.height then + constraint.height = notif.height + s = true + end + + constraint.strategy = s and "exact" or "max" + end) + + rawset(constraint, "get_notification", function() + return constraint._private.notification[1] + end) + + return constraint +end + +-- It is not worth doing a special widget for this either. +local function notif_margins() + local margins = wibox.container.margin() + margins:set_margins(beautiful.notification_margin or 4) + + rawset(margins, "set_notification", function(_, notif) + if notif.margin then + margins:set_margins(notif.margin) + end + end) + + return margins +end + +-- Used as a fallback when no widget_template is provided, emulate the legacy +-- widget. +return { + { + { + { + { + wicon, + { + widget = wibox.container.place, + valign = "center", + halign = "center", + { + wtitle, + wmessage, + -- spacing = 4, + layout = wibox.layout.fixed.vertical, + } + }, + fill_space = true, + -- spacing = 4, + layout = wibox.layout.fixed.horizontal + }, + actionlist, + -- spacing = 10, + layout = wibox.layout.fixed.vertical, + }, + widget = notif_margins, + }, + id = "background_role", + widget = wbg, + }, + widget = notif_size, +} diff --git a/.config/awesome/ui/wicked/init.lua b/.config/awesome/ui/wicked/init.lua new file mode 100644 index 0000000..5687b81 --- /dev/null +++ b/.config/awesome/ui/wicked/init.lua @@ -0,0 +1,101 @@ +local awful = require "awful" +local vars = require "misc.vars" +local wibox = require "wibox" +local debug = require "gears.debug" +local gtimer = require "gears.timer" +local naughty = require "naughty" +-- local rubato = require "lib.rubato" +local default = require "ui.wicked._default" +local h = require "misc.helpers" + +local beautiful = require "beautiful" +local xresources = require "beautiful.xresources" +local dpi = xresources.apply_dpi + +local wicked = {} + +wicked._active_notififcations = {} + +function wicked:notify(n) + -- local notif = wibox.widget { + local notif = h.popup { + -- widget = { + -- { + -- { + -- widget = naughty.widget.icon, + -- notification = n, + -- forced_height = 0, + -- forced_width = 0, + -- clip_shape = vars.shape, + -- id = "icon_role" + -- }, + -- { + -- { + -- widget = naughty.widget.title, + -- notification = n + -- }, + -- { + -- widget = naughty.widget.message, + -- notification = n + -- }, + -- layout = wibox.layout.fixed.vertical + -- }, + -- layout = wibox.layout.fixed.horizontal, + -- spacing = vars.padding + -- }, + -- widget = wibox.container.margin, + -- margins = vars.padding + -- }, + widget = { + -- { + { + widget = naughty.widget.icon, + notification = n + }, + { + widget = wibox.container.place, + valign = "center", + halign = "center", + { + { + widget = naughty.widget.title, + notification = n + }, + { + widget = naughty.widget.message, + notification = n + }, + -- spacing = 4, + layout = wibox.layout.fixed.vertical, + } + }, + fill_space = true, + -- spacing = 4, + layout = wibox.layout.fixed.horizontal + -- }, + -- actionlist, + -- spacing = 10, + -- layout = wibox.layout.fixed.vertical, + }, + placement = awful.placement.centered, + ontop = true + } + + gtimer { + timeout = vars.notif_timeout, + autostart = true, + callback = function() + notif.visible = false + notif = nil + end + } + + -- local icon = notif.widget:get_children_by_id("icon_role")[1] + + -- if n.image then + -- icon.forced_height = dpi(32) + -- icon.forced_width = dpi(32) + -- end +end + +return wicked diff --git a/.config/awesome/components/window_switcher/init.lua b/.config/awesome/ui/window_switcher/init.lua similarity index 98% rename from .config/awesome/components/window_switcher/init.lua rename to .config/awesome/ui/window_switcher/init.lua index 2e565f5..f14c865 100644 --- a/.config/awesome/components/window_switcher/init.lua +++ b/.config/awesome/ui/window_switcher/init.lua @@ -1,5 +1,5 @@ local awful = require "awful" -local vars = require "themes.prismite.vars" +local vars = require "misc.vars" local wibox = require "wibox" local obj = require "gears.object" local debug = require "gears.debug" @@ -28,7 +28,7 @@ local widget = awful.popup { layout = { forced_num_rows = 1, layout = wibox.layout.grid.vertical, - spacing = dpi(4) + spacing = vars.padding }, widget_template = { { @@ -92,7 +92,7 @@ local widget = awful.popup { id = "tasklist" }, widget = wibox.container.margin, - margins = dpi(4) + margins = vars.padding }, border_color = vars.colors.bright.black, border_width = vars.border_width, diff --git a/.config/fish/bindings.fish b/.config/fish/bindings.fish new file mode 100644 index 0000000..1ed7313 --- /dev/null +++ b/.config/fish/bindings.fish @@ -0,0 +1 @@ +bind \b backward-kill-word diff --git a/.config/fish/colors.fish b/.config/fish/colors.fish new file mode 100644 index 0000000..de32d6d --- /dev/null +++ b/.config/fish/colors.fish @@ -0,0 +1,23 @@ +# prompt +set fish_color_normal white +set fish_color_command white +set fish_color_keyword blue +set fish_color_quote yellow +set fish_color_redirection yellow +set fish_color_end pink +set fish_color_error white +set fish_color_param white +set fish_color_valid_path white +set fish_color_option white +set fish_color_comment "#8893a5" +set fish_color_operator white +set fish_color_escape yellow +set fish_color_autosuggestion "#8893a5" +set fish_color_search_match --background=black + +# pager +set fish_pager_color_progress "#8893a5" +set fish_pager_color_prefix white +set fish_pager_color_completion "#8893a5" +set fish_pager_color_description "#8893a5" +set fish_pager_color_selected_background --background=black diff --git a/.config/fish/config.fish b/.config/fish/config.fish new file mode 100644 index 0000000..2051e42 --- /dev/null +++ b/.config/fish/config.fish @@ -0,0 +1,59 @@ +# fish +set -gx FISH_CFG $XDG_CONFIG_HOME/fish +set -g fish_greeting +source $FISH_CFG/path.fish +set -gx LANG "en_US.UTF-8" + +# xdg +set -gx XDG_CONFIG_HOME "$HOME/.config" +set -gx XDG_CACHE_HOME "$HOME/.cache" +set -gx XDG_DATA_HOME "$HOME/.local/share" +set -gx XDG_STATE_HOME "$HOME/.local/state" + +# program +set -gx EDITOR "nvim" +set -gx VISUAL "lite-xl" +set -gx PF_INFO "ascii title os wm editor shell kernel palette" +set -gx BAT_THEME "ansi" +set -gx PNPM_HOME "$HOME/.local/share/pnpm" +set -gx GTK_USE_PORTAL 1 +set -gx LITE_SCALE 1.3 + +# $PATH +source $FISH_CFG/path.fish + +# colors +source $FISH_CFG/colors.fish + +# bindings +source $FISH_CFG/bindings.fish + +# configs +source $FISH_CFG/done_cfg.fish + +# abbreviations & aliases +abbr -a paru paru --limit 10 +abbr -a projects cd ~/DesktopTemp/RealProjects +abbr -a gc git commit -m +abbr -a ga git add +abbr -a gcl git clone +alias dots="git --git-dir=$HOME/.dots --work-tree=$HOME" +alias sudo="doas" +alias ls="ls --color=auto" +function ssh + export TERM=xterm-color + /usr/bin/ssh $argv + export TERM=xterm-kitty +end +function multicd + echo (string repeat -n (math (string length -- $argv[1]) - 1) ../) +end +abbr -a dotdot --regex '^\.\.+$' --position anywhere --function multicd +function last_history_item + echo $history[1] +end +abbr -a !! --position anywhere --function last_history_item + +# shell init +eval "$(ssh-agent -c)" +starship init fish | source diff --git a/.config/fish/done_cfg.fish b/.config/fish/done_cfg.fish new file mode 100644 index 0000000..1b8e154 --- /dev/null +++ b/.config/fish/done_cfg.fish @@ -0,0 +1 @@ +set -gx __done_exclude "lite-xl" diff --git a/.config/fish/fish_variables b/.config/fish/fish_variables new file mode 100644 index 0000000..fc6415f --- /dev/null +++ b/.config/fish/fish_variables @@ -0,0 +1,34 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR __done_exclude:lite\x2dxl +SETUVAR __fish_initialized:3400 +SETUVAR fish_color_autosuggestion:\x238893a5 +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:white +SETUVAR fish_color_comment:\x238893a5 +SETUVAR fish_color_cwd:green +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:pink +SETUVAR fish_color_error:white +SETUVAR fish_color_escape:yellow +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:yellow +SETUVAR fish_color_normal:white +SETUVAR fish_color_operator:white +SETUVAR fish_color_param:white +SETUVAR fish_color_quote:yellow +SETUVAR fish_color_redirection:yellow +SETUVAR fish_color_search_match:\x2d\x2dbackground\x3dblack +SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_status:red +SETUVAR fish_color_user:brgreen +SETUVAR fish_color_valid_path:white +SETUVAR fish_greeting:\x1d +SETUVAR fish_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_completion:\x238893a5 +SETUVAR fish_pager_color_description:\x238893a5 +SETUVAR fish_pager_color_prefix:white +SETUVAR fish_pager_color_progress:\x238893a5 +SETUVAR fish_pager_color_selected_background:\x2d\x2dbackground\x3dblack +SETUVAR fish_user_paths:/home/delta/\x2elocal/share/pnpm\x1e/home/delta/\x2elocal/bin\x1e/home/delta/\x2ecargo/bin\x1e/home/delta/\x2elocal/share/gem/ruby/3\x2e0\x2e0/bin\x1e/home/delta/\x2espicetify\x1e/home/delta/go/bin\x1e/home/delta/\x2edeno/bin diff --git a/.config/fish/functions/up-or-search.fish b/.config/fish/functions/up-or-search.fish new file mode 100644 index 0000000..11ef268 --- /dev/null +++ b/.config/fish/functions/up-or-search.fish @@ -0,0 +1,28 @@ +# Depending on cursor position and current mode, either search backward or move up one line" +function up-or-search -d "Search back or move cursor up 1 line" + # If we are already in search mode, continue + if commandline --search-mode + commandline -f history-prefix-search-backward + return + end + + # If we are navigating the pager, then up always navigates + if commandline --paging-mode + commandline -f up-line + return + end + + # We are not already in search mode. + # If we are on the top line, start search mode, + # otherwise move up + set -l lineno (commandline -L) + + switch $lineno + case 1 + commandline -f history-prefix-search-backward + + case '*' + commandline -f up-line + end +end + diff --git a/.config/fish/path.fish b/.config/fish/path.fish new file mode 100644 index 0000000..d0d3144 --- /dev/null +++ b/.config/fish/path.fish @@ -0,0 +1,20 @@ +alias fp="fish_add_path -a" + +# function pa +# set -x PATH PATH $argv[1] +# end +# +# function pp +# set -x PATH $argv[1] PATH +# end + +# ik this is not the "correct" way to set path but persistent path sucks + +fp $PNPM_HOME +fp ~/.deno/bin +fp ~/.local/bin +fp ~/usr/bin +fp ~/.cargo/bin +fp ~/.local/share/gem/ruby/3.0.0/bin +fp ~/.spicetify +fp ~/go/bin diff --git a/.config/wezterm/appearance.lua b/.config/wezterm/appearance.lua new file mode 100644 index 0000000..2376174 --- /dev/null +++ b/.config/wezterm/appearance.lua @@ -0,0 +1,62 @@ +local wezterm = require "wezterm" + +local function basename(s) + return string.gsub(s, '(.*[/\\])(.*)', '%2') +end + +local function home_or_path(path) + local realpath = path:sub(14, -1) -- file://lambda + local home = os.getenv("HOME") + return realpath == home and "~" or realpath +end + +wezterm.on("format-tab-title", function(tab) + local tab_format = { + { Text = " " }, + { Text = tostring(tab.tab_index + 1) }, + { Text = " " }, + { Text = basename(home_or_path(tab.active_pane.current_working_dir)) }, + { Text = " " }, + "ResetAttributes", + } + + if tab.is_active then + table.insert(tab_format, 1, { Background = { Color = C.black } }) + end + + return wezterm.format(tab_format) +end) + +return { + -- tabs + show_new_tab_button_in_tab_bar = false, + use_fancy_tab_bar = false, + tab_bar_at_bottom = true, + hide_tab_bar_if_only_one_tab = true, + + -- font + font = wezterm.font { + family = "FiraCode Nerd Font Mono", + harfbuzz_features = { "ss02", "ss03", "ss04", "ss08" } + }, + font_size = 10, + adjust_window_size_when_changing_font_size = false, + + -- cursor + default_cursor_style = "BlinkingUnderline", + cursor_blink_rate = 500, + animation_fps = 1, + + -- window + window_padding = { + left = 10, + right = 10, + top = 10, + bottom = 10 + }, + + -- colors + colors = R "colors", + bold_brightens_ansi_colors = false, + +} diff --git a/.config/wezterm/colors.lua b/.config/wezterm/colors.lua new file mode 100644 index 0000000..58ae639 --- /dev/null +++ b/.config/wezterm/colors.lua @@ -0,0 +1,48 @@ +return { + foreground = C.fg, + background = C.bg, + + cursor_bg = C.fg, + cursor_fg = C.bg, + cursor_border = C.bg, + + selection_bg = C.bright.black, + selection_fg = C.fg, + + visual_bell = C.white, + + ansi = { + C.black, + C.red, + C.green, + C.yellow, + C.blue, + C.pink, + C.cyan, + C.white, + }, + brights = { + C.bright.black, + C.bright.red, + C.bright.green, + C.bright.yellow, + C.bright.blue, + C.bright.pink, + C.bright.cyan, + C.bright.white, + }, + + tab_bar = { + background = C.bg, + + active_tab = { + bg_color = C.bg, + fg_color = C.fg + }, + + inactive_tab = { + bg_color = C.bg, + fg_color = C.fg_dark + }, + } +} diff --git a/.config/wezterm/inspect.lua b/.config/wezterm/inspect.lua new file mode 100644 index 0000000..ce90145 --- /dev/null +++ b/.config/wezterm/inspect.lua @@ -0,0 +1,372 @@ +local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local math = _tl_compat and _tl_compat.math or math; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table +local inspect = {Options = {}, } + + + + + + + + + + + + + + + + + +inspect._VERSION = 'inspect.lua 3.1.0' +inspect._URL = 'http://github.com/kikito/inspect.lua' +inspect._DESCRIPTION = 'human-readable representations of tables' +inspect._LICENSE = [[ + MIT LICENSE + + Copyright (c) 2022 Enrique García Cota + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +]] +inspect.KEY = setmetatable({}, { __tostring = function() return 'inspect.KEY' end }) +inspect.METATABLE = setmetatable({}, { __tostring = function() return 'inspect.METATABLE' end }) + +local tostring = tostring +local rep = string.rep +local match = string.match +local char = string.char +local gsub = string.gsub +local fmt = string.format + +local _rawget +if rawget then + _rawget = rawget +else + _rawget = function(t, k) return t[k] end +end + +local function rawpairs(t) + return next, t, nil +end + + + +local function smartQuote(str) + if match(str, '"') and not match(str, "'") then + return "'" .. str .. "'" + end + return '"' .. gsub(str, '"', '\\"') .. '"' +end + + +local shortControlCharEscapes = { + ["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n", + ["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v", ["\127"] = "\\127", +} +local longControlCharEscapes = { ["\127"] = "\127" } +for i = 0, 31 do + local ch = char(i) + if not shortControlCharEscapes[ch] then + shortControlCharEscapes[ch] = "\\" .. i + longControlCharEscapes[ch] = fmt("\\%03d", i) + end +end + +local function escape(str) + return (gsub(gsub(gsub(str, "\\", "\\\\"), + "(%c)%f[0-9]", longControlCharEscapes), + "%c", shortControlCharEscapes)) +end + +local luaKeywords = { + ['and'] = true, + ['break'] = true, + ['do'] = true, + ['else'] = true, + ['elseif'] = true, + ['end'] = true, + ['false'] = true, + ['for'] = true, + ['function'] = true, + ['goto'] = true, + ['if'] = true, + ['in'] = true, + ['local'] = true, + ['nil'] = true, + ['not'] = true, + ['or'] = true, + ['repeat'] = true, + ['return'] = true, + ['then'] = true, + ['true'] = true, + ['until'] = true, + ['while'] = true, +} + +local function isIdentifier(str) + return type(str) == "string" and + not not str:match("^[_%a][_%a%d]*$") and + not luaKeywords[str] +end + +local flr = math.floor +local function isSequenceKey(k, sequenceLength) + return type(k) == "number" and + flr(k) == k and + 1 <= (k) and + k <= sequenceLength +end + +local defaultTypeOrders = { + ['number'] = 1, ['boolean'] = 2, ['string'] = 3, ['table'] = 4, + ['function'] = 5, ['userdata'] = 6, ['thread'] = 7, +} + +local function sortKeys(a, b) + local ta, tb = type(a), type(b) + + + if ta == tb and (ta == 'string' or ta == 'number') then + return (a) < (b) + end + + local dta = defaultTypeOrders[ta] or 100 + local dtb = defaultTypeOrders[tb] or 100 + + + return dta == dtb and ta < tb or dta < dtb +end + +local function getKeys(t) + + local seqLen = 1 + while _rawget(t, seqLen) ~= nil do + seqLen = seqLen + 1 + end + seqLen = seqLen - 1 + + local keys, keysLen = {}, 0 + for k in rawpairs(t) do + if not isSequenceKey(k, seqLen) then + keysLen = keysLen + 1 + keys[keysLen] = k + end + end + table.sort(keys, sortKeys) + return keys, keysLen, seqLen +end + +local function countCycles(x, cycles) + if type(x) == "table" then + if cycles[x] then + cycles[x] = cycles[x] + 1 + else + cycles[x] = 1 + for k, v in rawpairs(x) do + countCycles(k, cycles) + countCycles(v, cycles) + end + countCycles(getmetatable(x), cycles) + end + end +end + +local function makePath(path, a, b) + local newPath = {} + local len = #path + for i = 1, len do newPath[i] = path[i] end + + newPath[len + 1] = a + newPath[len + 2] = b + + return newPath +end + + +local function processRecursive(process, + item, + path, + visited) + if item == nil then return nil end + if visited[item] then return visited[item] end + + local processed = process(item, path) + if type(processed) == "table" then + local processedCopy = {} + visited[item] = processedCopy + local processedKey + + for k, v in rawpairs(processed) do + processedKey = processRecursive(process, k, makePath(path, k, inspect.KEY), visited) + if processedKey ~= nil then + processedCopy[processedKey] = processRecursive(process, v, makePath(path, processedKey), visited) + end + end + + local mt = processRecursive(process, getmetatable(processed), makePath(path, inspect.METATABLE), visited) + if type(mt) ~= 'table' then mt = nil end + setmetatable(processedCopy, mt) + processed = processedCopy + end + return processed +end + +local function puts(buf, str) + buf.n = buf.n + 1 + buf[buf.n] = str +end + + + +local Inspector = {} + + + + + + + + + + +local Inspector_mt = { __index = Inspector } + +local function tabify(inspector) + puts(inspector.buf, inspector.newline .. rep(inspector.indent, inspector.level)) +end + +function Inspector:getId(v) + local id = self.ids[v] + local ids = self.ids + if not id then + local tv = type(v) + id = (ids[tv] or 0) + 1 + ids[v], ids[tv] = id, id + end + return tostring(id) +end + +function Inspector:putValue(v) + local buf = self.buf + local tv = type(v) + if tv == 'string' then + puts(buf, smartQuote(escape(v))) + elseif tv == 'number' or tv == 'boolean' or tv == 'nil' or + tv == 'cdata' or tv == 'ctype' then + puts(buf, tostring(v)) + elseif tv == 'table' and not self.ids[v] then + local t = v + + if t == inspect.KEY or t == inspect.METATABLE then + puts(buf, tostring(t)) + elseif self.level >= self.depth then + puts(buf, '{...}') + else + if self.cycles[t] > 1 then puts(buf, fmt('<%d>', self:getId(t))) end + + local keys, keysLen, seqLen = getKeys(t) + + puts(buf, '{') + self.level = self.level + 1 + + for i = 1, seqLen + keysLen do + if i > 1 then puts(buf, ',') end + if i <= seqLen then + puts(buf, ' ') + self:putValue(t[i]) + else + local k = keys[i - seqLen] + tabify(self) + if isIdentifier(k) then + puts(buf, k) + else + puts(buf, "[") + self:putValue(k) + puts(buf, "]") + end + puts(buf, ' = ') + self:putValue(t[k]) + end + end + + local mt = getmetatable(t) + if type(mt) == 'table' then + if seqLen + keysLen > 0 then puts(buf, ',') end + tabify(self) + puts(buf, ' = ') + self:putValue(mt) + end + + self.level = self.level - 1 + + if keysLen > 0 or type(mt) == 'table' then + tabify(self) + elseif seqLen > 0 then + puts(buf, ' ') + end + + puts(buf, '}') + end + + else + puts(buf, fmt('<%s %d>', tv, self:getId(v))) + end +end + + + + +function inspect.inspect(root, options) + options = options or {} + + local depth = options.depth or (math.huge) + local newline = options.newline or '\n' + local indent = options.indent or ' ' + local process = options.process + + if process then + root = processRecursive(process, root, {}, {}) + end + + local cycles = {} + countCycles(root, cycles) + + local inspector = setmetatable({ + buf = { n = 0 }, + ids = {}, + cycles = cycles, + depth = depth, + level = 0, + newline = newline, + indent = indent, + }, Inspector_mt) + + inspector:putValue(root) + + return table.concat(inspector.buf) +end + +setmetatable(inspect, { + __call = function(_, root, options) + return inspect.inspect(root, options) + end, +}) + +return inspect + diff --git a/.config/wezterm/keys.lua b/.config/wezterm/keys.lua new file mode 100644 index 0000000..0bba603 --- /dev/null +++ b/.config/wezterm/keys.lua @@ -0,0 +1,40 @@ +local wezterm = require "wezterm" +local act = wezterm.action +local act_callback = wezterm.action_callback + +local function kb(mods, key, action) + return { mods = mods, key = key, action = action } +end + +return { + disable_default_key_bindings = true, + keys = { + -- tabs + kb("SHIFT|CTRL", "t", act.SpawnTab "CurrentPaneDomain"), + kb("SHIFT|CTRL", "q", act.CloseCurrentTab { confirm = false }), + kb("SHIFT|CTRL", "LeftArrow", act.ActivateTabRelative(-1)), + kb("SHIFT|CTRL", "RightArrow", act.ActivateTabRelative(1)), + + -- panes + kb("SHIFT|ALT", "w", act.SplitVertical { domain = "CurrentPaneDomain" }), + kb("SHIFT|ALT", "d", act.SplitHorizontal { domain = "CurrentPaneDomain" }), + kb("SHIFT|ALT", "q", act.CloseCurrentPane { confirm = false }), + kb("SHIFT|ALT", "UpArrow", act.ActivatePaneDirection "Up"), + kb("SHIFT|ALT", "DownArrow", act.ActivatePaneDirection "Down"), + kb("SHIFT|ALT", "LeftArrow", act.ActivatePaneDirection "Left"), + kb("SHIFT|ALT", "RightArrow", act.ActivatePaneDirection "Right"), + + -- general + kb("CTRL", "c", act_callback(function(w, p) + local has_selection = w:get_selection_text_for_pane(p) ~= "" + + if has_selection then + w:perform_action(act.CopyTo "Clipboard", p) + else + w:perform_action(act.SendKey { mods = "CTRL", key = "c" }, p) + end + end)), + kb("CTRL", "v", act.PasteFrom "Clipboard"), + kb("CTRL", "f", act.Search "CurrentSelectionOrEmptyString") + } +} diff --git a/.config/wezterm/wezterm.lua b/.config/wezterm/wezterm.lua new file mode 100644 index 0000000..0cd46b6 --- /dev/null +++ b/.config/wezterm/wezterm.lua @@ -0,0 +1,61 @@ +local wezterm = require "wezterm" + +function R(name) + local m = require(name) + return m +end + +C = { + fg = "#dfe2e7", + bg = "#222831", + fg_dark = "#8893a5", + bg_dark = "#1e232b", + + black = "#252c36", + red = "#de615c", + green = "#91d89a", + yellow = "#ffc469", + blue = "#8fc7ff", + pink = "#f2b9c1", + cyan = "#9cfdff", + white = "#dfe2e7", + + bright = { + black = "#2c3440", + red = "#e8908d", + green = "#b2e4b8", + yellow = "#ffd696", + blue = "#b1d8ff", + pink = "#f6ced4", + cyan = "#bafeff", + white = "#e9ebee", + } +} + + +function M(...) + local mt = {} + for _,t in ipairs {...} do + for k,v in pairs(t) do + mt[k] = v + end + end + return mt +end + +wezterm.on("bell", function() + wezterm.background_child_process { + "notify-send", + "bell" + } +end) + +return M( + { + window_close_confirmation = "NeverPrompt", + check_for_updates = false + }, + R "appearance", + R "keys" +) +-- return {} diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..9f8367c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule ".config/awesome/.config/awesome/lib/bling"] + path = .config/awesome/.config/awesome/lib/bling + url = https://github.com/BlingCorp/bling +[submodule "/home/delta/.config/awesome/lib/bling"] + path = /home/delta/.config/awesome/lib/bling + url = https://github.com/BlingCorp/bling +[submodule "/home/delta/.config/awesome/lib/rubato"] + path = /home/delta/.config/awesome/lib/rubato + url = https://github.com/andOrlando/rubato