idk what i'm doing

This commit is contained in:
delta 2023-04-12 00:21:03 +02:00
parent f7116d268a
commit 98676ca1d7
17 changed files with 272 additions and 120 deletions

View file

@ -1 +1,2 @@
.luarc.json
assets/nightmare_fuel.png

View file

@ -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

View file

@ -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",

View file

@ -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"]

View file

@ -1,3 +1,4 @@
imports_layout = "Vertical"
unstable_features = true
group_imports = "StdExternalCrate"
imports_granularity = "Crate"

View file

@ -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<Entry, ()> {
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<LuaTable> {
.map(|result| result.map(|e| e.path()))
.collect::<Result<Vec<_>, std::io::Error>>()?;
let entries = entries
.into_iter()
.filter(|e| matches!(e.extension(), Some(ext) if ext == "desktop"))
.collect::<Vec<_>>();
let parsed_entries: Vec<Entry> = 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<Vec<Entry>> = 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,
))

View file

@ -1,4 +1,5 @@
mod lenses;
// mod sound;
use mlua::prelude::*;

View file

@ -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<()> {
}

View file

@ -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

View file

@ -1,5 +1,5 @@
require "signals.awesome"
require "signals.naughty"
require "signals.awesome"
require "signals.screen"
require "signals.client"

View file

@ -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)

View file

@ -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
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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