diff --git a/.config/awesome/.old-luarc.json b/.config/awesome/.old-luarc.json new file mode 100644 index 0000000..b62f876 --- /dev/null +++ b/.config/awesome/.old-luarc.json @@ -0,0 +1,14 @@ +{ + "diagnostics.globals": [ + "awesome", + "client", + "mouse", + "mousegrabber", + "root", + "screen", + "tag" + ], + "workspace.library": [ + "/usr/share/awesome/lib" + ] +} diff --git a/.config/awesome/assets/phosphor/battery-charging-vertical-fill.svg b/.config/awesome/assets/phosphor/battery-charging-vertical-fill.svg new file mode 100644 index 0000000..71c8c2c --- /dev/null +++ b/.config/awesome/assets/phosphor/battery-charging-vertical-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/battery-vertical-empty-fill.svg b/.config/awesome/assets/phosphor/battery-vertical-empty-fill.svg new file mode 100644 index 0000000..6b61106 --- /dev/null +++ b/.config/awesome/assets/phosphor/battery-vertical-empty-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/battery-vertical-full-fill.svg b/.config/awesome/assets/phosphor/battery-vertical-full-fill.svg new file mode 100644 index 0000000..a172515 --- /dev/null +++ b/.config/awesome/assets/phosphor/battery-vertical-full-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/battery-vertical-high-fill.svg b/.config/awesome/assets/phosphor/battery-vertical-high-fill.svg new file mode 100644 index 0000000..1e906dd --- /dev/null +++ b/.config/awesome/assets/phosphor/battery-vertical-high-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/battery-vertical-low-fill.svg b/.config/awesome/assets/phosphor/battery-vertical-low-fill.svg new file mode 100644 index 0000000..fe75375 --- /dev/null +++ b/.config/awesome/assets/phosphor/battery-vertical-low-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/battery-vertical-medium-fill.svg b/.config/awesome/assets/phosphor/battery-vertical-medium-fill.svg new file mode 100644 index 0000000..c79684d --- /dev/null +++ b/.config/awesome/assets/phosphor/battery-vertical-medium-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/battery-warning-vertical-fill.svg b/.config/awesome/assets/phosphor/battery-warning-vertical-fill.svg new file mode 100644 index 0000000..5f05e98 --- /dev/null +++ b/.config/awesome/assets/phosphor/battery-warning-vertical-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/caret-right-fill.svg b/.config/awesome/assets/phosphor/caret-right-fill.svg new file mode 100644 index 0000000..daffee9 --- /dev/null +++ b/.config/awesome/assets/phosphor/caret-right-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/circle-bold.svg b/.config/awesome/assets/phosphor/circle-bold.svg new file mode 100644 index 0000000..76b13a7 --- /dev/null +++ b/.config/awesome/assets/phosphor/circle-bold.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/circle-fill.svg b/.config/awesome/assets/phosphor/circle-fill.svg new file mode 100644 index 0000000..e95cc79 --- /dev/null +++ b/.config/awesome/assets/phosphor/circle-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/cloud-moon-fill.svg b/.config/awesome/assets/phosphor/cloud-moon-fill.svg new file mode 100644 index 0000000..8039262 --- /dev/null +++ b/.config/awesome/assets/phosphor/cloud-moon-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/dot-fill.svg b/.config/awesome/assets/phosphor/dot-fill.svg new file mode 100644 index 0000000..e4966ac --- /dev/null +++ b/.config/awesome/assets/phosphor/dot-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/dot-outline-fill.svg b/.config/awesome/assets/phosphor/dot-outline-fill.svg new file mode 100644 index 0000000..15fe425 --- /dev/null +++ b/.config/awesome/assets/phosphor/dot-outline-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/init.lua b/.config/awesome/assets/phosphor/init.lua new file mode 100644 index 0000000..0df3958 --- /dev/null +++ b/.config/awesome/assets/phosphor/init.lua @@ -0,0 +1,14 @@ +local qfs = require "quarrel.fs" +local gfs = require "gears.filesystem" +local gsurface = require "gears.surface" + +local icons = {} +local phosphor_dir = gfs.get_configuration_dir() .. "assets/phosphor/" + +for _, icon in ipairs(qfs.ls_files(phosphor_dir)) do + if icon:match(".+%.(.+)") == "svg" then + icons[icon:match("(.+)%..+"):gsub("-", "_")] = gsurface.load_uncached(phosphor_dir .. icon) + end +end + +return icons diff --git a/.config/awesome/assets/phosphor/moon-fill.svg b/.config/awesome/assets/phosphor/moon-fill.svg new file mode 100644 index 0000000..f37579c --- /dev/null +++ b/.config/awesome/assets/phosphor/moon-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/speaker-simple-high-fill.svg b/.config/awesome/assets/phosphor/speaker-simple-high-fill.svg new file mode 100644 index 0000000..9173143 --- /dev/null +++ b/.config/awesome/assets/phosphor/speaker-simple-high-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/speaker-simple-low-fill.svg b/.config/awesome/assets/phosphor/speaker-simple-low-fill.svg new file mode 100644 index 0000000..ea4dfad --- /dev/null +++ b/.config/awesome/assets/phosphor/speaker-simple-low-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/speaker-simple-none-fill.svg b/.config/awesome/assets/phosphor/speaker-simple-none-fill.svg new file mode 100644 index 0000000..0207086 --- /dev/null +++ b/.config/awesome/assets/phosphor/speaker-simple-none-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/speaker-simple-x-fill.svg b/.config/awesome/assets/phosphor/speaker-simple-x-fill.svg new file mode 100644 index 0000000..aa7f1c9 --- /dev/null +++ b/.config/awesome/assets/phosphor/speaker-simple-x-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/sun-dim-fill.svg b/.config/awesome/assets/phosphor/sun-dim-fill.svg new file mode 100644 index 0000000..91b3aff --- /dev/null +++ b/.config/awesome/assets/phosphor/sun-dim-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/sun-fill.svg b/.config/awesome/assets/phosphor/sun-fill.svg new file mode 100644 index 0000000..dbfc78e --- /dev/null +++ b/.config/awesome/assets/phosphor/sun-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/sun-horizon-fill.svg b/.config/awesome/assets/phosphor/sun-horizon-fill.svg new file mode 100644 index 0000000..f9164e7 --- /dev/null +++ b/.config/awesome/assets/phosphor/sun-horizon-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/triangle-fill.svg b/.config/awesome/assets/phosphor/triangle-fill.svg new file mode 100644 index 0000000..6bff4d7 --- /dev/null +++ b/.config/awesome/assets/phosphor/triangle-fill.svg @@ -0,0 +1 @@ + diff --git a/.config/awesome/assets/phosphor/wifi-high-fill.svg b/.config/awesome/assets/phosphor/wifi-high-fill.svg new file mode 100644 index 0000000..9a15a4a --- /dev/null +++ b/.config/awesome/assets/phosphor/wifi-high-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/wifi-low-fill.svg b/.config/awesome/assets/phosphor/wifi-low-fill.svg new file mode 100644 index 0000000..ac280ca --- /dev/null +++ b/.config/awesome/assets/phosphor/wifi-low-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/wifi-medium-fill.svg b/.config/awesome/assets/phosphor/wifi-medium-fill.svg new file mode 100644 index 0000000..c4b83fb --- /dev/null +++ b/.config/awesome/assets/phosphor/wifi-medium-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/wifi-none-fill.svg b/.config/awesome/assets/phosphor/wifi-none-fill.svg new file mode 100644 index 0000000..4e2962a --- /dev/null +++ b/.config/awesome/assets/phosphor/wifi-none-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/assets/phosphor/wifi-x-fill.svg b/.config/awesome/assets/phosphor/wifi-x-fill.svg new file mode 100644 index 0000000..c3c19bb --- /dev/null +++ b/.config/awesome/assets/phosphor/wifi-x-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.config/awesome/misc/autostart.lua b/.config/awesome/misc/autostart.lua new file mode 100644 index 0000000..8cf50b6 --- /dev/null +++ b/.config/awesome/misc/autostart.lua @@ -0,0 +1,19 @@ +local awful = require "awful" +local quarrel = require "quarrel" + +if quarrel.is_restart() then return end + +local programs = { + "picom -b", + "sxhkd", + "clipcatd", + "wezterm", + "wezterm start --class code_term", + "firefox", + "discord", + "spotify" +} + +for _, program in ipairs(programs) do + awful.spawn(program) +end diff --git a/.config/awesome/misc/autostart/init.lua b/.config/awesome/misc/autostart/init.lua deleted file mode 100644 index e0d4efb..0000000 --- a/.config/awesome/misc/autostart/init.lua +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index dbafe44..0000000 --- a/.config/awesome/misc/autostart/programs.sh +++ /dev/null @@ -1,22 +0,0 @@ -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/helpers.lua b/.config/awesome/misc/helpers.lua deleted file mode 100644 index 132a4df..0000000 --- a/.config/awesome/misc/helpers.lua +++ /dev/null @@ -1,121 +0,0 @@ -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 index ce17c05..d3c36b2 100644 --- a/.config/awesome/misc/init.lua +++ b/.config/awesome/misc/init.lua @@ -1,5 +1,3 @@ -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 index 6d83ec4..94091af 100644 --- a/.config/awesome/misc/keys.lua +++ b/.config/awesome/misc/keys.lua @@ -1,20 +1,20 @@ local awful = require "awful" -local gears = require "gears" +local gtimer = require "gears.timer" local naughty = require "naughty" local cfg = require "misc.cfg" +local qbind = require "quarrel.bind" 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 flashy = require "ui.flashy" +local qvars = require "quarrel.vars" local recording = { false, "" } client.connect_signal("request::default_mousebindings", function() awful.mouse.append_client_mousebindings { - insightful:bind { - mods = {}, - triggers = btn.LEFT, + qbind:new { + triggers = qvars.btns.left, press = function (c) c:activate { context = "mouse_click" @@ -23,9 +23,9 @@ client.connect_signal("request::default_mousebindings", function() group = "client", desc = "raise client" }, - insightful:bind { - mods = vars.mods.M, - triggers = btn.LEFT, + qbind:new { + mods = qvars.mods.M, + triggers = qvars.btns.left, press = function (c) c:activate { context = "mouse_click", @@ -35,9 +35,9 @@ client.connect_signal("request::default_mousebindings", function() group = "client", desc = "move client" }, - insightful:bind { - mods = vars.mods.M, - triggers = btn.RIGHT, + qbind:new { + mods = qvars.mods.M, + triggers = qvars.btns.right, press = function (c) c:activate { context = "mouse_click", @@ -50,35 +50,82 @@ client.connect_signal("request::default_mousebindings", function() } end) -local globalkeys = gears.table.join( - insightful:bind { - mods = vars.mods.MC, +client.connect_signal("request::default_keybindings", function() + awful.keyboard.append_client_keybindings { + qbind:new { + mods = qvars.mods.MC, + triggers = "q", + press = function(c) + c:kill() + end, + group = "client", + desc = "close" + }, + qbind:new { + mods = qvars.mods.M, + triggers = "m", + press = function(c) + c.maximized = not c.maximized + end, + group = "client", + desc = "(un)maximize" + }, + qbind:new { + mods = qvars.mods.M, + triggers = "n", + press = function(c) + gtimer.delayed_call(function() + c.minimized = true + end) + end, + group = "client", + desc = "minimize" + }, + qbind:new { + mods = qvars.mods.M, + triggers = "f", + press = function(c) + c.fullscreen = not c.fullscreen + end, + group = "client", + desc = "toggle fullscreen" + } + } +end) + +awful.keyboard.append_global_keybindings { + qbind:new { + mods = qvars.mods.MC, triggers = "r", press = awesome.restart, group = "awesome", desc = "restart awesome" }, - insightful:bind { - mods = vars.mods.MC, - triggers = "s", + qbind:new { + mods = qvars.mods.M, + triggers = "F1", press = function() insightful:toggle() end, group = "awesome", desc = "toggle insightful" }, - insightful:bind { - mods = vars.mods.MC, + qbind:new { + mods = qvars.mods.MC, triggers = "a", press = function() - archaic:toggle() + if flashy._widget.visible then + flashy:hide() + else + flashy:show() + end end, group = "awesome", - desc = "toggle notification center" + desc = "toggle flashy" }, - insightful:bind { - mods = vars.mods.M, - triggers = " ", + qbind:new { + mods = qvars.mods.M, + triggers = "space", press = function() fresnel:show() end, @@ -86,7 +133,7 @@ local globalkeys = gears.table.join( desc = "toggle fresnel" }, - insightful:bind { + qbind:new { mods = {}, triggers = "XF86AudioMute", press = function() @@ -95,7 +142,7 @@ local globalkeys = gears.table.join( group = "audio", desc = "mute" }, - insightful:bind { + qbind:new { mods = {}, triggers = { { "XF86AudioRaiseVolume", true }, @@ -111,7 +158,7 @@ local globalkeys = gears.table.join( group = "audio", desc = "increase/decrease volume" }, - insightful:bind { + qbind:new { mods = {}, triggers = { { "XF86AudioNext", true }, @@ -127,7 +174,7 @@ local globalkeys = gears.table.join( group = "audio", desc = "previous/next song" }, - insightful:bind { + qbind:new { mods = {}, triggers = "XF86AudioPlay", press = function() @@ -137,7 +184,7 @@ local globalkeys = gears.table.join( desc = "(un)pause song" }, - insightful:bind { + qbind:new { mods = {}, triggers = { { "XF86MonBrightnessUp", true }, @@ -154,8 +201,8 @@ local globalkeys = gears.table.join( desc = "increase/decrease brightness" }, - insightful:bind { - mods = vars.mods.M, + qbind:new { + mods = qvars.mods.M, triggers = "Return", press = function() awful.spawn(cfg.terminal) @@ -164,94 +211,35 @@ local globalkeys = gears.table.join( 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 { + qbind:new { 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 - } + -- Can't use naughty.notification cause it gets in the screenshot + -- Also can't use easy_async_with_shell cause it's buggy + awful.spawn.with_shell("maim --hidecursor " .. path .. " && xclip -selection clipboard -t image/png " .. path .. [[ && notify-send -a "Maim" "Screenshot taken" "Saved at ]] .. path .. [["]]) end, group = "screenshot", desc = "take fullscreen screenshot" }, - insightful:bind { - mods = vars.mods.S, + qbind:new { + mods = qvars.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, + qbind:new { + mods = qvars.mods.M, triggers = "Print", press = function() if recording[1] then @@ -277,8 +265,8 @@ local globalkeys = gears.table.join( desc = "toggle recording" }, - insightful:bind { - mods = vars.mods.M, + qbind:new { + mods = qvars.mods.M, triggers = "k", press = function() awful.spawn("xkblayout-state set +1") @@ -286,8 +274,8 @@ local globalkeys = gears.table.join( group = "keyboard", desc = "next keyboard layout" }, - insightful:bind { - mods = vars.mods.MS, + qbind:new { + mods = qvars.mods.MS, triggers = "k", press = function() awful.spawn("xkblayout-state set -1") @@ -296,23 +284,18 @@ local globalkeys = gears.table.join( desc = "previous keyboard layout" }, - insightful:bind { - mods = vars.mods.M, + qbind:new { + mods = qvars.mods.M, triggers = "Up", press = awful.tag.viewprev, group = "tag", desc = "switch to previous" }, - insightful:bind { - mods = vars.mods.M, + qbind:new { + mods = qvars.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/misc/rules.lua b/.config/awesome/misc/rules.lua index 803d49a..b777ae8 100644 --- a/.config/awesome/misc/rules.lua +++ b/.config/awesome/misc/rules.lua @@ -1,7 +1,6 @@ local ruled = require "ruled" local beautiful = require "beautiful" local awful = require "awful" -local vars = require "misc.vars" ruled.client.connect_signal("request::rules", function() ruled.client.append_rule({ @@ -15,9 +14,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, honor_padding = true - -- tag = "1" } }) @@ -47,7 +44,7 @@ ruled.client.connect_signal("request::rules", function() ruled.client.append_rule({ id = "browser_tag", rule_any = { - class = { "firefox" } + instance = { "Navigator" } }, properties = { screen = 1, diff --git a/.config/awesome/misc/setup.lua b/.config/awesome/misc/setup.lua deleted file mode 100644 index aeee19a..0000000 --- a/.config/awesome/misc/setup.lua +++ /dev/null @@ -1,65 +0,0 @@ -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/prismite.lua b/.config/awesome/prismite.lua index 194254d..14c6987 100644 --- a/.config/awesome/prismite.lua +++ b/.config/awesome/prismite.lua @@ -1,61 +1,43 @@ local xresources = require "beautiful.xresources" local dpi = xresources.apply_dpi -local g = require("gears") local naughty = require("naughty") -local vars = require "misc.vars" +local qvars = require "quarrel.vars" local theme = {} -theme.font = vars.font +theme.font = qvars.font -theme.bg_normal = vars.colors.bg -theme.bg_focus = vars.colors.bg -theme.bg_urgent = vars.colors.bg -theme.bg_minimize = vars.colors.bg -theme.bg_systray = vars.colors.bg +theme.bg_normal = qvars.colors.bg +theme.bg_focus = qvars.colors.bg +theme.bg_urgent = qvars.colors.bg +theme.bg_minimize = qvars.colors.bg +theme.bg_systray = qvars.colors.bg -theme.fg_normal = vars.colors.fg -theme.fg_focus = vars.colors.fg -theme.fg_urgent = vars.colors.fg -theme.fg_minimize = vars.colors.fg +theme.fg_normal = qvars.colors.fg +theme.fg_focus = qvars.colors.fg +theme.fg_urgent = qvars.colors.fg +theme.fg_minimize = qvars.colors.fg theme.useless_gap = dpi(2) -theme.border_width = vars.border_width -theme.border_normal = vars.colors.bright.black -theme.border_focus = vars.colors.bright.black -theme.border_marked = vars.colors.bright.black - -theme.titlebar_close_button_normal = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.red, "transparent", 4) -theme.titlebar_close_button_focus = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.red, "transparent", 4) -theme.titlebar_close_button_normal_hover = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.bright.red, "transparent", 4) -theme.titlebar_close_button_focus_hover = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.bright.red, "transparent", 4) - -theme.titlebar_minimize_button_normal = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.yellow, "transparent", 4) -theme.titlebar_minimize_button_focus = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.yellow, "transparent", 4) -theme.titlebar_minimize_button_normal_hover = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.bright.yellow, "transparent", 4) -theme.titlebar_minimize_button_focus_hover = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.bright.yellow, "transparent", 4) - -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.titlebar_maximized_button_normal_active_hover = g.surface.load_from_shape(15, 15, g.shape.rounded_rect, vars.colors.green, "transparent", 4) +theme.border_width = qvars.border_width +theme.border_normal = qvars.colors.bright.black +theme.border_focus = qvars.colors.bright.black +theme.border_marked = qvars.colors.bright.black theme.notification_icon_size = dpi(32) -theme.notification_border_width = vars.border_width +theme.notification_border_width = qvars.border_width theme.notification_border_color = theme.border_normal -theme.notification_shape = vars.shape +theme.notification_shape = qvars.shape theme.notification_spacing = theme.useless_gap * 2 naughty.config.presets.critical.bg = theme.bg_normal naughty.config.presets.critical.timeout = 3 naughty.config.presets.critical.fg = theme.fg_normal -naughty.config.presets.critical.border_color = vars.colors.red +naughty.config.presets.critical.border_color = qvars.colors.red naughty.config.defaults.position = "bottom_right" -naughty.config.defaults.border_width = vars.border_width +naughty.config.defaults.border_width = qvars.border_width theme.tasklist_plain_task_name = true theme.enable_spawn_cursor = false diff --git a/.config/awesome/quarrel/bind.lua b/.config/awesome/quarrel/bind.lua new file mode 100644 index 0000000..327da0b --- /dev/null +++ b/.config/awesome/quarrel/bind.lua @@ -0,0 +1,61 @@ +local awful = require "awful" +local gtable = require "gears.table" +local insightful = require "ui.insightful" + +local qbind = {} + +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 qbind:new(binding) + if not binding.hidden then table.insert(insightful._bindings, binding) end + binding.mods = binding.mods or {} + + local awful_bindings = {} + + 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 qbind diff --git a/.config/awesome/quarrel/fs.lua b/.config/awesome/quarrel/fs.lua new file mode 100644 index 0000000..89a1bc6 --- /dev/null +++ b/.config/awesome/quarrel/fs.lua @@ -0,0 +1,29 @@ +local GFile = require "lgi".Gio.File + +local qfs = {} + +function qfs.read(path, format) + local f = assert(io.open(path, "r")) + local c = f:read(format or "a") + f:close() + return c +end + +function qfs.ls_files(path, absolute) + local files = GFile.new_for_path(path):enumerate_children("standard::*", 0) + local files_filtered = {} + + if not files then return {} end + + for file in function() return files:next_file() end do + if file:get_file_type() == "REGULAR" then + local file_name = file:get_display_name() + file_name = absolute and (path:gsub("[/]*$", "") .. "/" .. file_name) or file_name + table.insert(files_filtered, file_name) + end + end + + return files_filtered +end + +return qfs diff --git a/.config/awesome/quarrel/init.lua b/.config/awesome/quarrel/init.lua new file mode 100644 index 0000000..025d899 --- /dev/null +++ b/.config/awesome/quarrel/init.lua @@ -0,0 +1,17 @@ +local n = require "naughty".notification + +local quarrel = {} + +function quarrel.debug(message) + n { message = tostring(message) } +end + +function quarrel.is_restart() + awesome.register_xproperty("is_restart", "boolean") + local restart_detected = awesome.get_xproperty("is_restart") ~= nil + awesome.set_xproperty("is_restart", true) + + return restart_detected + end + +return quarrel diff --git a/.config/awesome/quarrel/math.lua b/.config/awesome/quarrel/math.lua new file mode 100644 index 0000000..bc1f53b --- /dev/null +++ b/.config/awesome/quarrel/math.lua @@ -0,0 +1,19 @@ +local qmath = {} + +function qmath.step_value(value, steps) + for i, step in ipairs(steps) do + if step[1] <= value and value <= steps[i + 1][1] then + return step[2] + end + end +end + +function qmath.translate_range(value, in_min, in_max, out_min, out_max) + return out_min + ((out_max - out_min) / (in_max - in_min)) * (value - in_min) +end + +function qmath.clamp(value, min, max) + return math.max(math.min(value, max), min) +end + +return qmath diff --git a/.config/awesome/ui/fresnel/lenses/.gitignore b/.config/awesome/quarrel/native/.gitignore similarity index 100% rename from .config/awesome/ui/fresnel/lenses/.gitignore rename to .config/awesome/quarrel/native/.gitignore diff --git a/.config/awesome/ui/fresnel/lenses/Cargo.toml b/.config/awesome/quarrel/native/Cargo.toml similarity index 76% rename from .config/awesome/ui/fresnel/lenses/Cargo.toml rename to .config/awesome/quarrel/native/Cargo.toml index 4dcb8bc..3806f3c 100644 --- a/.config/awesome/ui/fresnel/lenses/Cargo.toml +++ b/.config/awesome/quarrel/native/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "lenses" +name = "qnative" version = "0.1.0" edition = "2021" @@ -7,8 +7,10 @@ edition = "2021" [dependencies] freedesktop_entry_parser = "1.3.0" -meval = "0.2.0" +# meval = "0.2.0" +cpc = "1.9.1" mlua = { version = "0.8.7", features = [ "module", "lua54", "serialize" ] } +palette = { version = "0.6.1", default-features = false, features = [ "std" ] } parking_lot = "0.12.1" rayon = "1.6.1" serde = { version = "1.0.152", features = [ "derive" ] } diff --git a/.config/awesome/quarrel/native/init.lua b/.config/awesome/quarrel/native/init.lua new file mode 100644 index 0000000..14c66e5 --- /dev/null +++ b/.config/awesome/quarrel/native/init.lua @@ -0,0 +1,6 @@ +local old_cpath = package.cpath +local cfg = require("gears.filesystem").get_configuration_dir() +package.cpath = package.cpath .. ";" .. cfg .. "quarrel/native/lib?.so" +local qnative = require "qnative" +package.cpath = old_cpath +return qnative diff --git a/.config/awesome/ui/fresnel/lenses/install.log b/.config/awesome/quarrel/native/install.log similarity index 100% rename from .config/awesome/ui/fresnel/lenses/install.log rename to .config/awesome/quarrel/native/install.log diff --git a/.config/awesome/quarrel/native/libqnative.so b/.config/awesome/quarrel/native/libqnative.so new file mode 120000 index 0000000..5fc821d --- /dev/null +++ b/.config/awesome/quarrel/native/libqnative.so @@ -0,0 +1 @@ +target/debug/libqnative.so \ No newline at end of file diff --git a/.config/awesome/ui/fresnel/lenses/rustfmt.toml b/.config/awesome/quarrel/native/rustfmt.toml similarity index 100% rename from .config/awesome/ui/fresnel/lenses/rustfmt.toml rename to .config/awesome/quarrel/native/rustfmt.toml diff --git a/.config/awesome/ui/fresnel/lenses/src/application.rs b/.config/awesome/quarrel/native/src/lenses/application.rs similarity index 64% rename from .config/awesome/ui/fresnel/lenses/src/application.rs rename to .config/awesome/quarrel/native/src/lenses/application.rs index 0cf6c1a..4317c75 100644 --- a/.config/awesome/ui/fresnel/lenses/src/application.rs +++ b/.config/awesome/quarrel/native/src/lenses/application.rs @@ -9,12 +9,12 @@ use parking_lot::Mutex; use rayon::prelude::*; use url::Url; -use crate::entry::{ +use crate::lenses::entry::{ entries_to_lua_table, Entry, }; -fn parse_entry<'a>(entry: fd::Entry, path: PathBuf) -> Result { +fn parse_entry(entry: &fd::Entry, path: &PathBuf) -> Result { let section = entry.section("Desktop Entry"); let name = section.attr("Name").ok_or(())?.to_string(); @@ -22,31 +22,24 @@ fn parse_entry<'a>(entry: fd::Entry, path: PathBuf) -> Result { 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 => {} + if section.attr("OnlyShowIn").is_some() + || section.attr("Hidden").is_some() + || section.attr("NoDisplay").is_some() + { + return Err(()); } let exec = section.attr("Exec").ok_or(())?.to_string(); let mut new_exec = exec.clone(); - for (index, _) in exec.match_indices("%") { + 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 => {} - }, + 'i' => { + if let Some(icon) = section.attr("Icon") { + new_exec.replace_range(index..index + 2, &format!("--icon {icon}")); + } + } 'c' => new_exec.replace_range(index..index + 2, &name), - 'k' => new_exec.replace_range(index..index + 2, Url::from_file_path(&path)?.as_str()), + '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, @@ -75,23 +68,18 @@ pub fn query(lua: &Lua, input: String) -> LuaResult { let entries = entries .into_iter() - .filter(|e| match e.extension() { - Some(ext) if ext == "desktop" => true, - None | _ => false, - }) + .filter(|e| matches!(e.extension(), Some(ext) if ext == "desktop")) .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, + let Ok(entry) = fd::parse_entry(&path) else { + return }; - match parse_entry(entry, path) { - Ok(parsed_entry) => parsed_entries.lock().push(parsed_entry), - Err(_) => return, + if let Ok(parsed_entry) = parse_entry(&entry, &path) { + parsed_entries.lock().push(parsed_entry); } }); diff --git a/.config/awesome/quarrel/native/src/lenses/calculator.rs b/.config/awesome/quarrel/native/src/lenses/calculator.rs new file mode 100644 index 0000000..89b738e --- /dev/null +++ b/.config/awesome/quarrel/native/src/lenses/calculator.rs @@ -0,0 +1,36 @@ +// use meval::eval_str; +use cpc::{ + eval, + units::Unit, +}; +use mlua::prelude::*; + +use crate::lenses::entry::{ + entries_to_lua_table, + Entry, +}; + +pub fn query<'a>(lua: &Lua, input: String) -> LuaResult { + let result = match eval(input.trim(), true, Unit::Celsius, false) { + Ok(result) => { + format!( + "{}{}", + result.value, + match result.unit { + Unit::NoUnit => "".to_owned(), + _ => format!(" {:?}", result.unit), + } + ) + } + Err(_) => return lua.create_table(), + }; + + Ok(entries_to_lua_table( + vec![Entry { + message: result, + exec: None, + provider: "Calculator".to_string(), + }], + lua, + )) +} diff --git a/.config/awesome/ui/fresnel/lenses/src/entry.rs b/.config/awesome/quarrel/native/src/lenses/entry.rs similarity index 94% rename from .config/awesome/ui/fresnel/lenses/src/entry.rs rename to .config/awesome/quarrel/native/src/lenses/entry.rs index d6e7467..c7ac09e 100644 --- a/.config/awesome/ui/fresnel/lenses/src/entry.rs +++ b/.config/awesome/quarrel/native/src/lenses/entry.rs @@ -8,7 +8,6 @@ use serde::Serialize; pub struct Entry { pub message: String, pub exec: Option<(String, bool)>, - // pub icon: char, pub provider: String, } diff --git a/.config/awesome/quarrel/native/src/lenses/mod.rs b/.config/awesome/quarrel/native/src/lenses/mod.rs new file mode 100644 index 0000000..d0db6f7 --- /dev/null +++ b/.config/awesome/quarrel/native/src/lenses/mod.rs @@ -0,0 +1,3 @@ +pub mod application; +pub mod calculator; +pub mod entry; diff --git a/.config/awesome/quarrel/native/src/lib.rs b/.config/awesome/quarrel/native/src/lib.rs new file mode 100644 index 0000000..3a016c4 --- /dev/null +++ b/.config/awesome/quarrel/native/src/lib.rs @@ -0,0 +1,15 @@ +mod lenses; + +use mlua::prelude::*; + +#[mlua::lua_module] +fn qnative(lua: &Lua) -> LuaResult { + let lenses = lua.create_table()?; + lenses.set("1", lua.create_function(lenses::calculator::query)?)?; + lenses.set("2", lua.create_function(lenses::application::query)?)?; + + let exports = lua.create_table()?; + exports.set("lenses", lenses)?; + + Ok(exports) +} diff --git a/.config/awesome/quarrel/table.lua b/.config/awesome/quarrel/table.lua new file mode 100644 index 0000000..13ccbce --- /dev/null +++ b/.config/awesome/quarrel/table.lua @@ -0,0 +1,59 @@ +local qtable = {} + +function qtable.map(t, f) + local nt = {} + for k,v in pairs(t) do + nt[k] = f(v) + end + return nt +end + +function qtable.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 + +function qtable.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 qtable.opairs(t) + return qtable.onext, t, nil +end + +return qtable diff --git a/.config/awesome/quarrel/ui.lua b/.config/awesome/quarrel/ui.lua new file mode 100644 index 0000000..8e979cb --- /dev/null +++ b/.config/awesome/quarrel/ui.lua @@ -0,0 +1,52 @@ +local awful = require "awful" +local gears = require "gears" +local qvars = require "quarrel.vars" +local wibox = require "wibox" + +local qui = {} + +function qui.markup_fg(color, text) + return "" .. text .. "" +end + +function qui.markup_bg(color, text) + return "" .. text .. "" +end + +function qui.font(factor) + return qvars.text_font .. " " .. qvars.font_size * (factor or 1) +end + +function qui.symbol_font(factor) + return qvars.symbol_font .. " " .. qvars.font_size * (factor or 1) +end + +function qui.styled(target) + return gears.table.crush({ + bg = qvars.colors.bg, + border_color = qvars.colors.bright.black, + border_width = qvars.border_width, + shape = qvars.shape + }, target) +end + +function qui.popup(args) + args.widget = { + widget = wibox.container.margin, + margins = qvars.big_padding, + args.widget + } + + return awful.popup(qui.styled(args)) +end + +function qui.tooltip(objects, callback) + awful.tooltip(qui.styled { + objects = objects, + timer_function = callback, + margin_leftright = qvars.padding, + margin_topbottom = qvars.padding + }) +end + +return qui diff --git a/.config/awesome/misc/vars.lua b/.config/awesome/quarrel/vars.lua similarity index 58% rename from .config/awesome/misc/vars.lua rename to .config/awesome/quarrel/vars.lua index 7a5f9c8..cbc7f00 100644 --- a/.config/awesome/misc/vars.lua +++ b/.config/awesome/quarrel/vars.lua @@ -1,43 +1,45 @@ +local btns = require "awful".button.names 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 = {} +local qvars = {} -v.notif_timeout = 3 +qvars.anim_duration = 0.15 +qvars.anim_intro = qvars.anim_duration / 4 -v.anim_duration = 0.15 -v.anim_intro = v.anim_duration / 2 +qvars.notif_timeout = 3 + qvars.anim_duration * 2 -function v.shape(cr,w,h) +function qvars.shape(cr,w,h) gears.shape.rounded_rect(cr,w,h,dpi(4)) end -v.border_width = dpi(1.5) +qvars.border_width = dpi(1.5) -v.padding = dpi(4) -v.big_padding = dpi(8) +qvars.padding = dpi(4) +qvars.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 +qvars.text_font = "Fira Code Nerd Font Mono Medium" +qvars.symbol_font = "Symbols Nerd Font:style=1000-em" +qvars.font_size = 8 +qvars.font = qvars.text_font .. " " .. qvars.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 +qvars.char_height = char_height +qvars.char_width = char_width -v.bar_size = dpi(16) +-- qvars.bar_size = dpi(16) +qvars.bar_size = dpi(24) + qvars.big_padding * 2 +qvars.icon_size = qvars.char_height +qvars.button_size = dpi(12) -v.button_size = dpi(12) - -v.colors = { +qvars.colors = { fg = x_col.foreground, bg = x_col.background, @@ -68,7 +70,7 @@ v.colors = { } -- 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" } }, { +qvars.mods = setmetatable({ _SHORT_MAP = { C = "Control", S = "Shift", A = "Mod1", M = "Mod4" } }, { __index = function(self, key) local resolved_mods = {} for i = 1, #key do @@ -78,4 +80,12 @@ v.mods = setmetatable({ _SHORT_MAP = { C = "Control", S = "Shift", A = "Mod1", M end }) -return v +qvars.btns = { + left = btns.LEFT, + right = btns.RIGHT, + middle = btns.MIDDLE, + up = btns.SCROLL_UP, + down = btns.SCROLL_DOWN +} + +return qvars diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index d48d7f7..aecbdb5 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -10,8 +10,9 @@ pcall(require, "luarocks.loader") -- --=-=-=-=-=-=-=-=-=-=-=-= A colorful and comfy AWM theme =-=-=-=-=-=-=-=-=-=-=-=-- -local beautiful = require "beautiful" -beautiful.init(require("gears").filesystem.get_configuration_dir() .. "/prismite.lua") +require("beautiful").init(require("gears.filesystem").get_configuration_dir() .. "/prismite.lua") +require "signals" +require "services" require "misc" require "ui" diff --git a/.config/awesome/scripts/maimtake b/.config/awesome/scripts/maimtake deleted file mode 100755 index 4b7f9e3..0000000 --- a/.config/awesome/scripts/maimtake +++ /dev/null @@ -1,26 +0,0 @@ -#!/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/services/battery.lua b/.config/awesome/services/battery.lua new file mode 100644 index 0000000..c2a7f3e --- /dev/null +++ b/.config/awesome/services/battery.lua @@ -0,0 +1,14 @@ +local gtimer = require "gears.timer" +local qfs = require "quarrel.fs" + +gtimer { + timeout = 1, + call_now = true, + autostart = true, + callback = function() + local capacity = qfs.read("/sys/class/power_supply/BAT0/capacity", "n") + local status = qfs.read("/sys/class/power_supply/BAT0/status", "l") + + awesome.emit_signal("services::battery", capacity, status) + end +} diff --git a/.config/awesome/services/brightness.lua b/.config/awesome/services/brightness.lua new file mode 100644 index 0000000..b8d07e7 --- /dev/null +++ b/.config/awesome/services/brightness.lua @@ -0,0 +1,13 @@ +local gtimer = require "gears.timer" +local qfs = require "quarrel.fs" + +gtimer { + timeout = 1, + call_now = true, + autostart = true, + callback = function() + local brightness = qfs.read("/sys/class/backlight/amdgpu_bl0/actual_brightness", "n") + + awesome.emit_signal("services::brightness", brightness) + end +} diff --git a/.config/awesome/services/init.lua b/.config/awesome/services/init.lua new file mode 100644 index 0000000..23f6dd3 --- /dev/null +++ b/.config/awesome/services/init.lua @@ -0,0 +1,3 @@ +require "services.battery" +require "services.brightness" +require "services.wifi" diff --git a/.config/awesome/services/wifi.lua b/.config/awesome/services/wifi.lua new file mode 100644 index 0000000..f6b67f1 --- /dev/null +++ b/.config/awesome/services/wifi.lua @@ -0,0 +1,23 @@ +local gtimer = require "gears.timer" + +gtimer { + timeout = 1, + call_now = true, + autostart = true, + callback = function() + local lines = {} + + for line in io.lines("/proc/net/wireless") do + table.insert(lines, line) + end + + if not lines[3] then + awesome.emit_signal("services::wifi", 0, false) + return + end + + local strength = lines[3]:match("^%s*(.*)"):match("^.-%s+.-%s+.-(%S+)%.") + + awesome.emit_signal("services::wifi", math.floor(tonumber(strength) * 10 / 7), true) + end +} diff --git a/.config/awesome/signals/awesome.lua b/.config/awesome/signals/awesome.lua new file mode 100644 index 0000000..37b9bdb --- /dev/null +++ b/.config/awesome/signals/awesome.lua @@ -0,0 +1,32 @@ +-- 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/signals/client.lua b/.config/awesome/signals/client.lua new file mode 100644 index 0000000..31f3d9c --- /dev/null +++ b/.config/awesome/signals/client.lua @@ -0,0 +1,34 @@ +local qvars = require "quarrel.vars" +local rectangle = require "gears.shape".rectangle + +-- io.popen spams logs, don't use +-- client.connect_signal("property::name", function(c) +-- 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("request::manage", function (c) + c.shape = qvars.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 = qvars.shape + c.border_width = qvars.border_width + end +end + +client.connect_signal("property::maximized", handle_corners) +client.connect_signal("property::fullscreen", handle_corners) diff --git a/.config/awesome/signals/init.lua b/.config/awesome/signals/init.lua new file mode 100644 index 0000000..69c74b5 --- /dev/null +++ b/.config/awesome/signals/init.lua @@ -0,0 +1,5 @@ +require "signals.awesome" +require "signals.naughty" +require "signals.screen" +require "signals.client" + diff --git a/.config/awesome/signals/naughty.lua b/.config/awesome/signals/naughty.lua new file mode 100644 index 0000000..49187c0 --- /dev/null +++ b/.config/awesome/signals/naughty.lua @@ -0,0 +1,54 @@ +local naughty = require "naughty" +local awful = require "awful" +local beautiful = require "beautiful" +local wibox = require "wibox" +local qvars = require "quarrel.vars" + +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, + widget_template = { + widget = wibox.container.margin, + margins = qvars.big_padding, + { + { + 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 = n.icon and qvars.big_padding or 0, + layout = wibox.layout.fixed.horizontal + } + } + } +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/misc/signals.lua b/.config/awesome/signals/screen.lua similarity index 54% rename from .config/awesome/misc/signals.lua rename to .config/awesome/signals/screen.lua index a65ca43..ea247a3 100644 --- a/.config/awesome/misc/signals.lua +++ b/.config/awesome/signals/screen.lua @@ -1,37 +1,4 @@ -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( diff --git a/.config/awesome/ui/archaic/init.lua b/.config/awesome/ui/archaic/init.lua index eace674..df7bbda 100644 --- a/.config/awesome/ui/archaic/init.lua +++ b/.config/awesome/ui/archaic/init.lua @@ -2,41 +2,40 @@ 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 qvars = require "quarrel.vars" +local qui = require "quarrel.ui" 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 height = screen[1].geometry.height - (beautiful.useless_gap * 4 + qvars.border_width * 2) +local inside_width = qvars.bar_size * 20 - (qvars.big_padding * 4 + qvars.border_width * 4 + qvars.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, + clip_shape = qvars.shape, + forced_width = qvars.bar_size * 4, + forced_height = qvars.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, + forced_width = qvars.bar_size * 4, + forced_height = qvars.bar_size * 4, + bg = qvars.colors.black, + fg = qvars.colors.dim.fg, + shape = qvars.shape, { widget = wibox.container.place, { widget = wibox.widget.textbox, text = "󰝚", - font = h.font(4) + font = qui.font(4) } }, id = "no_cover" @@ -52,15 +51,15 @@ local song = wibox.widget { local artist = wibox.widget { widget = wibox.widget.textbox, - markup = h.markup_fg(vars.colors.dim.fg, "Nothing Playing "), - font = h.font(0.8), + markup = qui.markup_fg(qvars.colors.dim.fg, "Nothing Playing "), + font = qui.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)) + font = qui.symbol_font(1.5), + forced_height = beautiful.get_font_height(qui.symbol_font(0.5)) } back:add_button(awful.button { modifiers = {}, @@ -73,8 +72,8 @@ back:add_button(awful.button { 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)) + font = qui.font(1.5), + forced_height = beautiful.get_font_height(qui.font(0.5)) } play_pause:add_button(awful.button { modifiers = {}, @@ -94,8 +93,8 @@ 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)) + font = qui.font(1.5), + forced_height = beautiful.get_font_height(qui.font(0.5)) } forward:add_button(awful.button { @@ -110,16 +109,16 @@ 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 + shape = qvars.shape, + bar_shape = qvars.shape, + forced_height = beautiful.get_font_height(qui.font(0.5)), + forced_width = inside_width - (qvars.padding * 2 + qvars.big_padding + back:get_preferred_size_at_dpi(screen[1].dpi) * 3), + color = qvars.colors.yellow, + background_color = qvars.colors.black } local progress_smoothing = rubato.timed { - duration = vars.anim_duration, - intro = vars.anim_intro, + duration = qvars.anim_duration, + intro = qvars.anim_intro, pos = 0, subscribed = function(pos) progress_bar.value = pos @@ -135,23 +134,23 @@ local archaic = {} archaic.playerctl = playerctl -archaic.widget = h.popup { +archaic.widget = qui.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_width = qvars.bar_size * 20, + maximum_width = qvars.bar_size * 20, minimum_height = height, maximum_height = height, widget = { - h.styled { + qui.styled { widget = wibox.container.background, { widget = wibox.container.margin, - margins = vars.big_padding, + margins = qvars.big_padding, { cover, { @@ -183,8 +182,8 @@ archaic.widget = h.popup { stops = { { 0, "#0000000" }, { 0.95, "#0000000" }, - { 0.95, vars.colors.bg .. "1a" }, - { 1, vars.colors.bg } + { 0.95, qvars.colors.bg .. "1a" }, + { 1, qvars.colors.bg } } } }, @@ -198,15 +197,15 @@ archaic.widget = h.popup { play_pause, forward, - spacing = vars.padding, + spacing = qvars.padding, layout = wibox.layout.fixed.horizontal }, - spacing = vars.big_padding, + spacing = qvars.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 + spacing = qvars.big_padding - qvars.border_width, -- for some reason awesome adds border_width here layout = wibox.layout.fixed.horizontal } } @@ -219,7 +218,7 @@ 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 .. " ")) + artist:set_markup(qui.markup_fg(qvars.colors.dim.fg, _artist .. " ")) if _cover == "" then cover.cover.visible = false cover.no_cover.visible = true diff --git a/.config/awesome/ui/conductor/init.lua b/.config/awesome/ui/conductor/init.lua new file mode 100644 index 0000000..1790d0d --- /dev/null +++ b/.config/awesome/ui/conductor/init.lua @@ -0,0 +1,26 @@ +local awful = require "awful" +local qui = require "quarrel.ui" +local q = require "quarrel" +local qvars = require "quarrel.vars" + +awful.keygrabber { + keybindings = { + awful.key { + modifiers = qvars.mods.A, + key = "Tab", + on_press = awful.client.focus.history.previous + }, + awful.key { + modifiers = qvars.mods.AS, + key = "Tab", + on_press = awful.client.focus.history.next + }, + }, + -- Note that it is using the key name and not the modifier name. + stop_key = "Mod1", + stop_event = "release", + -- start_callback = awful.client.focus.history.disable_tracking, + stop_callback = awful.client.focus.history.enable_tracking, + export_keybindings = true, + autostart = true +} diff --git a/.config/awesome/ui/decorations/titlebar.lua b/.config/awesome/ui/decorations/titlebar.lua index 8451817..9463dbc 100644 --- a/.config/awesome/ui/decorations/titlebar.lua +++ b/.config/awesome/ui/decorations/titlebar.lua @@ -1,5 +1,5 @@ local awful = require "awful" -local vars = require "misc.vars" +local qvars = require "quarrel.vars" local gears = require "gears" local wibox = require "wibox" local rubato = require "lib.rubato" @@ -8,10 +8,10 @@ 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, + forced_height = qvars.button_size, + forced_width = qvars.button_size, bg = color, - shape = vars.shape, + shape = qvars.shape, buttons = { callback } } @@ -19,13 +19,13 @@ local function button(color, color_focus, callback) local timed = rubato.timed { duration = 0.1, intro = 0.05, - pos = vars.button_size, + pos = qvars.button_size, subscribed = function(pos) widget.forced_width = pos end } - timed.target = vars.button_size * 2 + timed.target = qvars.button_size * 2 widget.bg = color_focus end) @@ -33,13 +33,13 @@ local function button(color, color_focus, callback) local timed = rubato.timed { duration = 0.1, intro = 0.05, - pos = vars.button_size * 2, + pos = qvars.button_size * 2, subscribed = function(pos) widget.forced_width = pos end } - timed.target = vars.button_size + timed.target = qvars.button_size widget.bg = color end) @@ -51,31 +51,31 @@ client.connect_signal("request::titlebars", function(c) local titlebar = awful.titlebar(c, { position = "top", - size = vars.button_size + vars.padding * 2 + size = qvars.button_size + qvars.padding * 2 }) awful.titlebar.enable_tooltip = false titlebar.widget = { widget = wibox.container.margin, - margins = vars.padding, + margins = qvars.padding, { nil, nil, { - button(vars.colors.green, vars.colors.bright.green, awful.button({}, 1, function() + button(qvars.colors.green, qvars.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() + button(qvars.colors.yellow, qvars.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() + button(qvars.colors.red, qvars.colors.bright.red, awful.button({}, 1, function() c:kill() end)), - spacing = vars.padding, + spacing = qvars.padding, layout = wibox.layout.fixed.horizontal }, layout = wibox.layout.align.horizontal diff --git a/.config/awesome/ui/decorations/wallpaper.lua b/.config/awesome/ui/decorations/wallpaper.lua index f7104ff..3c85b83 100644 --- a/.config/awesome/ui/decorations/wallpaper.lua +++ b/.config/awesome/ui/decorations/wallpaper.lua @@ -1,11 +1,11 @@ local wallpaper = require "awful.wallpaper" local wibox = require "wibox" -local vars = require "misc.vars" -local h = require "misc.helpers" +local qvars = require "quarrel.vars" +local qui = require "quarrel.ui" screen.connect_signal("request::wallpaper", function(s) wallpaper { - bg = vars.colors.dim.bg, + bg = qvars.colors.dim.bg, screen = s, widget = { widget = wibox.container.place, @@ -13,14 +13,14 @@ screen.connect_signal("request::wallpaper", function(s) halign = "center", { widget = wibox.widget.textbox, - font = h.font(1.5), + font = qui.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, " \\/__/") + qui.markup_fg(qvars.colors.red, " ___"), + qui.markup_fg(qvars.colors.green, " /\\ \\"), + qui.markup_fg(qvars.colors.yellow, " /::\\ \\"), + qui.markup_fg(qvars.colors.blue, "/::\\:\\__\\"), + qui.markup_fg(qvars.colors.pink, "\\/\\::/ /"), + qui.markup_fg(qvars.colors.cyan, " \\/__/") }, "\n") } } diff --git a/.config/awesome/ui/flashy/init.lua b/.config/awesome/ui/flashy/init.lua new file mode 100644 index 0000000..65f7518 --- /dev/null +++ b/.config/awesome/ui/flashy/init.lua @@ -0,0 +1,74 @@ +local awful = require "awful" +local gtable = require "gears.table" +local gdebug = require "gears.debug" +local gcolor = require "gears.color" +local qui = require "quarrel.ui" +local qvars = require "quarrel.vars" +local wibox = require "wibox" +local phosphor = require "assets.phosphor" +local beautiful = require "beautiful" +local rubato = require "lib.rubato" + +local flashy = {} +flashy._timeout_timer = {} + +flashy._widget = qui.popup { + placement = awful.placement.centered, + ontop = true, + minimum_width = qvars.button_size * 15, + maximum_width = qvars.button_size * 15, + minimum_height = qvars.button_size * 15, + maximum_height = qvars.button_size * 15, + visible = false, + widget = { + { + widget = wibox.container.place, + valign = "center", + haligh = "center", + -- widget = wibox.container.margin, + -- margins = qvars.big_padding * 8, + { + widget = wibox.widget.imagebox, + image = gcolor.recolor_image(phosphor.battery_warning, qvars.colors.fg), + -- image = phosphor["battery_warning"], + forced_width = qvars.button_size * 15 - (qvars.border_width * 2 + qvars.big_padding * 2), + forced_height = qvars.button_size * 14 - (qvars.border_width * 2 + qvars.big_padding * 2) + } + }, + { + widget = wibox.widget.progressbar, + max_value = 100, + value = 50, + forced_height = qvars.button_size; + shape = qvars.shape, + color = qvars.colors.yellow, + background_color = qvars.colors.black + }, + layout = wibox.layout.fixed.vertical + } +} + +flashy._timed = rubato.timed { + duration = qvars.anim_duration, + intro = qvars.anim_intro, + pos = 0, + subscribed = function(pos) + flashy._widget.opacity = pos + + if pos == 0 then + flashy._widget.visible = false + else + flashy._widget.visible = true + end + end +} + +function flashy:show() + self._timed.target = 1 +end + +function flashy:hide() + self._timed.target = 0 +end + +return flashy diff --git a/.config/awesome/ui/fresnel/init.lua b/.config/awesome/ui/fresnel/init.lua index cf1357a..242603f 100644 --- a/.config/awesome/ui/fresnel/init.lua +++ b/.config/awesome/ui/fresnel/init.lua @@ -1,19 +1,16 @@ 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 qui = require "quarrel.ui" +local qtable = require "quarrel.table" +local qnative = require "quarrel.native" local cfg = require "misc.cfg" -local vars = require "misc.vars" +local qvars = require "quarrel.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 = {} @@ -27,7 +24,7 @@ fresnel._selected_index = 1 function fresnel:_exec_entry(entry_index) local exec = self._entries_exec[entry_index] - if type(exec) ~= "userdata" then + if type(exec) ~= "userdata" and type(exec) ~= "nil" then awful.spawn((exec[2] and cfg.terminal .. " -e " or "") .. exec[1]) end end @@ -49,7 +46,7 @@ function fresnel:_update(query, scrolled) self._entries_exec = {} layout:reset() - for _, provider in h.opairs(lenses) do + for _, provider in qtable.opairs(qnative.lenses) do local entries = provider(query) table.sort(entries, function(a, b) @@ -70,18 +67,18 @@ function fresnel:_update(query, scrolled) local entry_widget = wibox.widget { widget = wibox.container.background, - shape = vars.shape, + shape = qvars.shape, { widget = wibox.container.margin, - margins = vars.padding, + margins = qvars.padding, { widget = wibox.container.constraint, strategy = "max", - height = vars.char_height, + height = qvars.char_height, { { widget = wibox.container.background, - fg = vars.colors.dim.fg, + fg = qvars.colors.dim.fg, { widget = wibox.widget.textbox, text = entry.provider .. " | " @@ -91,7 +88,7 @@ function fresnel:_update(query, scrolled) widget = wibox.widget.textbox, text = entry.message }, - spacing = vars.padding, + spacing = qvars.padding, layout = wibox.layout.fixed.horizontal } } @@ -110,17 +107,17 @@ function fresnel:_update(query, scrolled) if self._selected_index + self._entries_offset == i then entry_widget._selected = true - entry_widget.bg = vars.colors.black + entry_widget.bg = qvars.colors.black end entry_widget:connect_signal("mouse::enter", function() if entry_widget._selected == true then return end - entry_widget.bg = vars.colors.black + entry_widget.bg = qvars.colors.black end) entry_widget:connect_signal("mouse::leave", function() if entry_widget._selected == true then return end - entry_widget.bg = vars.colors.bg + entry_widget.bg = qvars.colors.bg end) layout:add(entry_widget) @@ -138,7 +135,7 @@ fresnel._prompt = al_prompt { prompt = "", reset_on_stop = true, ul_cursor = "low", - bg_cursor = vars.colors.black, + bg_cursor = qvars.colors.black, changed_callback = function(text) if fresnel._text == text then return end if fresnel._toggled == false then return end @@ -177,7 +174,7 @@ fresnel._prompt = al_prompt { end } -fresnel._widget = h.popup { +fresnel._widget = qui.popup { visible = false, ontop = true, placement = function(d) @@ -192,12 +189,12 @@ fresnel._widget = h.popup { widget = { { widget = wibox.container.background, - bg = vars.colors.black, - fg = vars.colors.dim.fg, - shape = vars.shape, + bg = qvars.colors.black, + fg = qvars.colors.dim.fg, + shape = qvars.shape, { widget = wibox.container.margin, - margins = vars.padding, + margins = qvars.padding, { { widget = wibox.widget.textbox, @@ -206,16 +203,16 @@ fresnel._widget = h.popup { { widget = wibox.container.margin, margins = { - left = vars.padding, - right = vars.padding + left = qvars.padding, + right = qvars.padding }, { widget = wibox.container.constraint, strategy = "max", - height = vars.char_height, + height = qvars.char_height, { widget = wibox.container.background, - fg = vars.colors.fg, + fg = qvars.colors.fg, fresnel._prompt.textbox } } @@ -232,10 +229,10 @@ fresnel._widget = h.popup { { widget = wibox.container.margin, margins = { - top = vars.padding + top = qvars.padding }, { - spacing = vars.padding, + spacing = qvars.padding, layout = wibox.layout.fixed.vertical, id = "entry_layout" } @@ -243,7 +240,7 @@ fresnel._widget = h.popup { 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 +fresnel._widget.maximum_height = qvars.big_padding * 2 + (qvars.padding * 2 + qvars.char_height) * (1 + 10) + qvars.padding + qvars.padding * 9 function fresnel:show() self._toggled = true @@ -259,8 +256,8 @@ function fresnel:hide() end fresnel._timed = rubato.timed { - duration = vars.anim_duration, - intro = vars.anim_intro, + duration = qvars.anim_duration, + intro = qvars.anim_intro, pos = 0, subscribed = function(pos) fresnel._widget.opacity = pos diff --git a/.config/awesome/ui/fresnel/lenses/liblenses.so b/.config/awesome/ui/fresnel/lenses/liblenses.so deleted file mode 120000 index 5f7fc45..0000000 --- a/.config/awesome/ui/fresnel/lenses/liblenses.so +++ /dev/null @@ -1 +0,0 @@ -target/liblenses.so \ No newline at end of file diff --git a/.config/awesome/ui/fresnel/lenses/src/calculator.rs b/.config/awesome/ui/fresnel/lenses/src/calculator.rs deleted file mode 100644 index 792985d..0000000 --- a/.config/awesome/ui/fresnel/lenses/src/calculator.rs +++ /dev/null @@ -1,25 +0,0 @@ -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/lib.rs b/.config/awesome/ui/fresnel/lenses/src/lib.rs deleted file mode 100644 index e4fc881..0000000 --- a/.config/awesome/ui/fresnel/lenses/src/lib.rs +++ /dev/null @@ -1,16 +0,0 @@ -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/ui/info_center/init.lua b/.config/awesome/ui/info_center/init.lua deleted file mode 100644 index e7f59cc..0000000 --- a/.config/awesome/ui/info_center/init.lua +++ /dev/null @@ -1,8 +0,0 @@ -local awful = require "awful" -local vars = require "misc.vars" -local wibox = require "wibox" -local obj = require "gears.object" -local debug = require "gears.debug" -local naughty = require "naughty" -local xresources = require "beautiful.xresources" -local dpi = xresources.apply_dpi diff --git a/.config/awesome/ui/init.lua b/.config/awesome/ui/init.lua index 4e6d98e..9ab3019 100644 --- a/.config/awesome/ui/init.lua +++ b/.config/awesome/ui/init.lua @@ -1,4 +1,5 @@ -- require "ui.window_switcher" +-- require "ui.conductor" 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 index 4ed6099..1e61046 100644 --- a/.config/awesome/ui/insightful/init.lua +++ b/.config/awesome/ui/insightful/init.lua @@ -1,9 +1,11 @@ local awful = require "awful" local gtable = require "gears.table" -local h = require "misc.helpers" -local vars = require "misc.vars" +local qui = require "quarrel.ui" +local qtable = require "quarrel.table" +local qvars = require "quarrel.vars" local wibox = require "wibox" local rubato = require "lib.rubato" +local beautiful = require "beautiful" local btn = awful.button.names local first_time = true @@ -14,44 +16,45 @@ local insightful = {} insightful._toggled = false insightful._bindings = {} insightful._selected_group = "" +insightful._selected_group_index = 1 insightful._keymap = { - Control = "Control", - Mod1 = "Alt", + 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 = "🔆+", + 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 = "ﱜ", @@ -65,15 +68,21 @@ insightful._keymap = { [tostring(btn.RIGHT)] = mouse .. "Right" } -insightful._widget = h.popup { +insightful._widget = qui.popup { visible = false, ontop = true, - placement = awful.placement.centered, + placement = function(d) + awful.placement.top(d, { + margins = { + top = beautiful.useless_gap * 2 + } + }) + end, minimum_height = screen[1].geometry.height / 2, minimum_width = screen[1].geometry.width / 2, widget = { layout = wibox.layout.fixed.vertical, - spacing = vars.big_padding, + spacing = qvars.big_padding, id = "layout_container" } } @@ -97,9 +106,9 @@ function insightful:_generate() }) end - for group, keybinds in h.opairs(grouped_binds) do + for group, keybinds in qtable.opairs(grouped_binds) do local group_layout = { - spacing = vars.padding, + spacing = qvars.padding, layout = wibox.layout.fixed.vertical } @@ -116,13 +125,13 @@ function insightful:_generate() } for _, mod in ipairs(keybind.mods) do - table.insert(key_layout, 1, h.styled { + table.insert(key_layout, 1, qui.styled { widget = wibox.container.background, - bg = vars.colors.bright.black, + bg = qvars.colors.bright.black, border_width = 0, { widget = wibox.container.margin, - margins = vars.padding, + margins = qvars.padding, { widget = wibox.widget.textbox, text = insightful._keymap[mod] or mod @@ -154,7 +163,7 @@ function insightful:_generate() if keybind.desc then key_and_desc_layout[3] = { widget = wibox.container.background, - fg = vars.colors.dim.fg, + fg = qvars.colors.dim.fg, { widget = wibox.widget.textbox, text = keybind.desc @@ -171,12 +180,12 @@ function insightful:_generate() { { widget = wibox.container.background, - bg = vars.colors.yellow, - fg = vars.colors.bg, - shape = vars.shape, + bg = qvars.colors.yellow, + fg = qvars.colors.bg, + shape = qvars.shape, { widget = wibox.container.margin, - margins = vars.padding, + margins = qvars.padding, { widget = wibox.widget.textbox, text = group @@ -187,15 +196,15 @@ function insightful:_generate() layout = wibox.layout.align.horizontal }, group_layout, - spacing = vars.padding, + spacing = qvars.padding, layout = wibox.layout.fixed.vertical } end end local timed = rubato.timed { - duration = vars.anim_duration, - intro = vars.anim_intro, + duration = qvars.anim_duration, + intro = qvars.anim_intro, pos = 0, subscribed = function(pos) insightful._widget.opacity = pos @@ -210,7 +219,7 @@ local timed = rubato.timed { function insightful:toggle() if first_time then - insightful:_generate_widget() + insightful:_generate() first_time = false end @@ -218,56 +227,4 @@ function insightful:toggle() 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 index dfe2868..01d6498 100644 --- a/.config/awesome/ui/statusbar/init.lua +++ b/.config/awesome/ui/statusbar/init.lua @@ -1,10 +1,14 @@ local awful = require "awful" local beautiful = require "beautiful" -local xresources = require "beautiful.xresources" -local dpi = xresources.apply_dpi -local vars = require "misc.vars" +local qvars = require "quarrel.vars" local wibox = require "wibox" -local h = require "misc.helpers" +local qui = require "quarrel.ui" +local gcolor = require "gears.color" +local gdebug = require "gears.debug" +local phosphor = require "assets.phosphor" +local qbind = require "quarrel.bind" +local q = require "quarrel" +local rubato = require "lib.rubato" local taglist = require "ui.statusbar.widgets.taglist" local clock = require "ui.statusbar.widgets.clock" @@ -14,62 +18,148 @@ 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 { + local expand_button = wibox.widget { + widget = wibox.container.place, + valign = "center", + halign = "center", + { + widget = wibox.widget.imagebox, + image = gcolor.recolor_image(phosphor.caret_right_fill, qvars.colors.fg), + forced_width = qvars.icon_size, + forced_height = qvars.icon_size + }, + _expanded = false + } + + local bar = qui.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), + minimum_height = s.geometry.height - (beautiful.useless_gap * 4 + qvars.border_width * 2), widget = { { + nil, { - widget = wibox.container.place, - valign = "top", - { - widget = wibox.widget.textbox, - text = "", - font = h.font(1.5) - } - }, - taglist, - { - widget = wibox.container.place, - valign = "bottom", { + expand_button, + taglist, layout = wibox.layout.fixed.vertical, - spacing = vars.padding * 2, - brightness, - battery, - wifi, - keyboardlayout, - clock + spacing = qvars.padding * 2, }, + nil, + { + widget = wibox.container.place, + valign = "bottom", + { + brightness, + battery, + wifi, + { + widget = wibox.container.place, + keyboardlayout + }, + clock, + layout = wibox.layout.fixed.vertical, + spacing = qvars.padding * 2 + }, + }, + layout = wibox.layout.align.vertical, + expand = "outside", }, - layout = wibox.layout.align.vertical, - expand = "outside", + nil, + layout = wibox.layout.align.horizontal }, - -- { - -- 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 + nil, + nil, + layout = wibox.layout.align.horizontal, } } + local bar_width = bar.width + bar:struts { - left = dpi(16) + vars.big_padding * 2 + beautiful.useless_gap * 4 + -- left = qvars.bar_size + qvars.big_padding * 2 + beautiful.useless_gap * 4 + -- left = qvars.bar_size + qvars.border_width * 2 + beautiful.useless_gap * 4 + left = bar_width + qvars.border_width * 2 + beautiful.useless_gap * 4 + } + + local timed = rubato.timed { + duration = qvars.anim_duration, + intro = qvars.anim_intro, + pos = bar_width, + subscribed = function(pos) + if pos ~= bar_width and expand_button._expanded then + bar.widget.widget.third = wibox.widget { + { + widget = wibox.container.margin, + margins = { + left = qvars.big_padding + } + }, + { + widget = wibox.container.constraint, + width = qvars.bar_size * 6, + strategy = "min", + { + { + { + widget = wibox.container.background, + bg = qvars.colors.black, + { + widget = wibox.widget.textbox, + text = "1" + } + }, + { + widget = wibox.container.background, + bg = qvars.colors.black, + { + widget = wibox.widget.textbox, + text = "2" + } + }, + { + widget = wibox.container.background, + bg = qvars.colors.black, + { + widget = wibox.widget.textbox, + text = "3" + } + }, + spacing = qvars.padding, + layout = wibox.layout.flex.horizontal + }, + layout = wibox.layout.fixed.vertical + } + }, + layout = wibox.layout.fixed.horizontal + } + bar.ontop = true + elseif pos == bar_width and not expand_button._expanded then + bar.widget.widget.third = nil + bar.ontop = false + end + + bar.maximum_width = pos + end + } + + expand_button.buttons = { + qbind:new { + triggers = qvars.btns.left, + press = function() + if expand_button._expanded then + timed.target = bar_width + else + timed.target = bar_width + qvars.bar_size * 6 + end + + expand_button._expanded = not expand_button._expanded + end, + hidden = true + } } end) diff --git a/.config/awesome/ui/statusbar/widgets/app_launcher.lua b/.config/awesome/ui/statusbar/widgets/app_launcher.lua deleted file mode 100644 index 2e1e10a..0000000 --- a/.config/awesome/ui/statusbar/widgets/app_launcher.lua +++ /dev/null @@ -1,6 +0,0 @@ -local awful = require "awful" -local wibox = require "wibox" -local vars = require "misc.vars" -local h = require "misc.helpers" - - diff --git a/.config/awesome/ui/statusbar/widgets/battery.lua b/.config/awesome/ui/statusbar/widgets/battery.lua index b041c3a..dab98ca 100644 --- a/.config/awesome/ui/statusbar/widgets/battery.lua +++ b/.config/awesome/ui/statusbar/widgets/battery.lua @@ -1,67 +1,37 @@ -local awful = require "awful" -local xresources = require "beautiful.xresources" -local vars = require "misc.vars" +local qvars = require "quarrel.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 = "" - local color = vars.colors.red - - if io.popen("cat /sys/class/power_supply/BAT0/status"):read("*a"):sub(0, -2) == "Charging" then - icon = "" - color = vars.colors.green - widget:set_markup("" .. icon .. "") - return - end - - local percent = tonumber(stdout) - - if percent <= 5 then - icon = "" - color = vars.colors.red - elseif percent <= 10 then - icon = "" - color = vars.colors.red - elseif percent <= 20 then - icon = "" - color = vars.colors.red - elseif percent <= 30 then - icon = "" - color = vars.colors.yellow - elseif percent <= 40 then - icon = "" - color = vars.colors.yellow - elseif percent <= 50 then - icon = "" - color = vars.colors.yellow - elseif percent <= 60 then - icon = "" - color = vars.colors.yellow - elseif percent <= 70 then - icon = "" - color = vars.colors.yellow - elseif percent <= 80 then - icon = "" - color = vars.colors.green - elseif percent <= 90 then - icon = "" - color = vars.colors.green - elseif percent <= 100 then - icon = "" - color = vars.colors.green - end - - widget:set_markup("" .. icon .. "") -end) +local qmath = require "quarrel.math" +local gcolor = require "gears.color" +local phosphor = require "assets.phosphor" local battery = wibox.widget { widget = wibox.container.place, - battery_inner + valign = "center", + halign = "center", + { + widget = wibox.widget.imagebox, + image = gcolor.recolor_image(phosphor.battery_warning_vertical_fill, qvars.colors.red), + forced_width = qvars.icon_size, + forced_height = qvars.icon_size + } } -h.tooltip({ battery }, function() - return io.popen("cat /sys/class/power_supply/BAT0/capacity"):read("*a"):sub(0, -2) .. "%" +awesome.connect_signal("services::battery", function(capacity, status) + if status == "Charging" then + battery.widget.image = gcolor.recolor_image(phosphor.battery_charging_vertical_fill, qvars.colors.green) + return + end + + local icon_data = qmath.step_value(capacity, { + { 0, { "empty", "red" } }, + { 20, { "low", "red" } }, + { 40, { "medium", "yellow" } }, + { 60, { "high", "green" } }, + { 80, { "full", "green" } }, + { 100 } + }) + + battery.widget.image = gcolor.recolor_image(phosphor["battery_vertical_" .. icon_data[1] .. "_fill"], qvars.colors[icon_data[2]]) end) return battery diff --git a/.config/awesome/ui/statusbar/widgets/brightness.lua b/.config/awesome/ui/statusbar/widgets/brightness.lua index cceba89..f8f6c17 100644 --- a/.config/awesome/ui/statusbar/widgets/brightness.lua +++ b/.config/awesome/ui/statusbar/widgets/brightness.lua @@ -1,18 +1,32 @@ -local vars = require "misc.vars" +local qvars = require "quarrel.vars" local wibox = require "wibox" -local h = require "misc.helpers" +local qmath = require "quarrel.math" +local gcolor = require "gears.color" +local phosphor = require "assets.phosphor" local brightness = wibox.widget { widget = wibox.container.place, + valign = "center", + halign = "center", { - widget = wibox.widget.textbox, - font = vars.font, - text = "" - }, + widget = wibox.widget.imagebox, + image = gcolor.recolor_image(phosphor.moon_fill, qvars.colors.fg), + forced_width = qvars.icon_size, + forced_height = qvars.icon_size + } } -h.tooltip({ brightness }, function() - return math.floor(tonumber(io.popen("brightnessctl g"):read("*a"):sub(0, -2)) / 255 * 100) .. "%" +awesome.connect_signal("services::brightness", function(value) + local icon_data = qmath.step_value(value, { + { 0, "cloud_moon" }, + { 51, "moon" }, + { 102, "sun_horizon" }, + { 153, "sun_dim" }, + { 204, "sun" }, + { 255 } + }) + + brightness.widget.image = gcolor.recolor_image(phosphor[icon_data .. "_fill"], qvars.colors.fg) end) return brightness diff --git a/.config/awesome/ui/statusbar/widgets/clock.lua b/.config/awesome/ui/statusbar/widgets/clock.lua index c7b3c29..77ce8ce 100644 --- a/.config/awesome/ui/statusbar/widgets/clock.lua +++ b/.config/awesome/ui/statusbar/widgets/clock.lua @@ -1,17 +1,17 @@ -local vars = require "misc.vars" +local qvars = require "quarrel.vars" local wibox = require "wibox" -local h = require "misc.helpers" +local qui = require "quarrel.ui" local clock = wibox.widget { widget = wibox.container.place, { format = "%H\n%M", widget = wibox.widget.textclock, - font = vars.font + font = qvars.font }, } -h.tooltip({ clock }, function() +qui.tooltip({ clock }, function() return os.date("%a %d/%m/%y") end) diff --git a/.config/awesome/ui/statusbar/widgets/taglist.lua b/.config/awesome/ui/statusbar/widgets/taglist.lua index 751cbf0..89eaf2f 100644 --- a/.config/awesome/ui/statusbar/widgets/taglist.lua +++ b/.config/awesome/ui/statusbar/widgets/taglist.lua @@ -1,89 +1,82 @@ local awful = require "awful" -local vars = require "misc.vars" +local qvars = require "quarrel.vars" local wibox = require "wibox" -local timed = require "lib.rubato".timed +local gcolor = require "gears.color" +local phosphor = require "assets.phosphor" +local qbind = require "quarrel.bind" -return awful.widget.taglist({ +return awful.widget.taglist { screen = screen[1], filter = awful.widget.taglist.filter.all, - style = { - shape = vars.shape - }, layout = { - spacing = vars.padding, + spacing = qvars.padding, layout = wibox.layout.fixed.vertical }, widget_template = { - { - 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, + valign = "center", + halign = "center", + { + widget = wibox.widget.imagebox, + image = gcolor.recolor_image(phosphor.circle_bold, qvars.colors.fg), + forced_width = qvars.icon_size, + forced_height = qvars.icon_size, + icon = phosphor.dot_fill + }, create_callback = function(self, tag) - local indicator = self:get_children_by_id("indicator_role")[1] - - 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.widget.icon = phosphor[next(tag:clients()) and "circle_fill" or "circle_bold"] self:connect_signal("mouse::enter", function() if tag.selected then return end - indicator.bg = vars.colors.yellow + self.widget.image = gcolor.recolor_image(self.widget.icon, qvars.colors.yellow) end) 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 + self.widget.image = gcolor.recolor_image(self.widget.icon, qvars.colors.fg) 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 + self.widget.image = gcolor.recolor_image(self.widget.icon, qvars.colors.yellow) + return + end + + self.widget.image = gcolor.recolor_image(self.widget.icon, qvars.colors.fg) + end, + update_callback = function(self, tag) + -- self.widget.icon = phosphor[next(tag:clients()) and "circle_fill" or "circle_bold"] + + if tag.selected then + self.widget.image = gcolor.recolor_image(self.widget.icon, qvars.colors.yellow) else - indicator.bg = vars.colors.bright.black - self._anim.target = vars.button_size + self.widget.image = gcolor.recolor_image(self.widget.icon, qvars.colors.fg) end end }, buttons = { - awful.button({ }, 1, function(t) t:view_only() end), - awful.button(vars.mods.M, 1, function(t) - if client.focus then - client.focus:move_to_tag(t) - end - end), - awful.button({ }, 3, awful.tag.viewtoggle), + qbind:new { + triggers = qvars.btns.left, + press = function(t) + t:view_only() + end, + hidden = true + }, + qbind:new { + mods = qvars.mods.M, + triggers = qvars.btns.left, + press = function(t) + if client.focus then + client.focus:move_to_tag(t) + end + end, + hidden = true + }, + qbind:new { + triggers = qvars.btns.right, + press = awful.tag.viewtoggle, + hidden = true + }, } -}) +} diff --git a/.config/awesome/ui/statusbar/widgets/power_menu.lua b/.config/awesome/ui/statusbar/widgets/volume.lua similarity index 100% rename from .config/awesome/ui/statusbar/widgets/power_menu.lua rename to .config/awesome/ui/statusbar/widgets/volume.lua diff --git a/.config/awesome/ui/statusbar/widgets/wifi.lua b/.config/awesome/ui/statusbar/widgets/wifi.lua index d0b7116..5f131b3 100644 --- a/.config/awesome/ui/statusbar/widgets/wifi.lua +++ b/.config/awesome/ui/statusbar/widgets/wifi.lua @@ -1,48 +1,36 @@ -local awful = require "awful" -local vars = require "misc.vars" +local qvars = require "quarrel.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" - local icon = "" - local color = vars.colors.red - - if stdout == "" then - widget:set_markup("" .. icon .. "") - return - end - - local percent = tonumber(stdout) - - if percent <= 20 then - icon = "" - color = vars.colors.red - elseif percent <= 40 then - icon = "" - color = vars.colors.yellow - elseif percent <= 60 then - icon = "" - color = vars.colors.yellow - elseif percent <= 80 then - icon = "" - color = vars.colors.green - elseif percent <= 100 then - icon = "" - color = vars.colors.green - end - - - widget:set_markup("" .. icon .. "") -end) +local qmath = require "quarrel.math" +local gcolor = require "gears.color" +local phosphor = require "assets.phosphor" local wifi = wibox.widget { widget = wibox.container.place, - wifi_inner + valign = "center", + halign = "center", + { + widget = wibox.widget.imagebox, + image = gcolor.recolor_image(phosphor.wifi_x_fill, qvars.colors.red), + forced_width = qvars.icon_size, + forced_height = qvars.icon_size + } } -h.tooltip({ wifi }, function() - return io.popen("iwgetid -r"):read("*a"):sub(0, -2) +awesome.connect_signal("services::wifi", function(strength, connected) + if not connected then + wifi.widget.image = gcolor.recolor_image(phosphor.wifi_x_fill, qvars.colors.red) + return + end + + local icon_data = qmath.step_value(strength, { + { 0, { "none", "red" } }, + { 25, { "low", "yellow" } }, + { 50, { "medium", "yellow" } }, + { 75, { "high", "green" } }, + { 100 } + }) + + wifi.widget.image = gcolor.recolor_image(phosphor["wifi_" .. icon_data[1] .. "_fill"], qvars.colors[icon_data[2]]) end) return wifi diff --git a/.config/awesome/ui/wicked/init.lua b/.config/awesome/ui/wicked/init.lua index 5687b81..5bd36be 100644 --- a/.config/awesome/ui/wicked/init.lua +++ b/.config/awesome/ui/wicked/init.lua @@ -1,16 +1,12 @@ local awful = require "awful" -local vars = require "misc.vars" +local qvars = require "quarrel.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 qui = require "quarrel.ui" local wicked = {} @@ -18,7 +14,7 @@ wicked._active_notififcations = {} function wicked:notify(n) -- local notif = wibox.widget { - local notif = h.popup { + local notif = qui.popup { -- widget = { -- { -- { @@ -26,7 +22,7 @@ function wicked:notify(n) -- notification = n, -- forced_height = 0, -- forced_width = 0, - -- clip_shape = vars.shape, + -- clip_shape = qvars.shape, -- id = "icon_role" -- }, -- { @@ -41,10 +37,10 @@ function wicked:notify(n) -- layout = wibox.layout.fixed.vertical -- }, -- layout = wibox.layout.fixed.horizontal, - -- spacing = vars.padding + -- spacing = qvars.padding -- }, -- widget = wibox.container.margin, - -- margins = vars.padding + -- margins = qvars.padding -- }, widget = { -- { @@ -82,7 +78,7 @@ function wicked:notify(n) } gtimer { - timeout = vars.notif_timeout, + timeout = qvars.notif_timeout, autostart = true, callback = function() notif.visible = false diff --git a/.config/awesome/ui/window_switcher/init.lua b/.config/awesome/ui/window_switcher/init.lua deleted file mode 100644 index f14c865..0000000 --- a/.config/awesome/ui/window_switcher/init.lua +++ /dev/null @@ -1,172 +0,0 @@ -local awful = require "awful" -local vars = require "misc.vars" -local wibox = require "wibox" -local obj = require "gears.object" -local debug = require "gears.debug" -local naughty = require "naughty" -local xresources = require "beautiful.xresources" -local dpi = xresources.apply_dpi - - -local ws = obj { - enable_properties = true, - enable_auto_signals = true -} - -ws.selected = 1 -ws.max = 0 - -local widget = awful.popup { - widget = { - { - widget = awful.widget.tasklist { - screen = screen[1], - filter = awful.widget.tasklist.filter.allscreen, - style = { - shape = vars.shape, - }, - layout = { - forced_num_rows = 1, - layout = wibox.layout.grid.vertical, - spacing = vars.padding - }, - widget_template = { - { - layout = wibox.layout.align.horizontal, - { - widget = wibox.container.place, - { - widget = wibox.container.margin, - margins = dpi(6), - { - id = "text_role", - widget = wibox.widget.textbox, - } - } - }, - nil, - { - widget = wibox.container.place, - { - widget = wibox.container.margin, - margins = dpi(6), - { - id = "tag_role", - widget = wibox.widget.textbox, - } - } - } - }, - forced_width = dpi(screen[1].geometry.width / 8), - bg = vars.colors.black, - border_width = vars.border_width, - border_color = vars.colors.black, - shape = vars.shape, - widget = wibox.container.background, - create_callback = function(self, client, i) - -- self:get_children_by_id("name_role")[1].text = client.name - self:get_children_by_id("tag_role")[1].text = client.first_tag.name - - ws:connect_signal("property::selected", function(selected) - naughty.notification { - urgency = "critical", - message = tostring(selected) .. " | " .. tostring(i) - } - - if selected == i then - self.border_color = vars.colors.yellow - else - self.border_color = vars.colors.black - end - end) - end - -- update_callback = function(self, _, i) - -- if ws.selected == i then - -- self.border_color = vars.colors.yellow - -- else - -- self.border_color = vars.colors.black - -- end - -- end - } - }, - id = "tasklist" - }, - widget = wibox.container.margin, - margins = vars.padding - }, - border_color = vars.colors.bright.black, - border_width = vars.border_width, - ontop = true, - placement = awful.placement.centered, - bg = vars.colors.bg, - shape = vars.shape, - visible = false -} - -ws.widget = widget - -ws.max = ws.widget.widget.tasklist.count - - - --- ws.widget:connect_signal("property::count", function(self) --- naughty.notification { --- urgency = "critical", --- message = tostring(ws.max) --- } --- ws.max = self.count --- end) - -awful.keygrabber { - keybindings = { - awful.key { - modifiers = { "Mod1" }, - key = "Tab", - on_press = function() - -- naughty.notification { - -- urgency = "critical", - -- message = tostring(WS.widget) - -- } - naughty.notification { - urgency = "critical", - message = tostring(ws.selected) - } - -- local file = io.open("/home/delta/.cache/awesome/tasklist_dump.txt", "w+") - -- file:write(debug.dump_return(WS.widget, "tasklist")) - -- file:close() - -- ws.widget:emit_signal_recursive("widget::layout_changed") - -- WS.widget:emit_signal("widget::redraw_needed") - if ws.selected + 1 > ws.max then - ws.selected = 1 - return - end - ws.selected = ws.selected + 1 - end - }, - awful.key { - modifiers = { "Mod1", "Shift" }, - key = "Tab", - on_press = function() - ws.widget:emit_signal("widget::layout_changed") - if ws.selected - 1 == 0 then - ws.selected = ws.max - return - end - ws.selected = ws.selected - 1 - end - }, - }, - stop_key = "Mod1", - stop_event = "release", - start_callback = function() - ws.widget.visible = true - naughty.notification { - urgency = "critical", - message = tostring(ws.max) -} - end, - stop_callback = function() - ws.widget.visible = false - end, - autostart = false -} diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 2051e42..2fddce3 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -1,3 +1,7 @@ +if not status is-interactive + exit +end + # fish set -gx FISH_CFG $XDG_CONFIG_HOME/fish set -g fish_greeting @@ -18,6 +22,7 @@ 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 +set -gx RANGER_LOAD_DEFAULT_RC "FALSE" # $PATH source $FISH_CFG/path.fish @@ -37,6 +42,7 @@ abbr -a projects cd ~/DesktopTemp/RealProjects abbr -a gc git commit -m abbr -a ga git add abbr -a gcl git clone +alias imgcat="wezterm imgcat" alias dots="git --git-dir=$HOME/.dots --work-tree=$HOME" alias sudo="doas" alias ls="ls --color=auto"