1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

feat(i3): reintroduce workspaces, add info workspace, reduce bar info

This commit is contained in:
2024-03-13 09:01:42 +01:00
parent 3af20cdd7b
commit aa2c84142b
5 changed files with 297 additions and 189 deletions

View File

@@ -72,6 +72,12 @@ in {
group = config.users.users.me.group;
mode = "400";
};
miniflux-api-token = {
file = ../secrets/miniflux-api-token.age;
owner = config.users.users.me.name;
group = config.users.users.me.group;
mode = "400";
};
};
programs.slock.enable = true;
@@ -101,6 +107,7 @@ in {
home-manager.users.me = let
modifier = "Mod4";
infoWorkspace = "";
modes.resize = {
"Escape" = ''mode "default"'';
"Return" = ''mode "default"'';
@@ -117,13 +124,13 @@ in {
bars = [
(config.home-manager.users.me.lib.stylix.i3.bar
// rec {
workspaceButtons = false;
workspaceButtons = true;
mode = "dock"; # "hide";
position = "bottom";
statusCommand = toString (pkgs.writers.writeDash "i3status-rust" ''
export I3RS_GITHUB_TOKEN="$(cat ${config.age.secrets.github-token-i3status-rust.path})"
export OPENWEATHERMAP_API_KEY="$(cat ${config.age.secrets.openweathermap-api-key.path})"
${config.home-manager.users.me.programs.i3status-rust.package}/bin/i3status-rs ${config.home-manager.users.me.home.homeDirectory}/.config/i3status-rust/config-${position}.toml
exec ${config.home-manager.users.me.programs.i3status-rust.package}/bin/i3status-rs ${config.home-manager.users.me.home.homeDirectory}/.config/i3status-rust/config-${position}.toml
'');
fonts = {
names = ["${config.stylix.fonts.sansSerif.name}" "FontAwesome 6 Free"];
@@ -168,83 +175,89 @@ in {
childBorder = lib.mkForce background;
};
};
keybindings = {
"${modifier}+Shift+h" = "move left 25 px";
"${modifier}+Shift+j" = "move down 25 px";
"${modifier}+Shift+k" = "move up 25 px";
"${modifier}+Shift+l" = "move right 25 px";
"${modifier}+h" = "focus left";
"${modifier}+j" = "focus down";
"${modifier}+k" = "focus up";
"${modifier}+l" = "focus right";
keybindings =
lib.listToAttrs (map (x: lib.nameValuePair "${modifier}+Shift+${toString x}" "move container to workspace ${toString x}") (lib.range 1 9))
// lib.listToAttrs (map (x: lib.nameValuePair "${modifier}+${toString x}" "workspace ${toString x}") (lib.range 1 9))
// {
"${modifier}+0" = "workspace ${infoWorkspace}";
"${modifier}+Shift+0" = "move container to workspace ${infoWorkspace}";
"${modifier}+Shift+b" = "move window to workspace prev";
"${modifier}+Shift+n" = "move window to workspace next";
"${modifier}+b" = "workspace prev";
"${modifier}+n" = "workspace next";
"${modifier}+Shift+h" = "move left 25 px";
"${modifier}+Shift+j" = "move down 25 px";
"${modifier}+Shift+k" = "move up 25 px";
"${modifier}+Shift+l" = "move right 25 px";
"${modifier}+h" = "focus left";
"${modifier}+j" = "focus down";
"${modifier}+k" = "focus up";
"${modifier}+l" = "focus right";
"${modifier}+Shift+c" = "reload";
"${modifier}+Shift+q" = "kill";
"${modifier}+Shift+r" = "restart";
# "${modifier}+Shift+b" = "move container to workspace prev";
# "${modifier}+Shift+n" = "move container to workspace next";
# "${modifier}+b" = "workspace prev";
# "${modifier}+n" = "workspace next";
"${modifier}+z" = "sticky toggle";
"${modifier}+Shift+z" = "floating toggle";
"${modifier}+Shift+c" = "reload";
"${modifier}+Shift+q" = "kill";
"${modifier}+Shift+r" = "restart";
"${modifier}+s" = "scratchpad show";
"${modifier}+Shift+s" = "move scratchpad";
"${modifier}+z" = "sticky toggle";
"${modifier}+Shift+z" = "floating toggle";
"${modifier}+c" = "split h";
"${modifier}+e" = "layout toggle split";
"${modifier}+f" = "fullscreen toggle";
"${modifier}+r" = "mode resize";
"${modifier}+v" = "split v";
"${modifier}+w" = "layout tabbed";
"${modifier}+q" = "exec ${config.services.clipmenu.package}/bin/clipmenu";
"${modifier}+s" = "scratchpad show";
"${modifier}+Shift+s" = "move scratchpad";
"${modifier}+Return" = "exec ${(defaultApplications pkgs).terminal}";
"${modifier}+t" = "exec ${(defaultApplications pkgs).fileManager}";
"${modifier}+y" = "exec ${(defaultApplications pkgs).browser}";
"${modifier}+0" = "exec ${niveumPackages.menu-calc}/bin/=";
"${modifier}+c" = "split h";
"${modifier}+e" = "layout toggle split";
"${modifier}+f" = "fullscreen toggle";
"${modifier}+r" = "mode resize";
"${modifier}+v" = "split v";
"${modifier}+w" = "layout tabbed";
"${modifier}+q" = "exec ${config.services.clipmenu.package}/bin/clipmenu";
"${modifier}+d" = "exec ${pkgs.writers.writeDash "run" ''exec rofi -modi run,ssh,window -show run''}";
"${modifier}+Shift+d" = "exec ${niveumPackages.notemenu}/bin/notemenu";
"${modifier}+p" = "exec rofi-pass";
"${modifier}+Shift+p" = "exec rofi-pass --insert";
"${modifier}+u" = "exec ${niveumPackages.unicodmenu}/bin/unicodmenu";
"${modifier}+Return" = "exec ${(defaultApplications pkgs).terminal}";
"${modifier}+t" = "exec ${(defaultApplications pkgs).fileManager}";
"${modifier}+y" = "exec ${(defaultApplications pkgs).browser}";
"${modifier}+ß" = "exec ${niveumPackages.menu-calc}/bin/=";
"${modifier}+F7" = "exec ${pkgs.writers.writeDash "showkeys-toggle" ''
if ${pkgs.procps}/bin/pgrep screenkey; then
exec ${pkgs.procps}/bin/pkill screenkey
else
exec ${pkgs.screenkey}/bin/screenkey
fi
''}";
"${modifier}+F12" = "exec ${klem}/bin/klem";
"XF86AudioLowerVolume" = "exec ${pkgs.pamixer}/bin/pamixer -d 5";
"XF86AudioMute" = "exec ${pkgs.pamixer}/bin/pamixer -t";
"XF86AudioRaiseVolume" = "exec ${pkgs.pamixer}/bin/pamixer -i 5";
"XF86Calculator" = "exec ${pkgs.st}/bin/st -c floating -e ${pkgs.bc}/bin/bc";
"XF86AudioPause" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next";
"XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous";
"XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop";
"XF86ScreenSaver" = "exec ${niveumPackages.k-lock}/bin/k-lock";
"${modifier}+d" = "exec ${pkgs.writers.writeDash "run" ''exec rofi -modi run,ssh,window -show run''}";
"${modifier}+Shift+d" = "exec ${niveumPackages.notemenu}/bin/notemenu";
"${modifier}+p" = "exec rofi-pass";
"${modifier}+Shift+p" = "exec rofi-pass --insert";
"${modifier}+u" = "exec ${niveumPackages.unicodmenu}/bin/unicodmenu";
# key names detected with xorg.xev:
# XF86WakeUp (fn twice)
# XF86Battery (fn f3)
# XF86Sleep (fn f4) - actually suspends
# XF86WLAN
# XF86WebCam (fn f6)
# XF86TouchpadToggle (fn f8)
# XF86Suspend (fn f12) - actually suspends to disk
# Num_Lock (fn Roll) - numlocks
# XF86Audio{Prev,Next,Mute,Play,Stop}
# XF86Forward
# XF86Back
# XF86Launch1 (thinkvantage)
};
"${modifier}+F7" = "exec ${pkgs.writers.writeDash "showkeys-toggle" ''
if ${pkgs.procps}/bin/pgrep screenkey; then
exec ${pkgs.procps}/bin/pkill screenkey
else
exec ${pkgs.screenkey}/bin/screenkey
fi
''}";
"${modifier}+F12" = "exec ${klem}/bin/klem";
"XF86AudioLowerVolume" = "exec ${pkgs.pamixer}/bin/pamixer -d 5";
"XF86AudioMute" = "exec ${pkgs.pamixer}/bin/pamixer -t";
"XF86AudioRaiseVolume" = "exec ${pkgs.pamixer}/bin/pamixer -i 5";
"XF86Calculator" = "exec ${pkgs.st}/bin/st -c floating -e ${pkgs.bc}/bin/bc";
"XF86AudioPause" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next";
"XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous";
"XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop";
"XF86ScreenSaver" = "exec ${niveumPackages.k-lock}/bin/k-lock";
# key names detected with xorg.xev:
# XF86WakeUp (fn twice)
# XF86Battery (fn f3)
# XF86Sleep (fn f4) - actually suspends
# XF86WLAN
# XF86WebCam (fn f6)
# XF86TouchpadToggle (fn f8)
# XF86Suspend (fn f12) - actually suspends to disk
# Num_Lock (fn Roll) - numlocks
# XF86Audio{Prev,Next,Mute,Play,Stop}
# XF86Forward
# XF86Back
# XF86Launch1 (thinkvantage)
};
in {
wayland.windowManager.sway = {
enable = true;
@@ -277,6 +290,12 @@ in {
enable = true;
extraConfig = ''
bindsym --release ${modifier}+Shift+w exec /run/wrappers/bin/slock
assign [class="wtf"] ${infoWorkspace}
exec ${pkgs.alacritty}/bin/alacritty --class wtf --command ${pkgs.writers.writeDash "dashboard" ''
export WTF_OWM_API_KEY="$(cat ${config.age.secrets.openweathermap-api-key.path})"
export WTF_MINIFLUX_API_KEY="$(cat ${config.age.secrets.miniflux-api-token.path})"
exec ${niveumPackages.dashboard}/bin/dashboard
''}
'';
config = lib.mkMerge [
{
@@ -296,8 +315,8 @@ in {
"${modifier}+F10" = "exec ${pkgs.redshift}/bin/redshift -x";
"${modifier}+F11" = "exec ${pkgs.xcalib}/bin/xcalib -invert -alter";
"Print" = "exec flameshot gui";
"${modifier}+Shift+x" = "exec ${move-to-new-workspace}";
"${modifier}+x" = "exec ${new-workspace}";
# "${modifier}+Shift+x" = "exec ${move-to-new-workspace}";
# "${modifier}+x" = "exec ${new-workspace}";
"XF86Display" = "exec ${niveumPackages.dmenu-randr}/bin/dmenu-randr";
};
}

View File

@@ -41,88 +41,6 @@
format = "{$icon $combo $play |}";
separator = " ";
}
{
block = "weather";
autolocate = true;
format = "$icon $location: $temp";
service = {
name = "openweathermap";
city_id = "2950159";
units = "metric";
};
}
{
block = "custom";
interval = 60 * 5;
command = let
spacetime = import ../configs/spacetime.nix;
in
pkgs.writers.writePython3 "sun.py" {
libraries = [pkgs.python3Packages.astral];
flakeIgnore = ["E121" "E501"];
}
''
import astral
import astral.moon
import astral.sun
current_phase = astral.moon.phase()
city = astral.LocationInfo("Berlin", "Germany", "${spacetime.time.timeZone}", ${toString spacetime.location.latitude}, ${toString spacetime.location.longitude})
sun = astral.sun.sun(city.observer, date=astral.today(), tzinfo=city.timezone)
print("{} {} {}{}".format(sun["sunrise"].strftime("%R"), sun["sunset"].strftime("%R"), "" if current_phase < 14 else "", round(current_phase, 1)))
'';
}
{
block = "custom";
interval = 5 * 60;
hide_when_empty = true;
json = true;
icons_overrides.update = "";
command = let
minifluxEndpoint = "https://feed.kmein.de";
in
pkgs.writers.writeDash "miniflux" ''
MINIFLUX_TOKEN=$(cat ${config.age.secrets.miniflux-api-token.path})
${pkgs.curl}/bin/curl --insecure --header "X-Auth-Token: $MINIFLUX_TOKEN" ${minifluxEndpoint}/v1/feeds/counters \
| ${pkgs.jq}/bin/jq '{
text: ((.unreads | values | add) // 0) | tostring,
icon: "update"
}'
'';
}
{
block = "github";
info = ["total"];
warning = ["mention" "review_requested" "team_mention" "manual" "invitation" "assign" "subscribed"];
}
{
block = "custom";
interval = 10;
command = pkgs.writers.writeDash "todo" ''
${pkgs.todoman}/bin/todo --porcelain | ${pkgs.jq}/bin/jq -r '
map(select(.due != null))
| (map(select(.due < now)) | length) as $overdue
| (map(select(.due >= now and .due < now + (60 * 60 * 24))) | length) as $dueToday
| {
icon: "tasks",
text: (($overdue + $dueToday) as $sum | if $sum > 0 then $sum | tostring else "" end),
state: (
if $overdue > 0 then
"Critical"
elif $dueToday > 0 then
"Warning"
else
"Idle"
end
)
}
'
'';
json = true;
hide_when_empty = true;
}
{
block = "custom";
interval = 60;
@@ -148,11 +66,6 @@
missing_format = "";
device = "tun0";
}
{
block = "net";
device = config.niveum.wirelessInterface;
format = "$icon $ssid $signal_strength";
}
{
block = "battery";
device = config.niveum.batteryName;
@@ -170,35 +83,8 @@
}
{block = "load";}
{
block = "custom";
interval = 10;
json = true;
command = pkgs.writers.writeDash "time" ''
${pkgs.jq}/bin/jq -n \
--arg now "$(${pkgs.coreutils}/bin/date +'%Y-%m-%d (%W %a) %H:%M')" \
--argjson nextEvent "$(
${pkgs.khal}/bin/khal list --format "{start}" --day-format "" $(${pkgs.coreutils}/bin/date +'%Y-%m-%d %H:%M') 2>/dev/null \
| ${pkgs.gnugrep}/bin/grep -E '[0-9]{2}:[0-9]{2}' \
| ${pkgs.coreutils}/bin/head -1 \
| ${pkgs.coreutils}/bin/date --date="$(cat)" +%s
)" \
'{
text: $now,
icon: "time",
state: (
($nextEvent - now) as $deltaT
| if $deltaT < (5 * 60) then
"Critical"
elif $deltaT < (15 * 60) then
"Warning"
elif $deltaT < (60 * 60) then
"Info"
else
"Idle"
end
)
}'
'';
block = "time";
format = "$icon $timestamp.datetime(f:'%Y-%m-%d (%W %a) %H:%M', l:de_DE)";
}
];
};

View File

@@ -297,6 +297,7 @@
cyberlocker-tools = pkgs.callPackage packages/cyberlocker-tools.nix {};
default-gateway = pkgs.callPackage packages/default-gateway.nix {};
depp = pkgs.callPackage packages/depp.nix {};
dashboard = pkgs.callPackage packages/dashboard {};
devanagari = pkgs.callPackage packages/devanagari {};
devour = pkgs.callPackage packages/devour.nix {};
dic = pkgs.callPackage packages/dic.nix {};

View File

@@ -0,0 +1,202 @@
{
writers,
formats,
wtf,
lib,
jq,
gh,
curl,
khal,
todoman,
gnused,
coreutils,
astrolog,
weatherCityIds ? [2950159],
}: let
rowCount = 10;
columnCount = 6;
yaml = formats.yaml {};
command = args:
{
enabled = true;
type = "cmdrunner";
}
// args;
configuration.wtf = rec {
grid = {
columns = lib.replicate columnCount 32;
rows = lib.replicate rowCount 5;
};
mods.vdir_khal = command {
title = "Calendar";
cmd = "${khal}/bin/khal";
args = ["--color" "list"];
refreshInterval = "1m";
position = rec {
top = 0;
left = columnCount - width + 1;
height = rowCount - mods.vdir_todo.position.height;
width = 1;
};
};
mods.vdir_todo = command {
title = "Agenda";
cmd = writers.writeDash "vdir_todo" "${todoman}/bin/todo --color=always -h | ${coreutils}/bin/tac";
refreshInterval = "1m";
position = {
top = 8;
left = 0;
height = 2;
width = columnCount + 1;
};
};
mods.weather = {
enabled = true;
cityids = weatherCityIds;
position = {
top = 6;
left = 2;
height = 2;
width = 1;
};
refreshInterval = "15m";
language = "DE";
tempUnit = "C";
useEmoji = true;
compact = true;
};
mods.btc = command {
title = "BTC";
cmd = writers.writeDash "btc" "${curl}/bin/curl -sSL https://rate.sx/BTC | ${gnused}/bin/sed -n '34,36p'";
refreshInterval = "1h";
position = {
top = 6;
left = 0;
height = 1;
width = 2;
};
};
mods.xmr = command {
title = "XMR";
cmd = writers.writeDash "xmr" "${curl}/bin/curl -sSL https://rate.sx/XMR | ${gnused}/bin/sed -n '34,36p'";
refreshInterval = "1h";
position = {
top = 7;
left = 0;
height = 1;
width = 2;
};
};
mods.top = command {
title = "uptime";
cmd = writers.writeDash "top" "top -b -n 1 -E g | ${gnused}/bin/sed -n '1,5p'";
refreshInterval = "30s";
position = {
top = 0;
left = 0;
height = 2;
width = 3;
};
enabled = false;
};
mods.resourceusage = {
enabled = true;
cpuCombined = false;
position = {
top = 0;
left = 0;
height = 2;
width = 1;
};
refreshInterval = "1s";
showCPU = true;
showMem = true;
showSwp = false;
};
mods.ipapi = {
enabled = true;
position = {
top = 0;
left = 1;
height = 2;
width = 2;
};
refreshInterval = "150s";
};
mods.disk-usage = command {
enabled = false;
cmd = "df";
args = ["-h"];
refreshInterval = "1m";
position = {
top = 2;
left = 1;
height = 2;
width = 2;
};
};
mods.gh-status = command {
enabled = true;
title = "GitHub";
cmd = writers.writeDash "gh-status" ''
${gh}/bin/gh api notifications \
| ${jq}/bin/jq -r 'map("\u001b[35m\(.repository.full_name)\u001b[0m \(.subject.title)") | join("\n")'
'';
refreshInterval = "5m";
position = {
top = 4;
left = 3;
height = 4;
width = 3;
};
};
mods.astro-aspects = command {
title = "Aspects";
enabled = false;
cmd = writers.writeDash "astro-aspects" "${astrolog}/bin/astrolog -n -zN Berlin -d";
refreshInterval = "1h";
position = {
top = 7;
left = 3;
height = 1;
width = 2;
};
};
mods.feed = command {
title = "Feed";
cmd = writers.writeDash "feed" ''
${curl}/bin/curl -u "$WTF_MINIFLUX_API_KEY" --basic -s 'https://feed.kmein.de/v1/entries?status=unread&direction=desc' \
| ${jq}/bin/jq -r '
.total as $total | (
.entries
| map("\(.feed.category.title) \u001b[32m\(.author)\u001b[0m \(.title)")
| join("\n")
)'
'';
# position = { top = 0; left = 5; height = 5; width = 1; };
position = {
top = 0;
left = 3;
height = 4;
width = 3;
};
refreshInterval = "15m";
};
mods.astro-positions = command {
enabled = false;
title = "Positions";
cmd = writers.writeDash "astro-positions" "${astrolog}/bin/astrolog -q $(date +'%m %d %Y %H:%M') -zN Berlin | ${gnused}/bin/sed -n '4,16p' | ${coreutils}/bin/cut -c 1-33";
refreshInterval = "1h";
position = {
top = 5;
left = 5;
height = 3;
width = 1;
};
};
};
in
writers.writeDashBin "dashboard" ''
exec ${wtf}/bin/wtfutil --config=${yaml.generate "config.yml" configuration}
''

Submodule secrets updated: 3d11dd6efb...cc426c750e