From 98676ca1d7ab9a9abb4c01d0cdf67b83f7cdce49 Mon Sep 17 00:00:00 2001 From: delta Date: Wed, 12 Apr 2023 00:21:03 +0200 Subject: [PATCH] idk what i'm doing --- .config/awesome/.gitignore | 1 + .config/awesome/misc/autostart.lua | 2 +- .config/awesome/misc/keys.lua | 31 +++-- .config/awesome/quarrel/native/Cargo.toml | 3 +- .config/awesome/quarrel/native/rustfmt.toml | 1 + .../quarrel/native/src/lenses/application.rs | 34 +++--- .config/awesome/quarrel/native/src/lib.rs | 1 + .config/awesome/quarrel/native/src/sound.rs | 17 +++ .config/awesome/quarrel/vars.lua | 4 +- .config/awesome/signals/init.lua | 2 +- .config/awesome/ui/decorations/wallpaper.lua | 10 ++ .config/awesome/ui/statusbar/init.lua | 108 +++++------------- .config/awesome/ui/statusbar/panel/init.lua | 65 +++++++++++ .../statusbar/panel/widgets/battery_bar.lua | 60 ++++++++++ .../panel/widgets/brightness_bar.lua | 46 ++++++++ .../ui/statusbar/panel/widgets/calendar.lua | 0 .../awesome/ui/statusbar/widgets/clock.lua | 7 +- 17 files changed, 272 insertions(+), 120 deletions(-) create mode 100644 .config/awesome/quarrel/native/src/sound.rs create mode 100644 .config/awesome/ui/statusbar/panel/init.lua create mode 100644 .config/awesome/ui/statusbar/panel/widgets/battery_bar.lua create mode 100644 .config/awesome/ui/statusbar/panel/widgets/brightness_bar.lua create mode 100644 .config/awesome/ui/statusbar/panel/widgets/calendar.lua diff --git a/.config/awesome/.gitignore b/.config/awesome/.gitignore index 9bbbeea..5ea4265 100644 --- a/.config/awesome/.gitignore +++ b/.config/awesome/.gitignore @@ -1 +1,2 @@ .luarc.json +assets/nightmare_fuel.png diff --git a/.config/awesome/misc/autostart.lua b/.config/awesome/misc/autostart.lua index 8cf50b6..1747db6 100644 --- a/.config/awesome/misc/autostart.lua +++ b/.config/awesome/misc/autostart.lua @@ -11,7 +11,7 @@ local programs = { "wezterm start --class code_term", "firefox", "discord", - "spotify" + "env LD_PRELOAD=/usr/lib/spotify-adblock.so spotify" } for _, program in ipairs(programs) do diff --git a/.config/awesome/misc/keys.lua b/.config/awesome/misc/keys.lua index 94091af..3040657 100644 --- a/.config/awesome/misc/keys.lua +++ b/.config/awesome/misc/keys.lua @@ -16,7 +16,7 @@ client.connect_signal("request::default_mousebindings", function() qbind:new { triggers = qvars.btns.left, press = function (c) - c:activate { + c:activate { context = "mouse_click" } end, @@ -27,7 +27,7 @@ client.connect_signal("request::default_mousebindings", function() mods = qvars.mods.M, triggers = qvars.btns.left, press = function (c) - c:activate { + c:activate { context = "mouse_click", action = "mouse_move" } @@ -39,7 +39,7 @@ client.connect_signal("request::default_mousebindings", function() mods = qvars.mods.M, triggers = qvars.btns.right, press = function (c) - c:activate { + c:activate { context = "mouse_click", action = "mouse_resize" } @@ -53,8 +53,8 @@ end) client.connect_signal("request::default_keybindings", function() awful.keyboard.append_client_keybindings { qbind:new { - mods = qvars.mods.MC, - triggers = "q", + mods = qvars.mods.MC, + triggers = "q", press = function(c) c:kill() end, @@ -83,7 +83,7 @@ client.connect_signal("request::default_keybindings", function() }, qbind:new { mods = qvars.mods.M, - triggers = "f", + triggers = "f", press = function(c) c.fullscreen = not c.fullscreen end, @@ -95,8 +95,8 @@ end) awful.keyboard.append_global_keybindings { qbind:new { - mods = qvars.mods.MC, - triggers = "r", + mods = qvars.mods.MC, + triggers = "r", press = awesome.restart, group = "awesome", desc = "restart awesome" @@ -132,6 +132,15 @@ awful.keyboard.append_global_keybindings { group = "awesome", desc = "toggle fresnel" }, + qbind:new { + mods = qvars.mods.MC, + triggers = "d", + press = function() + archaic:toggle() + end, + group = "awesome", + desc = "toggle archaic" + }, qbind:new { mods = {}, @@ -202,9 +211,9 @@ awful.keyboard.append_global_keybindings { }, qbind:new { - mods = qvars.mods.M, - triggers = "Return", - press = function() + mods = qvars.mods.M, + triggers = "Return", + press = function() awful.spawn(cfg.terminal) end, group = "launcher", diff --git a/.config/awesome/quarrel/native/Cargo.toml b/.config/awesome/quarrel/native/Cargo.toml index 3806f3c..fdabea0 100644 --- a/.config/awesome/quarrel/native/Cargo.toml +++ b/.config/awesome/quarrel/native/Cargo.toml @@ -7,14 +7,13 @@ edition = "2021" [dependencies] freedesktop_entry_parser = "1.3.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" ] } url = "2.3.1" +rodio = "0.17.1" [lib] crate-type = ["cdylib"] diff --git a/.config/awesome/quarrel/native/rustfmt.toml b/.config/awesome/quarrel/native/rustfmt.toml index 36afbbd..3c7f9b0 100644 --- a/.config/awesome/quarrel/native/rustfmt.toml +++ b/.config/awesome/quarrel/native/rustfmt.toml @@ -1,3 +1,4 @@ imports_layout = "Vertical" unstable_features = true group_imports = "StdExternalCrate" +imports_granularity = "Crate" diff --git a/.config/awesome/quarrel/native/src/lenses/application.rs b/.config/awesome/quarrel/native/src/lenses/application.rs index 4317c75..b0135d4 100644 --- a/.config/awesome/quarrel/native/src/lenses/application.rs +++ b/.config/awesome/quarrel/native/src/lenses/application.rs @@ -5,7 +5,6 @@ use std::{ use freedesktop_entry_parser as fd; use mlua::prelude::*; -use parking_lot::Mutex; use rayon::prelude::*; use url::Url; @@ -14,6 +13,10 @@ use crate::lenses::entry::{ Entry, }; +fn contains_ignore_ascii_case(a: &str, b: &str) -> bool { + return false; +} + fn parse_entry(entry: &fd::Entry, path: &PathBuf) -> Result { let section = entry.section("Desktop Entry"); let name = section.attr("Name").ok_or(())?.to_string(); @@ -66,29 +69,22 @@ pub fn query(lua: &Lua, input: String) -> LuaResult { .map(|result| result.map(|e| e.path())) .collect::, std::io::Error>>()?; - let entries = entries - .into_iter() - .filter(|e| matches!(e.extension(), Some(ext) if ext == "desktop")) - .collect::>(); + let parsed_entries: Vec = entries + .into_par_iter() + .filter(|path| matches!(path.extension(), Some(ext) if ext == "desktop")) + .filter_map(|path| { + let Ok(entry) = fd::parse_entry(&path) else { + return None + }; - let mut parsed_entries: Mutex> = Mutex::new(Vec::new()); - - entries.into_par_iter().for_each(|path| { - let Ok(entry) = fd::parse_entry(&path) else { - return - }; - - if let Ok(parsed_entry) = parse_entry(&entry, &path) { - parsed_entries.lock().push(parsed_entry); - } - }); + return parse_entry(&entry, &path).ok(); + }) + .collect(); Ok(entries_to_lua_table( parsed_entries - .get_mut() - .iter() + .into_iter() .filter(|entry| entry.message.to_lowercase().contains(&input)) - .map(|entry| (*entry).clone()) .collect(), lua, )) diff --git a/.config/awesome/quarrel/native/src/lib.rs b/.config/awesome/quarrel/native/src/lib.rs index 3a016c4..d265d2d 100644 --- a/.config/awesome/quarrel/native/src/lib.rs +++ b/.config/awesome/quarrel/native/src/lib.rs @@ -1,4 +1,5 @@ mod lenses; +// mod sound; use mlua::prelude::*; diff --git a/.config/awesome/quarrel/native/src/sound.rs b/.config/awesome/quarrel/native/src/sound.rs new file mode 100644 index 0000000..c398d70 --- /dev/null +++ b/.config/awesome/quarrel/native/src/sound.rs @@ -0,0 +1,17 @@ +use std::{ + fs::File, + io::BufReader, + path::Path, + time::Duration, +}; + +use mlua::prelude::*; +use rodio::{ + Decoder, + OutputStream, + Sink, +}; + +pub fn play_sound(_: &Lua, file: String) -> LuaResult<()> { + +} diff --git a/.config/awesome/quarrel/vars.lua b/.config/awesome/quarrel/vars.lua index cbc7f00..76d0b94 100644 --- a/.config/awesome/quarrel/vars.lua +++ b/.config/awesome/quarrel/vars.lua @@ -66,7 +66,9 @@ qvars.colors = { dim = { fg = "#8893a5", bg = "#20262e" - } + }, + + transparent = "#00000000" } -- taken from https://github.com/bew/dotfiles/blob/ab9bb1935783f7a31ef777b1d7e26d53f35df864/gui/wezterm/cfg_utils.lua diff --git a/.config/awesome/signals/init.lua b/.config/awesome/signals/init.lua index 69c74b5..5641a96 100644 --- a/.config/awesome/signals/init.lua +++ b/.config/awesome/signals/init.lua @@ -1,5 +1,5 @@ -require "signals.awesome" require "signals.naughty" +require "signals.awesome" require "signals.screen" require "signals.client" diff --git a/.config/awesome/ui/decorations/wallpaper.lua b/.config/awesome/ui/decorations/wallpaper.lua index 3c85b83..fc2aa79 100644 --- a/.config/awesome/ui/decorations/wallpaper.lua +++ b/.config/awesome/ui/decorations/wallpaper.lua @@ -1,5 +1,6 @@ local wallpaper = require "awful.wallpaper" local wibox = require "wibox" +-- local gfs = require "gears.filesystem" local qvars = require "quarrel.vars" local qui = require "quarrel.ui" @@ -23,6 +24,15 @@ screen.connect_signal("request::wallpaper", function(s) qui.markup_fg(qvars.colors.cyan, " \\/__/") }, "\n") } + -- { + -- image = gfs.get_configuration_dir() .. "assets/nightmare_fuel.png", + -- resize = true, + -- widget = wibox.widget.imagebox, + -- }, + -- valign = "center", + -- halign = "center", + -- tiled = false, + -- widget = wibox.container.tile, } } end) diff --git a/.config/awesome/ui/statusbar/init.lua b/.config/awesome/ui/statusbar/init.lua index 01d6498..2851b73 100644 --- a/.config/awesome/ui/statusbar/init.lua +++ b/.config/awesome/ui/statusbar/init.lua @@ -4,11 +4,10 @@ local qvars = require "quarrel.vars" local wibox = require "wibox" 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 panel = require "ui.statusbar.panel" local taglist = require "ui.statusbar.widgets.taglist" local clock = require "ui.statusbar.widgets.clock" @@ -41,36 +40,31 @@ screen.connect_signal("request::desktop_decoration", function(s) minimum_height = s.geometry.height - (beautiful.useless_gap * 4 + qvars.border_width * 2), widget = { { - nil, { - { - expand_button, - taglist, - layout = wibox.layout.fixed.vertical, - 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", + expand_button, + taglist, + layout = wibox.layout.fixed.vertical, + spacing = qvars.padding * 2, }, nil, - layout = wibox.layout.align.horizontal + { + widget = wibox.container.place, + valign = "bottom", + { + { + widget = wibox.container.place, + keyboardlayout + }, + clock, + wifi, + brightness, + battery, + layout = wibox.layout.fixed.vertical, + spacing = qvars.padding * 2 + }, + }, + layout = wibox.layout.align.vertical, + expand = "outside", }, nil, nil, @@ -78,12 +72,10 @@ screen.connect_signal("request::desktop_decoration", function(s) } } - local bar_width = bar.width + local bar_width = bar.width + qvars.border_width * 2 bar:struts { - -- 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 + left = bar_width + beautiful.useless_gap * 4 } local timed = rubato.timed { @@ -92,58 +84,16 @@ screen.connect_signal("request::desktop_decoration", function(s) 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.widget.widget.third = panel 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 + bar.shape = function(cr, _, h) + qvars.shape(cr, pos, h) + end end } diff --git a/.config/awesome/ui/statusbar/panel/init.lua b/.config/awesome/ui/statusbar/panel/init.lua new file mode 100644 index 0000000..bbdbaee --- /dev/null +++ b/.config/awesome/ui/statusbar/panel/init.lua @@ -0,0 +1,65 @@ +local wibox = require "wibox" +local qvars = require "quarrel.vars" + +local battery_bar = require "ui.statusbar.panel.widgets.battery_bar" +local brightness_bar = require "ui.statusbar.panel.widgets.brightness_bar" + +local panel = wibox.widget { + { + widget = wibox.container.margin, + margins = { + left = qvars.big_padding * 2 + } + }, + { + widget = wibox.container.constraint, + width = qvars.bar_size * 6, + strategy = "exact", + { + widget = wibox.container.margin, + margins = { + right = qvars.big_padding * 4 + }, + { + { + widget = wibox.widget.calendar.month, + date = os.date("*t"), + font = qvars.font, + -- long_weekdays = true, + -- flex_height = true, + -- fn_embed = decorate_cell + }, + { + widget = wibox.container.background, + -- bg = qvars.colors.blue, + { + widget = wibox.widget.textbox, + text = ":)" + } + }, + { + widget = wibox.container.place, + valign = "bottom", + { + { + widget = wibox.widget.separator, + forced_height = qvars.char_height * 4 + qvars.padding * 4, + color = qvars.colors.transparent, + }, + brightness_bar, + battery_bar, + layout = wibox.layout.fixed.vertical, + spacing = qvars.padding * 2 + }, + }, + layout = wibox.layout.align.vertical, + } + } + }, + layout = wibox.layout.fixed.horizontal +} + +-- panel:get_children_by_id("ratio_layout"):adjust_ratio(2, 0.3, 0.7, 0) +-- gdebug.dump(panel:get_children_by_id("ratio_layout")) + +return panel diff --git a/.config/awesome/ui/statusbar/panel/widgets/battery_bar.lua b/.config/awesome/ui/statusbar/panel/widgets/battery_bar.lua new file mode 100644 index 0000000..b504330 --- /dev/null +++ b/.config/awesome/ui/statusbar/panel/widgets/battery_bar.lua @@ -0,0 +1,60 @@ +local wibox = require "wibox" +local qvars = require "quarrel.vars" +local qmath = require "quarrel.math" + +local battery_bar = wibox.widget { + widget = wibox.container.place, + forced_height = qvars.char_height, + { + { + widget = wibox.container.constraint, + width = qvars.char_width * 4, + strategy = "exact", + { + widget = wibox.widget.textbox, + text = "0%" + }, + id = "text" + }, + nil, + { + widget = wibox.container.margin, + margins = { + left = qvars.padding + }, + { + widget = wibox.container.place, + { + widget = wibox.widget.progressbar, + max_value = 100, + value = 0, + forced_height = qvars.char_height / 4, + shape = qvars.shape, + background_color = qvars.colors.black, + color = qvars.colors.red, + } + }, + id = "bar" + }, + layout = wibox.layout.align.horizontal, + -- expand = "outside" + } +} + +awesome.connect_signal("services::battery", function(capacity) + local color = qmath.step_value(capacity, { + { 0, "red" }, + { 20, "red" }, + { 40, "yellow" }, + { 60, "green" }, + { 80, "green" }, + { 100 } + }) + + battery_bar.widget.bar.widget.widget.color = qvars.colors[color] + battery_bar.widget.bar.widget.widget.value = capacity + + battery_bar.widget.text.widget.text = capacity .. "%" +end) + +return battery_bar diff --git a/.config/awesome/ui/statusbar/panel/widgets/brightness_bar.lua b/.config/awesome/ui/statusbar/panel/widgets/brightness_bar.lua new file mode 100644 index 0000000..2db03dc --- /dev/null +++ b/.config/awesome/ui/statusbar/panel/widgets/brightness_bar.lua @@ -0,0 +1,46 @@ +local wibox = require "wibox" +local qvars = require "quarrel.vars" +local qmath = require "quarrel.math" + +local brightness_bar = wibox.widget { + widget = wibox.container.place, + forced_height = qvars.char_height, + { + { + widget = wibox.widget.textbox, + text = "0%", + id = "text" + }, + nil, + { + widget = wibox.container.margin, + margins = { + left = qvars.padding + }, + { + widget = wibox.container.place, + { + widget = wibox.widget.progressbar, + max_value = 100, + value = 0, + forced_height = qvars.char_height / 4, + shape = qvars.shape, + background_color = qvars.colors.black, + color = qvars.colors.fg, + } + }, + id = "bar" + }, + layout = wibox.layout.align.horizontal, + } +} + +awesome.connect_signal("services::brightness", function(brightness) + brightness = math.floor(qmath.translate_range(brightness, 0, 255, 0, 100)) + + brightness_bar.widget.bar.widget.widget.value = brightness + + brightness_bar.widget.text.text = brightness .. "%" +end) + +return brightness_bar diff --git a/.config/awesome/ui/statusbar/panel/widgets/calendar.lua b/.config/awesome/ui/statusbar/panel/widgets/calendar.lua new file mode 100644 index 0000000..e69de29 diff --git a/.config/awesome/ui/statusbar/widgets/clock.lua b/.config/awesome/ui/statusbar/widgets/clock.lua index 77ce8ce..ff57a36 100644 --- a/.config/awesome/ui/statusbar/widgets/clock.lua +++ b/.config/awesome/ui/statusbar/widgets/clock.lua @@ -1,6 +1,5 @@ local qvars = require "quarrel.vars" local wibox = require "wibox" -local qui = require "quarrel.ui" local clock = wibox.widget { widget = wibox.container.place, @@ -8,11 +7,7 @@ local clock = wibox.widget { format = "%H\n%M", widget = wibox.widget.textclock, font = qvars.font - }, + } } -qui.tooltip({ clock }, function() - return os.date("%a %d/%m/%y") -end) - return clock