remove dependencies on i3status-rust assets at runtime

This commit is contained in:
LordMZTE 2023-05-19 11:28:57 +02:00
parent e1ac63ac8f
commit 19b83f34e5
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
3 changed files with 152 additions and 25 deletions

View file

@ -11,3 +11,4 @@ env_logger = "0.10.0"
i3status-rs = { git = "https://github.com/greshake/i3status-rust.git" }
serde_json = "1.0.96"
tokio = "1.28.1"
toml = "0.7.4"

View file

@ -0,0 +1,125 @@
# Material from NerdFont
# https://www.nerdfonts.com/cheat-sheet
backlight = [
"\ue38d", # nf-weather-moon_new
"\ue3d4", # nf-weather-moon_alt_waxing_gibbous_6
"\ue3d3", # nf-weather-moon_alt_waxing_gibbous_5
"\ue3d2", # nf-weather-moon_alt_waxing_gibbous_4
"\ue3d1", # nf-weather-moon_alt_waxing_gibbous_3
"\ue3d0", # nf-weather-moon_alt_waxing_gibbous_2
"\ue3cf", # nf-weather-moon_alt_waxing_gibbous_1
"\ue3ce", # nf-weather-moon_alt_first_quarter
"\ue3cd", # nf-weather-moon_alt_waxing_crescent_6
"\ue3cc", # nf-weather-moon_alt_waxing_crescent_5
"\ue3cb", # nf-weather-moon_alt_waxing_crescent_4
"\ue3ca", # nf-weather-moon_alt_waxing_crescent_3
"\ue3c9", # nf-weather-moon_alt_waxing_crescent_2
"\ue3c8", # nf-weather-moon_alt_waxing_crescent_1
"\ue39b", # nf-weather-moon_full
]
bat_charging = "\U000f0084" # nf-md-battery_charging
bat_not_available = "\U000f0091" # nf-md-battery_unknown
bat = [
"\U000f007a", # nf-md-battery_10
"\U000f007b", # nf-md-battery_20
"\U000f007c", # nf-md-battery_30
"\U000f007d", # nf-md-battery_40
"\U000f007e", # nf-md-battery_50
"\U000f007f", # nf-md-battery_60
"\U000f0080", # nf-md-battery_70
"\U000f0081", # nf-md-battery_80
"\U000f0082", # nf-md-battery_90
"\U000f0079", # nf-md-battery
]
bell = "\U000f009c" # nf-md-bell_outline
bell-slash = "\U000f009b" # nf-md-bell_off
bluetooth = "\U000f00af" # nf-md-bluetooth
calendar = "\U000f00ed" # nf-md-calendar
cogs = "\U000f0493" # nf-md-cog
cpu = [
"\U000F0F86", # nf-md-speedometer_slow
"\U000F0F85", # nf-md-speedometer_medium
"\U000F04C5", # nf-md-speedometer
]
cpu_boost_on = "\U000f0521" # nf-md-toggle_switch
cpu_boost_off = "\U000f0a19" # nf-md-toggle_switch_off_outline
disk_drive = "\U000f02ca" # nf-md-harddisk
docker = "\uf308" # nf-linux-docker
github = "\U000f02a4" # nf-md-github
gpu = "\U000f0379" # nf-md-monitor
headphones = "\U000f02cb" # nf-md-headphones
joystick = "\U000f0297" # nf-md-gamepad_variant
keyboard = "\U000f030c" # nf-md-keyboard
mail = "\U000f01ee" # nf-md-email
memory_mem = "\U000f035b" # nf-md-memory
memory_swap = "\U000f02ca" # nf-md-harddisk
mouse = "\U000f037d" # nf-md-mouse
music = "\U000f075a" # nf-md-music
music_next = "\U000f04ad" # nf-md-skip_next
music_pause = "\U000f03e4" # nf-md-pause
music_play = "\U000f040a" # nf-md-play
music_prev = "\U000f04ae" # nf-md-skip_previous
net_bridge = "\U000f04aa" # nf-md-sitemap
net_down = "\U000f01da" # nf-md-download
net_loopback = "\U000f006f" # nf-md-backup_restore
net_modem = "\U000f03f2" # nf-md-phone
net_cellular = [
"\U000F08FD", # nf-md-network_strength_off_outline
"\U000F08FE", # nf-md-network_strength_outline
"\U000F08F4", # nf-md-network_strength_1
"\U000F08F6", # nf-md-network_strength_2
"\U000F08F8", # nf-md-network_strength_3
"\U000F08FA", # nf-md-network_strength_4
]
net_up = "\U000f0552" # nf-md-upload
net_vpn = "\U000f0582" # nf-md-vpn
net_wired = "\U000f0200" # nf-md-ethernet
net_wireless = [
"\U000F092F", # nf-md-wifi_strength_outline
"\U000F091F", # nf-md-wifi_strength_1
"\U000F0922", # nf-md-wifi_strength_2
"\U000F0925", # nf-md-wifi_strength_3
"\U000F0928", # nf-md-wifi_strength_4
]
notification = "\U000f009c" # nf-md-bell_outline
phone = "\U000f03f2" # nf-md-phone
phone_disconnected = "\U000f0658" # nf-md-phone_minus
ping = "\U000f051f" # nf-md-timer_sand
pomodoro = "\ue001" # nf-pom-pomodoro_done
pomodoro_break = "\U000f0176" # nf-md-coffee
pomodoro_paused = "\U000f03e4" # nf-md-pause
pomodoro_started = "\U000f040a" # nf-md-play
pomodoro_stopped = "\U000f04db" # nf-md-stop
resolution = "\U000f0293" # nf-md-fullscreen
tasks = "\U000f05c7" # nf-md-playlist_check
tea = "\U000f0d9e" # nf-md-tea
thermometer = [
"\U000f10c3", # nf-md-thermometer_low
"\U000f050f", # nf-md-thermometer
"\U000f10c2", # nf-md-thermometer_high
]
time = "\U000f0150" # nf-md-clock_outline
toggle_off = "\U000f0a19" # nf-md-toggle_switch_off_outline
toggle_on = "\U000f0521" # nf-md-toggle_switch
unknown = "\U000f0186" # nf-md-comment_question_outline | TODO: Make default?
update = "\U000f03d5" # nf-md-package_up
uptime = "\U000f0153" # nf-md-clock_in
volume_muted = "\U000f075f" # nf-md-volume_mute
volume = [
"\U000f057f", # nf-md-volume_low
"\U000f0580", # nf-md-volume_medium
"\U000f057e", # nf-md-volume_high
]
microphone_muted = "\U000f036d" # nf-md-microphone_off
microphone = [
"\U000f036e", # nf-md-microphone_outline
"\U000f036c", # nf-md-microphone
"\U000f036c", # nf-md-microphone
]
weather_clouds = "\ue33d" # nf-weather-cloud
weather_default = "\ue33d" # Cloud symbol as default
weather_rain = "\ue371" # nf-weather-raindrop
weather_snow = "\ue36f" # nf-weather-snowflake_cold
weather_sun = "\ue30d" # nf-weather-day_sunny
weather_thunder = "\ue31d" # nf-weather-thunderstorm
xrandr = "\U000f037a" # nf-md-monitor_multiple

View file

@ -9,10 +9,7 @@ use i3status_rs::{
themes::{
color::{Color, Rgba},
separator::Separator,
ColorOrLink,
Theme,
ThemeOverrides,
ThemeUserConfig,
},
widget::{State, Widget},
BarState,
@ -42,31 +39,35 @@ async fn try_main() -> anyhow::Result<()> {
env_logger::try_init()?;
protocol::init(false);
fn override_color(r: u8, g: u8, b: u8) -> Option<ColorOrLink> {
Some(ColorOrLink::Color(Color::Rgba(Rgba { r, g, b, a: 0xff })))
fn color(r: u8, g: u8, b: u8) -> Color {
Color::Rgba(Rgba { r, g, b, a: 0xff })
}
let icons = Icons::from_file("material-nf")?;
let theme = Theme::try_from(ThemeUserConfig {
theme: Some("slick".into()),
overrides: Some(ThemeOverrides {
// dracula theme
idle_bg: override_color(0x44, 0x47, 0x5a),
idle_fg: override_color(0xf8, 0xf8, 0xf2),
info_bg: override_color(0x44, 0x47, 0x5a),
info_fg: override_color(0xf8, 0xf8, 0xf2),
good_bg: override_color(0x50, 0xfa, 0x7b),
good_fg: override_color(0x62, 0x72, 0xa4),
warning_bg: override_color(0xff, 0xb8, 0x6c),
warning_fg: override_color(0xbd, 0x93, 0xf9),
critical_bg: override_color(0xff, 0x55, 0x55),
critical_fg: override_color(0xbd, 0x93, 0xf9),
separator: Some(Separator::Custom("\u{e0b2}".to_string())),
separator_bg: Some(ColorOrLink::Color(Color::Auto)),
separator_fg: Some(ColorOrLink::Color(Color::Auto)),
..Default::default()
let icons = Icons(toml::from_str(include_str!("../assets/material-nf.toml"))?);
let theme = Theme {
// dracula theme
idle_bg: color(0x44, 0x47, 0x5a),
idle_fg: color(0xf8, 0xf8, 0xf2),
info_bg: color(0x44, 0x47, 0x5a),
info_fg: color(0xf8, 0xf8, 0xf2),
good_bg: color(0x50, 0xfa, 0x7b),
good_fg: color(0x62, 0x72, 0xa4),
warning_bg: color(0xff, 0xb8, 0x6c),
warning_fg: color(0xbd, 0x93, 0xf9),
critical_bg: color(0xff, 0x55, 0x55),
critical_fg: color(0xbd, 0x93, 0xf9),
separator: Separator::Custom("\u{e0b2}".to_string()),
separator_bg: Color::Auto,
separator_fg: Color::Auto,
alternating_tint_bg: Color::Rgba(Rgba {
r: 0x11,
g: 0x11,
b: 0x11,
a: 0x00,
}),
})?;
alternating_tint_fg: Color::Auto,
end_separator: Separator::Native,
};
let mut bar = BarState::new(i3status_rs::config::Config {
shared: SharedConfig {