nix-config/home/ironbar.nix

243 lines
5.9 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
2023-07-05 06:36:38 +02:00
2024-04-03 00:01:13 +02:00
let
inherit (builtins) toJSON;
2024-04-03 00:01:13 +02:00
inherit (lib) singleton;
inherit (config.lib.stylix.colors) base00 base01 base04 base05 base09;
inherit (pkgs) ironbar inotify-tools;
mullvadScript = "ironbar/mullvad.fish";
mullvadNotification = "ironbar/mullvad-notification.fish";
2024-04-03 00:01:13 +02:00
in
{
home.packages = [ 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 drun";
}
{
type = "script";
on_click_left = "~/.config/${mullvadNotification}";
cmd = "~/.config/${mullvadScript}";
mode = "watch";
}
];
2023-07-04 19:31:19 +02:00
2024-04-03 00:01:13 +02:00
center = singleton {
type = "launcher";
icon_size = 39;
favorites = [
"librewolf"
"kitty"
"thunar"
"org.qutebrowser.qutebrowser"
"anki"
];
};
end = [
{
type = "tray";
}
{
type = "script";
cmd = "fish -c 'echo \"$(math \"$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | choose 1) * 100\")%\"'";
mode = "poll";
interval = 2500;
}
{
type = "clock";
format = "%x%a%R";
}
{
name = "overview";
type = "label";
label = "";
on_mouse_enter = "hyprctl dispatch hycov:toggleoverview";
}
];
};
xdg.configFile."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;
2023-07-05 15:20:32 +02:00
color: #${base05};
}
.background {
background: alpha(#${base00}, 0.925);
}
button:hover {
2023-07-05 15:20:32 +02:00
background: #${base01};
}
#bar {
2023-07-05 15:20:32 +02:00
border-top: 1px solid #${base01};
}
.label, .script, .tray {
padding-left: 0.5em;
padding-right: 0.5em;
2023-07-21 20:10:10 +02:00
}
.popup {
2023-07-05 15:20:32 +02:00
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;
2023-07-05 15:20:32 +02:00
border-top: 1px solid #${base01};
font-size: 1.5em;
}
.popup-clock .calendar {
padding: 0.2em 0.4em;
}
.popup-clock .calendar:selected {
color: #${base09};
}
.launcher .item {
padding-left: 1em;
padding-right: 1em;
margin-right: 4px;
}
button:active {
background: #${base04};
}
.launcher .open {
box-shadow: inset 0 -2px #${base04};
}
.launcher .focused {
2023-07-05 15:20:32 +02:00
box-shadow: inset 0 -2px #${base09};
background: #${base01};
}
.popup-launcher {
padding: 0;
}
.popup-launcher .popup-item:not(:first-child) {
2023-07-05 15:20:32 +02:00
border-top: 1px solid #${base01};
}
#startMenu {
padding-left: 1em;
padding-right: 0.5em;
}
#overview {
padding-left: 0.5em;
padding-right: 1em;
}
'';
xdg.configFile.${mullvadNotification} = {
executable = true;
text = /* fish */ ''
#!/usr/bin/env fish
mullvad relay set location any
mullvad relay set location us
sleep 0.2
notify-send -t 2000 "Mullvad" "$(mullvad status | choose 2)"
'';
};
xdg.configFile.${mullvadScript} = {
executable = true;
text = /* fish */ ''
#!/usr/bin/env fish
function get_mullvad_status
if test -z "$inside"
set inside true
test -n "$initialized" && sleep 0.2
set MULLVAD (mullvad status)
set LOCATION (echo "$MULLVAD" | choose 4.. | 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/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
${inotify-tools}/bin/inotifywait -q -e close_write,moved_to,create -m /etc/mullvad-vpn |
while read directory events filename
get_mullvad_status
end
'';
};
}