Initial commit

This commit is contained in:
2025-08-20 18:24:02 +03:00
commit 2dec42d487
116 changed files with 6591 additions and 0 deletions

690
modules/desktop/yambar.nix Normal file
View File

@@ -0,0 +1,690 @@
{
pkgs,
lib,
config,
host,
...
}: let
niri = lib.getExe pkgs.c.niri;
jq = lib.getExe pkgs.jq;
workspaces_script = pkgs.writeShellScript "workspaces.sh" ''
workspaces_num () {
IFS=$'\n'
local r=$(${niri} msg -j workspaces | ${jq} '.[].idx' | sort -nr | head -n1)
echo $r
}
get_idx () {
local r=$(${niri} msg -j workspaces)
for (( i=0; i<$(workspaces_num); i+=1 ))
do
local act=$(echo $r | ${jq} .[$i].id)
if [ $act -eq $1 ]; then
local idx=$(echo $r | ${jq} .[$i].idx)
echo $idx
break
fi
done
}
get_before () {
if [ $1 -eq "1" ]; then
echo ""
else
a=
for (( i=1; i<$1; i++ )) do
a="$a $i"
done
echo $a
fi
}
get_after () {
if [ $1 -eq $2 ]; then
echo ""
else
a=
for (( i=$1+1; i<=$2; i++ )) do
a="$a $i"
done
echo $a
fi
}
ret_add () {
echo "before|string|$(get_before $1)"
echo "after|string|$(get_after $1 $2)"
}
bnum=$(workspaces_num)
echo "number|int|$bnum"
beg=$(${niri} msg -j workspaces)
cf () {
for (( i=0; i<$2; i+=1 ))
do
bact=$(echo $1 | ${jq} .[$i].is_active)
if [[ "$bact" == "true" ]]; then
bf=$(echo $1 | ${jq} .[$i].idx)
echo "$bf"
break
fi
done
}
sf=`cf "$beg" "$bnum"`
echo "focused|int|$sf"
ret_add $sf $bnum
echo ""
${niri} msg -j event-stream | while read -r line; do
current=$(echo $line | ${jq} .WorkspaceActivated.id)
if [[ "$current" != "null" ]]; then
cn=$(workspaces_num)
idx=$(get_idx $current)
echo "number|int|$cn"
echo "focused|int|$idx"
ret_add $idx $cn
echo ""
fi
current=$(echo $line | ${jq} .WorkspacesChanged.workspaces)
if [[ "$current" != "null" ]]; then
cn=$(workspaces_num)
c=$(cf "$current" "$cn")
idx=$c
echo "number|int|$cn"
echo "focused|int|$idx"
ret_add $c $cn
echo ""
fi
done
'';
lang_script = pkgs.writeShellScript "current_layout.sh" ''
startl=$(${niri} msg -j keyboard-layouts | ${jq} .current_idx)
echo "lang|int|$startl"
echo ""
${niri} msg -j event-stream | while read -r line; do
current=$(echo $line | ${jq} .KeyboardLayoutSwitched.idx)
if [[ "$current" != "null" ]]; then
echo "lang|string|$current"
echo ""
fi
done
'';
in {
hm.programs.yambar = {
enable = true;
settings.bar = let
# std_underline = {
# underline = {
# size = 2;
# color = "ff0000ff";
# };
# };
red = config.lib.stylix.colors.base08 + "ff";
orange = config.lib.stylix.colors.base09 + "ff";
yellow = config.lib.stylix.colors.base0A + "ff";
white = config.lib.stylix.colors.base05 + "ff";
grey = "999999ff";
awesome = "Font Awesome 6 Free:style=solid:pixelsize=14";
in {
font = "FiraCode Nerd Font:pixelsize=12";
height = 26;
location = "top";
spacing = 8;
margin = 7;
foreground = white;
background = config.lib.stylix.colors.base00 + "cc";
left = [
{
script = {
path = workspaces_script;
args = [
];
content = [
{
string = {
text = "{before}";
};
}
{
string = {
text = " {focused} ";
foreground = orange;
};
}
{
string = {
text = "{after}";
};
}
];
};
}
{
foreign-toplevel = {
content = {
map = {
conditions = {
"~activated" = {
empty = {
};
};
activated = [
{
string = {
text = "{app-id}";
foreground = orange;
};
}
];
};
};
};
};
}
];
center = [
{
clock = {
time-format = "%H:%M";
content = [
{
string = {
text = "{time}";
on-click = "${lib.getExe pkgs.playerctl} play-pause";
};
}
];
};
}
];
right = [
{
network = {
content = {
map = {
default = {
empty = {
};
};
conditions = {
"name == enp2s0" = {
map = {
conditions = {
"~carrier" = {
empty = {
};
};
carrier = {
map = {
default = {
string = {
text = "";
font = awesome;
foreground = white;
};
};
conditions = {
"state == up && ipv4 != \"\"" = {
string = {
text = "";
foreground = red;
font = awesome;
};
};
};
};
};
};
};
};
};
};
};
};
}
{
network = {
poll-interval = 1000;
content = {
map = {
default = {
empty = {
};
};
conditions = {
"name == wlan0" = {
map = {
default = {
string = {
text = "";
font = awesome;
foreground = white;
};
};
conditions = {
"state == down" = {
string = {
text = "";
font = awesome;
foreground = red;
};
};
"state == up" = {
map = {
default = [
{
string = {
text = "";
font = awesome;
};
}
];
conditions = {
"ipv4 == \"\"" = [
{
string = {
text = "";
font = awesome;
foreground = red;
};
}
];
};
};
};
};
};
};
};
};
};
};
}
{
pipewire = let
volume.conditions = {
muted = {
string = {
text = "{cubic_volume}%";
foreground = "999999ff";
};
};
"~muted" = {
string = {
text = "{cubic_volume}%";
};
};
};
in {
content.list.items = [
{
map.conditions = {
"type == \"sink\"".map.conditions = {
"bus == \"bluetooth\"" = {
string = {
text = "󰂯 ";
font = awesome;
};
};
muted = {
string = {
text = " ";
font = awesome;
foreground = grey;
};
};
"~muted" = [
{
ramp = {
tag = "cubic_volume";
items = [
{
string = {
text = " ";
font = awesome;
};
}
{
string = {
text = " ";
font = awesome;
};
}
];
};
}
];
};
"type == \"source\"" = {
map.conditions = {
muted = {
string = {
text = " ";
font = awesome;
foreground = grey;
};
};
"~muted" = {
string = {
text = " 🎙";
font = awesome;
foreground = yellow;
};
};
};
};
};
}
{map."<<" = volume;}
];
};
}
{
backlight = {
name = "amdgpu_bl2";
content = [
{
string = {
text = "";
font = awesome;
};
}
{
string = {
text = "{percent}%";
};
}
];
};
}
{
battery = let
discharging = {
list = {
items = [
{
ramp = {
tag = "capacity";
items = [
{
string = {
text = "";
foreground = "ff0000ff";
font = awesome;
};
}
{
string = {
text = "";
foreground = "ff0000ff";
font = awesome;
};
}
{
string = {
text = "";
foreground = "ffa600ff";
font = awesome;
};
}
{
string = {
text = "";
font = awesome;
};
}
{
string = {
text = "";
font = awesome;
};
}
{
string = {
text = "";
font = awesome;
};
}
{
string = {
text = "";
font = awesome;
};
}
{
string = {
text = "";
font = awesome;
};
}
{
string = {
text = "";
font = awesome;
};
}
{
string = {
text = "";
foreground = "00ff00ff";
font = awesome;
};
}
];
};
}
{
string = {
text = "{capacity}%";
};
}
];
};
};
in {
name = if host == "tureis" then "BAT1" else "BAT0";
poll-interval = 250;
content = {
map = {
conditions = {
"state == unknown" = {
"<<" = discharging;
};
"state == discharging" = {
"<<" = discharging;
};
"state == charging" = [
{
string = {
text = "󱐋";
foreground = "00ff00ff";
font = awesome;
};
}
{
string = {
text = "{capacity}%";
};
}
];
"state == full" = [
{
string = {
text = "";
foreground = "00ff00ff";
font = awesome;
};
}
{
string = {
text = "{capacity}%";
};
}
];
"state == \"not charging\"" = [
{
ramp = {
tag = "capacity";
items = [
{
string = {
text = " ";
foreground = "ff0000ff";
font = awesome;
};
}
{
string = {
text = " ";
foreground = "ffa600ff";
font = awesome;
};
}
{
string = {
text = " ";
foreground = "00ff00ff";
font = awesome;
};
}
{
string = {
text = " ";
foreground = "00ff00ff";
font = awesome;
};
}
{
string = {
text = " ";
foreground = "00ff00ff";
font = awesome;
};
}
{
string = {
text = " ";
foreground = "00ff00ff";
font = awesome;
};
}
{
string = {
text = " ";
foreground = "00ff00ff";
font = awesome;
};
}
{
string = {
text = " ";
foreground = "00ff00ff";
font = awesome;
};
}
{
string = {
text = " ";
foreground = "00ff00ff";
font = awesome;
};
}
{
string = {
text = " ";
foreground = "00ff00ff";
font = awesome;
};
}
];
};
}
{
string = {
text = "{capacity}%";
};
}
];
};
};
};
};
}
{
clock = {
date-format = "%d %B, %A";
content = [
{
string = {
text = "";
font = awesome;
};
}
{
string = {
text = "{date}";
right-margin = 5;
};
}
];
};
}
{
script = {
path = lang_script;
args = [
];
content = {
map = {
default = {
string = {
text = "{lang}";
};
};
conditions = {
"lang == 0" = [
{
string = {
text = "";
font = awesome;
};
}
{
string = {
text = "en";
};
}
];
"lang == 1" = [
{
string = {
text = "";
font = awesome;
};
}
{
string = {
text = "ru";
};
}
];
};
};
};
};
}
];
};
};
}