Waybar: Replace ugly icons for a beauty.

This commit is contained in:
Dmitry Voronin 2024-12-12 10:48:42 +03:00
parent 2bfd58acc1
commit 8d49899e50
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
9 changed files with 145 additions and 45 deletions

View file

@ -10,45 +10,45 @@
in {
config = lib.mkIf cfg.enable {
# Specify default model.
environment.variables.OLLAMA_MODEL = cfg.primaryModel;
systemd.services = {
# Enable Ollama server.
ollama = {
description = "Ollama LLM server";
serviceConfig = {
Type = "simple";
};
wantedBy = [
"multi-user.target"
];
script = ''
HOME=/root ${lib.getExe pkgsUnstable.ollama} serve
'';
};
# Download Ollama models.
ollama-pull = {
description = "Ollama LLM model";
after = [
"NetworkManager-wait-online.service"
"ollama.service"
];
wantedBy = [
"multi-user.target"
];
wants = [
"NetworkManager-wait-online.service"
"ollama.service"
];
serviceConfig = {
Type = "simple";
};
script = util.trimTabs ''
sleep 5
${lib.getExe pkgsUnstable.ollama} pull ${lib.concatStringsSep " " cfg.models}
'';
};
};
# environment.variables.OLLAMA_MODEL = cfg.primaryModel;
#
# systemd.services = {
# # Enable Ollama server.
# ollama = {
# description = "Ollama LLM server";
# serviceConfig = {
# Type = "simple";
# };
# wantedBy = [
# "multi-user.target"
# ];
# script = ''
# HOME=/root ${lib.getExe pkgsUnstable.ollama} serve
# '';
# };
#
# # Download Ollama models.
# ollama-pull = {
# description = "Ollama LLM model";
# after = [
# "NetworkManager-wait-online.service"
# "ollama.service"
# ];
# wantedBy = [
# "multi-user.target"
# ];
# wants = [
# "NetworkManager-wait-online.service"
# "ollama.service"
# ];
# serviceConfig = {
# Type = "simple";
# };
# script = util.trimTabs ''
# sleep 5
# ${lib.getExe pkgsUnstable.ollama} pull ${lib.concatStringsSep " " cfg.models}
# '';
# };
# };
};
}

View file

@ -3,7 +3,8 @@
config,
pkgs,
...
}: let
} @args: let
swayscript = pkgs.callPackage <package/swayscript> args;
alpha = config.module.style.opacity.hex;
color = config.module.style.color;
max = 3;
@ -20,7 +21,7 @@ in {
margin = 32;
max-history = max;
max-visible = max;
on-notify = "exec swayscript notify";
on-notify = "exec ${swayscript}/bin/swayscript notify";
text-color = "#${config.module.style.color.bg.dark}";
width = 480;
};

View file

@ -4,6 +4,7 @@
in {
text = ''
bindsym ${mod} input * xkb_switch_layout 0
bindsym --to-code ${mod}+a exec 'swayscript network'
bindsym --to-code ${mod}+c exec 'systemctl reboot -i'
bindsym --to-code ${mod}+g exec 'swayscript gaming'
bindsym --to-code ${mod}+l exec 'powerlimit toggle'

View file

@ -2,7 +2,5 @@
text = ''
bindsym --to-code $mod+shift+r exec 'pkill waybar || exec waybar'
exec waybar
exec nm-applet
exec blueman-applet
'';
}

View file

@ -32,6 +32,7 @@ in {
"group/batteryinfo"
"group/hardware"
"custom/display"
"custom/network"
"tray"
];
"sway/workspaces" = {
@ -186,6 +187,15 @@ in {
return-type = "json";
signal = 4;
};
"custom/network" = {
exec = "swayscript networkwidget";
# interval = refreshInterval;
on-click = "blueman-manager";
on-click-middle = "swayscript network";
on-click-right = "nm-connection-editor";
return-type = "json";
signal = 7;
};
"custom/taghw1" = {
exec = "echo ";
};

View file

@ -23,6 +23,7 @@ in {
/* Padding for global widgets. */
#clock,
#custom-display,
#custom-network,
#language,
#mpris,
#pulseaudio,
@ -44,6 +45,7 @@ in {
#batteryinfo:hover,
#clock:hover,
#custom-display:hover,
#custom-network:hover,
#hardware:hover,
#language:hover,
#mpris:hover,
@ -58,6 +60,7 @@ in {
#battery,
#cpu.usage,
#custom-display,
#custom-network,
#memory,
#pulseaudio,
#temperature,
@ -69,6 +72,8 @@ in {
#battery.critical,
#cpu.usage.critical,
#custom-display.modified,
#custom-network.issue,
#custom-network.vpn,
#memory.critical,
#pulseaudio.muted,
#pulseaudio.source-muted,

View file

@ -0,0 +1,62 @@
{ ... }: {
text = ''
# Waybar output.
function networkwidget() {
local IFS=$'\n'
local internet=$(nmcli networking connectivity check)
local _ethernets=($(nmcli connection show --active | rg ethernet | cut -f1 -d\ ))
local _vpns=($(nmcli connection show --active | rg vpn | cut -f1 -d\ ))
local _wifis=($(nmcli connection show --active | rg wifi | cut -f1 -d\ ))
local _bts=($(bluetoothctl devices Connected | cut -d\ -f3))
local icon="󰖩"
local class=""
if [[ "''${_bts}" != "" ]]; then
icon="󱛃"
fi
if [[ "''${_vpns}" != "" ]]; then
class="vpn"
icon="󱚿"
fi
if [[ "''${internet}" != "full" ]]; then
class="issue"
icon="󱚵"
fi
for net in ''${_vpns[@]}; do
[[ "''${networks}" = "" ]] || networks+="\\\n"
networks+=" ''${net}"
done
for net in ''${_ethernets[@]}; do
[[ "''${networks}" = "" ]] || networks+="\\\n"
networks+=" ''${net}"
done
for net in ''${_wifis[@]}; do
[[ "''${networks}" = "" ]] || networks+="\\\n"
networks+="󰖩 ''${net}"
done
for bt in ''${_bts[@]}; do
[[ "''${networks}" = "" ]] || networks+="\\\n"
networks+="󰂯 ''${bt}"
done
printf "{\"text\": \"''${icon}\", \"tooltip\": \"''${networks[@]}\", \"class\": \"''${class}\"}\n"
}
# Toggle network.
function network() {
notify_short
local state=$(nmcli networking)
if [[ "''${state}" = "enabled" ]]; then
nmcli networking off
else
nmcli networking on
fi
}
'';
}

View file

@ -1,7 +1,16 @@
{ ... }: {
{
pkgs,
util,
...
}: {
networking = {
networkmanager = {
enable = true;
dispatcherScripts = [{
source = pkgs.writeText "nm-wb-dispatcher" (util.trimTabs ''
${pkgs.procps}/bin/pkill -RTMIN+7 waybar
'');
}];
# unmanaged = [
# "type:bridge"
# "type:ethernet"

14
system/Udev.nix Normal file
View file

@ -0,0 +1,14 @@
{
pkgs,
util,
...
}: let
waybar_reload = pkgs.writeShellScriptBin "bt-wb-dispatcher" (util.trimTabs ''
${pkgs.procps}/bin/pkill -RTMIN+7 waybar
'');
in {
services.udev.extraRules = util.trimTabs ''
ACTION=="add", SUBSYSTEM=="bluetooth", RUN+="${waybar_reload}/bin/bt-wb-dispatcher"
ACTION=="remove", SUBSYSTEM=="bluetooth", RUN+="${waybar_reload}/bin/bt-wb-dispatcher"
'';
}