mirror of
https://forge.katzen.cafe/schrottkatze/nix-configs.git
synced 2024-12-05 02:38:44 +01:00
Compare commits
3 commits
867514362a
...
258d4639d7
Author | SHA1 | Date | |
---|---|---|---|
258d4639d7 | |||
4f1e43e923 | |||
718fe00b46 |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ result
|
||||||
.direnv/
|
.direnv/
|
||||||
programs/*/target
|
programs/*/target
|
||||||
target
|
target
|
||||||
|
*openapi.json
|
||||||
|
|
927
Cargo.lock
generated
927
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = [ "programs/bar-ws-monitor",
|
members = [ "programs/bar-pinger", "programs/bar-ws-monitor",
|
||||||
"programs/jrnl"
|
"programs/jrnl"
|
||||||
]
|
, "programs/traveldings"]
|
||||||
|
|
|
@ -87,6 +87,8 @@
|
||||||
]))
|
]))
|
||||||
rs-toolchain
|
rs-toolchain
|
||||||
pkgs.haskell-language-server
|
pkgs.haskell-language-server
|
||||||
|
pkgs.pkg-config
|
||||||
|
pkgs.openssl
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
.topBar {
|
|
||||||
margin-bottom: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
label {
|
label {
|
||||||
font: 14pt "FiraCode Nerd Font";
|
font: 14pt "FiraCode Nerd Font";
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
}: {
|
}: {
|
||||||
programs.wofi.enable = true;
|
programs.wofi.enable = true;
|
||||||
programs.swaylock.enable = true;
|
programs.swaylock.enable = true;
|
||||||
|
services.network-manager-applet.enable = true;
|
||||||
|
|
||||||
xdg.portal = {
|
xdg.portal = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -64,11 +65,7 @@
|
||||||
};
|
};
|
||||||
startup = [
|
startup = [
|
||||||
{
|
{
|
||||||
command = "eww open topBar; eww open bottomBar";
|
command = "eww open-many topBar bottomBar";
|
||||||
}
|
|
||||||
{
|
|
||||||
command = "pkill nm-applet; sleep 1 && nm-applet";
|
|
||||||
always = true;
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
command = "sleep 1 && mullvad-gui";
|
command = "sleep 1 && mullvad-gui";
|
||||||
|
@ -77,6 +74,16 @@
|
||||||
bars = [];
|
bars = [];
|
||||||
menu = "wofi -d";
|
menu = "wofi -d";
|
||||||
modifier = "Mod4";
|
modifier = "Mod4";
|
||||||
|
assigns = {
|
||||||
|
"1" = [
|
||||||
|
{class = "^Signal$";}
|
||||||
|
{class = "^Element$";}
|
||||||
|
{class = "^Evolution$";}
|
||||||
|
];
|
||||||
|
"2" = [
|
||||||
|
{app_id = "^firefox$";}
|
||||||
|
];
|
||||||
|
};
|
||||||
keybindings = with {
|
keybindings = with {
|
||||||
#mod = config.xsession.windowManager.i3.config.modifier;
|
#mod = config.xsession.windowManager.i3.config.modifier;
|
||||||
# mod = "Mod1";
|
# mod = "Mod1";
|
||||||
|
@ -112,14 +119,6 @@
|
||||||
# rofi fuckery
|
# rofi fuckery
|
||||||
"${mod}+d" = "exec wofi -S drun --allow-images";
|
"${mod}+d" = "exec wofi -S drun --allow-images";
|
||||||
"${mod}+i" = "exec rofimoji --selector wofi -f alchemical_symbols anatolian_hieroglyphs emojis braille_patterns box_drawing chess_symbols emoticons geometric_shapes gothic greek_extended math mathematical_alphanumeric_symbols mathematical_operators miscellaneous_symbols miscellaneous_mathematical_symbols-a miscellaneous_mathematical_symbols-b miscellaneous_symbols_and_arrows miscellaneous_symbols_and_pictographs miscellaneous_technical modi modifier_tone_letters musical_symbols nerd_font number_forms shorthand_format_controls specials variation_selectors vertical_forms -a copy";
|
"${mod}+i" = "exec rofimoji --selector wofi -f alchemical_symbols anatolian_hieroglyphs emojis braille_patterns box_drawing chess_symbols emoticons geometric_shapes gothic greek_extended math mathematical_alphanumeric_symbols mathematical_operators miscellaneous_symbols miscellaneous_mathematical_symbols-a miscellaneous_mathematical_symbols-b miscellaneous_symbols_and_arrows miscellaneous_symbols_and_pictographs miscellaneous_technical modi modifier_tone_letters musical_symbols nerd_font number_forms shorthand_format_controls specials variation_selectors vertical_forms -a copy";
|
||||||
# TODO: wayland
|
|
||||||
# "${mod}+d" = "exec --no-startup-id rofi -show drun -theme ${../../other/rofi-themes/applauncher.rasi}";
|
|
||||||
# "${mod}+space" = "exec --no-startup-id rofi -show combi -combi-show window#run -modes combi -theme ${../../other/rofi-themes/applauncher.rasi}";
|
|
||||||
# "${mod}+i" = "exec --no-startup-id rofimoji -f alchemical_symbols anatolian_hieroglyphs emojis braille_patterns box_drawing chess_symbols emoticons geometric_shapes gothic greek_extended math mathematical_alphanumeric_symbols mathematical_operators miscellaneous_symbols miscellaneous_mathematical_symbols-a miscellaneous_mathematical_symbols-b miscellaneous_symbols_and_arrows miscellaneous_symbols_and_pictographs miscellaneous_technical modi modifier_tone_letters musical_symbols nerd_font number_forms shorthand_format_controls specials variation_selectors vertical_forms -a copy";
|
|
||||||
# "${mod}+Shift+e" = "exec --no-startup-id rofi -show \"desktopctl\" -modes \"desktopctl:${desktop-ctl.outPath}/bin/desktopctl\" -theme ${../../other/rofi-themes/applauncher.rasi}";
|
|
||||||
# "${mod}+m" = "exec --no-startup-id menu-qalc";
|
|
||||||
|
|
||||||
# "${mod}+o" = "exec --no-startup-id rofi -show searchwolf -modes \"searchwolf:${searchwolf.outPath}/bin/searchwolf\"";
|
|
||||||
|
|
||||||
# audio
|
# audio
|
||||||
"XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status";
|
"XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status";
|
||||||
|
@ -138,16 +137,11 @@
|
||||||
|
|
||||||
"XF86KbdBrightnessUp" = "exec brillo -kA 10.0";
|
"XF86KbdBrightnessUp" = "exec brillo -kA 10.0";
|
||||||
"XF86KbdBrightnessDown" = "exec brillo -kU 10.0";
|
"XF86KbdBrightnessDown" = "exec brillo -kU 10.0";
|
||||||
|
|
||||||
# macros
|
|
||||||
# "${mod}+q" = "exec em-record.sh";
|
|
||||||
# "${mod}+p" = "exec em-play.sh";
|
|
||||||
# "${mod}+Shift+p" = "exec em-play-loop.sh";
|
|
||||||
|
|
||||||
# permaclip
|
|
||||||
# "${mod}+c" = "exec rofi -show register -modes \"register:${pc-set.outPath}/bin/pc-set.sh\" -theme gruvbox-dark";
|
|
||||||
# "${mod}+v" = "exec rofi -show register -modes \"register:${pc-get.outPath}/bin/pc-get.sh\" -theme gruvbox-dark";
|
|
||||||
};
|
};
|
||||||
|
workspaceAutoBackAndForth = true;
|
||||||
|
focus = {
|
||||||
|
wrapping = "yes";
|
||||||
|
};
|
||||||
fonts = {
|
fonts = {
|
||||||
names = ["Atkinson Hyperlegible"];
|
names = ["Atkinson Hyperlegible"];
|
||||||
style = "Regular";
|
style = "Regular";
|
||||||
|
|
|
@ -51,6 +51,7 @@ def main [] {
|
||||||
let next_events = open ~/Docs/dates.csv
|
let next_events = open ~/Docs/dates.csv
|
||||||
| update datetime {|ev| $ev.datetime | into datetime }
|
| update datetime {|ev| $ev.datetime | into datetime }
|
||||||
| sort-by datetime
|
| sort-by datetime
|
||||||
|
| filter {|ev| ($ev.datetime > (date now))}
|
||||||
| first
|
| first
|
||||||
| each {|ev| $"(ansi attr_bold)($ev.event)(ansi reset) in (ansi attr_bold)(tfmt ($ev.datetime - (date now)))s(ansi reset)" };
|
| each {|ev| $"(ansi attr_bold)($ev.event)(ansi reset) in (ansi attr_bold)(tfmt ($ev.datetime - (date now)))s(ansi reset)" };
|
||||||
print $"Hi jade, you're on HRT for (ansi reset)(ansi attr_bold)((date now) - ('2024-02-18T20:53' | into datetime) | format duration month)s(ansi reset) now! | Next Event: ($next_events)";
|
print $"Hi jade, you're on HRT for (ansi reset)(ansi attr_bold)((date now) - ('2024-02-18T20:53' | into datetime) | format duration month)s(ansi reset) now! | Next Event: ($next_events)";
|
||||||
|
|
6
programs/bar-pinger/Cargo.toml
Normal file
6
programs/bar-pinger/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "bar-pinger"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
5
programs/bar-pinger/src/main.rs
Normal file
5
programs/bar-pinger/src/main.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
// const ADDRS: [&str] = ["katzen.cafe", "fucktorio.s10e.de", "9.9.9.9"];
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// let pingers = ADDRS.iter.map(|addr| Command::new("ping").args([addr]));
|
||||||
|
}
|
13
programs/traveldings/Cargo.toml
Normal file
13
programs/traveldings/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[package]
|
||||||
|
name = "traveldings"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0.209", features = ["derive"] }
|
||||||
|
serde_json = "1.0.128"
|
||||||
|
reqwest = {version = "0.12.7", default-features = false, features = ["rustls-tls", "charset", "http2"]}
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
anyhow = "1"
|
||||||
|
chrono = { version = "0.4", features = ["serde"]}
|
||||||
|
clap = { version = "4.5", features = ["derive"]}
|
1
programs/traveldings/src/commands.rs
Normal file
1
programs/traveldings/src/commands.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod current_journey;
|
9
programs/traveldings/src/commands/current_journey.rs
Normal file
9
programs/traveldings/src/commands/current_journey.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
use crate::traewelling::TraewellingClient;
|
||||||
|
|
||||||
|
pub async fn get_current_journey() -> anyhow::Result<()> {
|
||||||
|
let client = TraewellingClient::new()?;
|
||||||
|
|
||||||
|
println!("active: {:#?}", client.get_active_checkin().await?);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
35
programs/traveldings/src/main.rs
Normal file
35
programs/traveldings/src/main.rs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
use std::{default, fs};
|
||||||
|
|
||||||
|
use clap::{Parser, Subcommand};
|
||||||
|
use commands::current_journey::get_current_journey;
|
||||||
|
use reqwest::{
|
||||||
|
header::{self, HeaderMap},
|
||||||
|
ClientBuilder,
|
||||||
|
};
|
||||||
|
use traewelling::model::{Container, Status};
|
||||||
|
|
||||||
|
mod commands;
|
||||||
|
mod traewelling;
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
struct Cli {
|
||||||
|
#[command(subcommand)]
|
||||||
|
subcommand: Subcommands,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand, Clone)]
|
||||||
|
enum Subcommands {
|
||||||
|
/// Watch for a current journey and give out json info about it
|
||||||
|
Current,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> anyhow::Result<()> {
|
||||||
|
let args = Cli::parse();
|
||||||
|
|
||||||
|
match args.subcommand {
|
||||||
|
Subcommands::Current => get_current_journey().await?,
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
56
programs/traveldings/src/traewelling.rs
Normal file
56
programs/traveldings/src/traewelling.rs
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
use std::{fmt, fs};
|
||||||
|
|
||||||
|
use model::{Container, Status};
|
||||||
|
use reqwest::{
|
||||||
|
header::{self, HeaderMap},
|
||||||
|
Client, ClientBuilder,
|
||||||
|
};
|
||||||
|
|
||||||
|
const KEY_PATH: &str = "/home/jade/Docs/traveldings-key";
|
||||||
|
const USER_AGENT: &str = "s10e/traveldings";
|
||||||
|
const TRAEWELLING_API_URL: &str = "https://traewelling.de/api/v1";
|
||||||
|
|
||||||
|
pub struct TraewellingClient {
|
||||||
|
client: Client,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TraewellingClient {
|
||||||
|
pub fn new() -> anyhow::Result<Self> {
|
||||||
|
let mut headers = HeaderMap::new();
|
||||||
|
let token = fs::read_to_string(KEY_PATH)?;
|
||||||
|
let key = header::HeaderValue::from_str(&format!("Bearer {token}"))?;
|
||||||
|
println!("meow");
|
||||||
|
headers.insert("Authorization", key);
|
||||||
|
headers.insert(
|
||||||
|
header::ACCEPT,
|
||||||
|
header::HeaderValue::from_static("application/json"),
|
||||||
|
);
|
||||||
|
Ok(Self {
|
||||||
|
client: ClientBuilder::new()
|
||||||
|
.user_agent("s10e/traveldings")
|
||||||
|
.default_headers(headers)
|
||||||
|
.build()?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_active_checkin(&self) -> anyhow::Result<Status> {
|
||||||
|
let txt = self
|
||||||
|
.client
|
||||||
|
.get(Self::fmt_url("user/statuses/active"))
|
||||||
|
.send()
|
||||||
|
.await?
|
||||||
|
.text()
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
println!("{txt}");
|
||||||
|
|
||||||
|
let res: Container<Status> = serde_json::de::from_str(&txt)?;
|
||||||
|
Ok(res.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fmt_url(path: impl fmt::Display) -> String {
|
||||||
|
format!("{TRAEWELLING_API_URL}/{path}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod model;
|
47
programs/traveldings/src/traewelling/model.rs
Normal file
47
programs/traveldings/src/traewelling/model.rs
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
use chrono::{DateTime, FixedOffset};
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
pub struct Container<D> {
|
||||||
|
pub data: D,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Status {
|
||||||
|
train: TransportResource,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct TransportResource {
|
||||||
|
category: String,
|
||||||
|
line_name: String,
|
||||||
|
distance: u32,
|
||||||
|
duration: u32,
|
||||||
|
operator: OperatorResource,
|
||||||
|
origin: StopOverResource,
|
||||||
|
destination: StopOverResource,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct StopOverResource {
|
||||||
|
name: String,
|
||||||
|
ril_identifier: Option<String>,
|
||||||
|
arrival: Option<DateTime<FixedOffset>>,
|
||||||
|
arrival_planned: Option<DateTime<FixedOffset>>,
|
||||||
|
arrival_real: Option<DateTime<FixedOffset>>,
|
||||||
|
departure: Option<DateTime<FixedOffset>>,
|
||||||
|
departure_planned: Option<DateTime<FixedOffset>>,
|
||||||
|
departure_real: Option<DateTime<FixedOffset>>,
|
||||||
|
platform: Option<String>,
|
||||||
|
departure_platform_planned: Option<String>,
|
||||||
|
departure_platform_real: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct OperatorResource {
|
||||||
|
name: String,
|
||||||
|
}
|
Loading…
Reference in a new issue