nix-config/home/ironbar.nix
Donovan Glover f54f3fe9ba
chore: update to latest nixos-unstable release
- Updated Mullvad ironbar script to account for new breaking cli changes
- Removed `native_https_query = false` since LibreWolf 132 fixes DNS leaks
2024-11-11 01:08:30 -05:00

281 lines
7.2 KiB
Nix
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
nixosConfig,
config,
lib,
pkgs,
...
}:
let
inherit (nixosConfig._module.specialArgs) nix-config;
inherit (lib) singleton;
inherit (builtins) toJSON;
inherit (nix-config.packages.${pkgs.system}) dunst-scripts;
inherit (config.lib.stylix.colors.withHashtag)
base00
base01
base04
base05
base0D
;
mullvadScript = "ironbar/mullvad.fish";
volumeScript = "ironbar/volume.fish";
volumeGet = "ironbar/volume-get.fish";
in
{
home.packages = with pkgs; [ ironbar ];
xdg.configFile = {
"ironbar/config.json".text = toJSON {
name = "main";
icon_theme = "Fluent-dark";
position = "bottom";
anchor_to_edges = true;
start = [
{
name = "startMenu";
type = "label";
label = "";
on_mouse_enter = "rofi -show";
}
{
type = "script";
on_click_left = "mullvad relay set location any && mullvad relay set location us";
cmd = "~/.config/${mullvadScript}";
mode = "watch";
}
];
center = singleton {
type = "launcher";
icon_size = 39;
favorites = [
"librewolf"
"kitty"
"thunar"
"Chromium-browser"
"anki"
];
};
end = [
{
type = "script";
cmd = "~/.config/${volumeScript}";
on_click_left = "${dunst-scripts}/bin/mv-up";
on_click_right = "${dunst-scripts}/bin/mv-down";
mode = "watch";
}
{
type = "upower";
show_if = "upower -e | grep BAT";
}
{
type = "clock";
format = "%x%a%R";
}
];
};
"ironbar/style.css".text = # css
''
* {
font-family: "Noto Sans CJK JP", "Font Awesome 6 Free Solid";
font-size: 16px;
text-shadow: 2px 2px ${base00};
border: none;
border-radius: 0;
outline: none;
font-weight: 500;
background: none;
color: ${base05};
}
.background {
background: alpha(${base00}, 0.925);
}
button:hover {
background: alpha(${base01}, 0.8);
}
#bar {
border-top: 1px solid alpha(${base01}, 0.925);
}
.label, .script, .tray {
padding-left: 0.5em;
padding-right: 0.5em;
}
.upower {
padding-left: 0.2em;
padding-right: 0.2em;
}
.upower .label {
padding-left: 0;
padding-right: 0;
}
.popup {
border: 1px solid ${base01};
padding: 1em;
}
.popup-clock .calendar-clock {
font-family: "Maple Mono";
font-size: 2.5em;
padding-bottom: 0.1em;
}
.popup-clock .calendar .header {
padding-top: 1em;
border-top: 1px solid ${base01};
font-size: 1.5em;
}
.popup-clock .calendar {
padding: 0.2em 0.4em;
}
.popup-clock .calendar:selected {
color: ${base0D};
}
.launcher .item {
padding-left: 1em;
padding-right: 1em;
margin-right: 4px;
}
button:active {
background: alpha(${base04}, 0.8);
}
.launcher .open {
box-shadow: inset 0 -2px alpha(${base04}, 0.8);
}
.launcher .focused {
box-shadow: inset 0 -2px alpha(${base0D}, 0.8);
background: alpha(${base01}, 0.8);
}
.popup-launcher {
padding: 0;
}
.popup-launcher .popup-item:not(:first-child) {
border-top: 1px solid ${base01};
}
#startMenu {
padding-left: 1em;
padding-right: 0.5em;
}
'';
${mullvadScript} = {
executable = true;
text = # fish
''
#!/usr/bin/env fish
sleep 2
function get_mullvad_status
if test -z "$inside"
set inside true
test -n "$initialized" && sleep 0.2
set MULLVAD (mullvad status | tail -1)
set LOCATION (echo "$MULLVAD" | choose 3.. | sed \
-e 's/Ashburn.*//g' \
-e 's/Atlanta.*//g' \
-e 's/Boston.*//g' \
-e 's/Charlotte.*//g' \
-e 's/Chicago.*//g' \
-e 's/Cleveland.*//g' \
-e 's/Dallas.*//g' \
-e 's/Detroit.*//g' \
-e 's/Denver.*//g' \
-e 's/Honolulu.*//g' \
-e 's/Houston.*//g' \
-e 's/Jackson.*//g' \
-e 's/Los Angeles.*//g' \
-e 's/Louisville.*//g' \
-e 's/McAllen.*//g' \
-e 's/Miami.*//g' \
-e 's/Milwaukee.*//g' \
-e 's/Minneapolis.*//g' \
-e 's/New York.*//g' \
-e 's/Oklahoma.*//g' \
-e 's/Philadelphia.*//g' \
-e 's/Phoenix.*//g' \
-e 's/Piscataway.*//g' \
-e 's/Portland.*//g' \
-e 's/Raleigh.*//g' \
-e 's/Richmond.*//g' \
-e 's/Salt Lake.*//g' \
-e 's/San Francisco.*//g' \
-e 's/San Jose.*//g' \
-e 's/Seattle.*//g' \
-e 's/Secaucus.*//g' \
-e 's/Sioux Falls.*//g' \
-e 's/St. Louis.*//g' \
-e 's/Stamford.*//g' \
-e 's/Washington.*//g'
)
echo "$LOCATION"
set -e inside
end
end
get_mullvad_status
set initialized true
${pkgs.inotify-tools}/bin/inotifywait -q -e close_write,moved_to,create -m /etc/mullvad-vpn |
while read directory events filename
get_mullvad_status
end
'';
};
${volumeScript} = {
executable = true;
text = # fish
''
#!/usr/bin/env fish
sleep 2
~/.config/${volumeGet}
pactl subscribe | grep --line-buffered -e "" | xargs -L 1 ~/.config/${volumeGet}
'';
};
${volumeGet} = {
executable = true;
text = # fish
''
#!/usr/bin/env fish
set VOL $(wpctl get-volume @DEFAULT_AUDIO_SINK@)
set MUTE $(echo "$VOL" | awk '{print $3}' | sed -e 's/\[MUTED\]//' | tr --delete '\n')
echo -n "$MUTE"
echo "$(math "$(echo "$VOL" | choose 1) * 100")%"
'';
};
};
}