From ddcb125ee3502f992ab2ef95b7b84718647127b5 Mon Sep 17 00:00:00 2001
From: gytic <149968794+gytic@users.noreply.github.com>
Date: Sun, 27 Jul 2025 01:28:01 +0200
Subject: [PATCH] feat(taskbar): allow users to configure the taskbar
there are now options to:
- enable a battery icon (nixos95.taskbar.battery-plugin.enable)
- change the home icon (nixos95.taskbar.homeIcon)
- define pinned applications (nixos95.taskbar.applications)
---
nixos95/dotfiles/battery.rc | 19 ++
nixos95/dotfiles/launcher-13/brave.desktop | 10 -
nixos95/dotfiles/launcher-14/signal.desktop | 11 -
nixos95/dotfiles/launcher-15/obsidian.desktop | 10 -
nixos95/dotfiles/launcher-16/spotify.desktop | 10 -
nixos95/dotfiles/xfce4-panel.xml | 81 -------
nixos95/taskbar.nix | 215 ++++++++++++++++--
7 files changed, 218 insertions(+), 138 deletions(-)
create mode 100644 nixos95/dotfiles/battery.rc
delete mode 100644 nixos95/dotfiles/launcher-13/brave.desktop
delete mode 100644 nixos95/dotfiles/launcher-14/signal.desktop
delete mode 100644 nixos95/dotfiles/launcher-15/obsidian.desktop
delete mode 100644 nixos95/dotfiles/launcher-16/spotify.desktop
delete mode 100644 nixos95/dotfiles/xfce4-panel.xml
diff --git a/nixos95/dotfiles/battery.rc b/nixos95/dotfiles/battery.rc
new file mode 100644
index 0000000..cc72256
--- /dev/null
+++ b/nixos95/dotfiles/battery.rc
@@ -0,0 +1,19 @@
+display_label=false
+display_icon=true
+display_power=false
+display_percentage=false
+display_bar=false
+display_time=false
+tooltip_display_percentage=true
+tooltip_display_time=false
+low_percentage=30
+critical_percentage=20
+action_on_low=1
+action_on_critical=1
+hide_when_full=0
+colorA=rgb(119,118,123)
+colorH=rgb(143,240,164)
+colorL=rgb(248,228,92)
+colorC=rgb(237,51,59)
+command_on_low=
+command_on_critical=
diff --git a/nixos95/dotfiles/launcher-13/brave.desktop b/nixos95/dotfiles/launcher-13/brave.desktop
deleted file mode 100644
index 82e79b8..0000000
--- a/nixos95/dotfiles/launcher-13/brave.desktop
+++ /dev/null
@@ -1,10 +0,0 @@
-[Desktop Entry]
-Version=1.0
-Type=Application
-Name=Brave
-GenericName=Web Browser
-Comment=Browse the Web
-Exec=brave
-Icon=world
-Terminal=false
-Categories=Network;WebBrowser;
diff --git a/nixos95/dotfiles/launcher-14/signal.desktop b/nixos95/dotfiles/launcher-14/signal.desktop
deleted file mode 100644
index cd6cee7..0000000
--- a/nixos95/dotfiles/launcher-14/signal.desktop
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Version=1.0
-Type=Application
-Name=Signal
-
-Comment=Private Messenger
-Exec=signal-desktop %U
-Icon=signal-desktop
-Terminal=false
-Categories=Network;InstantMessaging;
-
diff --git a/nixos95/dotfiles/launcher-15/obsidian.desktop b/nixos95/dotfiles/launcher-15/obsidian.desktop
deleted file mode 100644
index 80b6393..0000000
--- a/nixos95/dotfiles/launcher-15/obsidian.desktop
+++ /dev/null
@@ -1,10 +0,0 @@
-[Desktop Entry]
-Version=1.0
-Type=Application
-Name=Obsidian
-
-Comment=Markdown Editor
-Exec=obsidian %u
-Icon=obsidian
-Terminal=false
-Categories=Office;Utility;
\ No newline at end of file
diff --git a/nixos95/dotfiles/launcher-16/spotify.desktop b/nixos95/dotfiles/launcher-16/spotify.desktop
deleted file mode 100644
index e514b9d..0000000
--- a/nixos95/dotfiles/launcher-16/spotify.desktop
+++ /dev/null
@@ -1,10 +0,0 @@
-[Desktop Entry]
-Version=1.0
-Type=Application
-Name=Spotify
-
-Comment=Spotify Music
-Exec=spotify %U
-Icon=spotify
-Terminal=false
-Categories=AudioVideo;Player;
diff --git a/nixos95/dotfiles/xfce4-panel.xml b/nixos95/dotfiles/xfce4-panel.xml
deleted file mode 100644
index 6286790..0000000
--- a/nixos95/dotfiles/xfce4-panel.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/nixos95/taskbar.nix b/nixos95/taskbar.nix
index 1c74c8b..e3e81db 100644
--- a/nixos95/taskbar.nix
+++ b/nixos95/taskbar.nix
@@ -3,28 +3,211 @@
* This can be improved by allowing users to define there own task bar config
*/
{ config, lib, pkgs, ... }: let
- cfg = config.nixos95;
-in lib.mkIf cfg.enable {
+ cfg = config.nixos95.taskbar;
+ user = config.nixos95.user;
+ t = lib.types;
+in {
- environment.systemPackages = [
- pkgs.xfce.xfce4-whiskermenu-plugin
- ];
+ options.nixos95.taskbar = {
- home-manager.users.${cfg.user} = {
-
- xdg.configFile = {
- "xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml" = {
- force = true;
- source = ./dotfiles/xfce4-panel.xml;
+ homeIcon = lib.mkOption {
+ description = ''
+ Home icon used in the lefter corner of the taskbar
+
+ Can be either a `path` to an icon to use,
+ or the name (string) of an icon in the current theme.
+ This will be the `Win95_plus` theme by default.
+ You can check for existing icons inside `/Ressources/Icons/Win95_plus`.
+ '';
+ default = "whisker-menu-button";
+ type = t.either t.str t.path;
+ example = "world";
+ };
+
+ battery-plugin = {
+ enable = lib.mkOption {
+ description = ''
+ Enable the battery plugin in the taskbar.
+
+ This will show the charging status in the right corner.
+ On hover it will show the excat percentage.
+ '';
+ default = true;
+ example = false;
+ type = t.bool;
};
+ };
- # Panel:
- "xfce4/panel/launcher-13/brave.desktop".source = ./dotfiles/launcher-13/brave.desktop;
- "xfce4/panel/launcher-14/signal.desktop".source = ./dotfiles/launcher-14/signal.desktop;
- "xfce4/panel/launcher-15/obsidian.desktop".source = ./dotfiles/launcher-15/obsidian.desktop;
- "xfce4/panel/launcher-16/spotify.desktop".source = ./dotfiles/launcher-16/spotify.desktop;
+ applications = lib.mkOption {
+ description = ''
+ (in order) list of applications to pin in the taskbar.
+
+ Applications must be defined as a set each with the following name-value paris:
+ {
+ enable = bool; [optional; default = true]
+ name = string; [application name shown on hover; optional]
+ description = string; [text shown on hover; optional]
+ icon = string | path; [icon shown in the task bar]
+ terminal = bool; [start the program inside a terminal; optional; default = false]
+ [either pkg or exe must be defined]
+ pkg = package; [use mainProgramm of a nix package; e.g. pkgs.firefox]
+ exe = string; [provide a program name directly; e.g. firefox]
+ }
+
+ The `icon` can be specified as an icon name (in the current Iocn pack)
+ or as a `path` to an image directly.
+ See `/Ressources/Icons/Win95_plus` for the default icons.
+
+ '';
+ default = [
+ {
+ name = "Files";
+ description = "View and manage local files";
+ icon = "folder_open";
+ exe = "exo-open --launch FileManager";
+ }
+ {
+ name = "Terminal";
+ description = "Run commands";
+ icon = "xfce4-terminal";
+ pkg = pkgs.xfce.xfce4-terminal;
+ }
+ {
+ name = "Browser";
+ description = "Access the world wide web";
+ icon = "firefox";
+ exe = "exo-open --launch WebBrowser";
+ }
+ ];
+ type = t.listOf t.attrs;
};
};
+ config = lib.mkIf config.nixos95.enable {
+
+ environment.systemPackages = [
+ pkgs.xfce.xfce4-whiskermenu-plugin
+ (lib.mkIf cfg.battery-plugin.enable pkgs.xfce.xfce4-battery-plugin)
+ ];
+
+ home-manager.users.${user} = {
+
+ xdg.configFile = {
+
+ "xfce4/panel/battery-7.rc" = {
+ force = true;
+ enable = cfg.battery-plugin.enable;
+ source = ./dotfiles/battery.rc;
+ };
+
+ "xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml" = let
+
+ ifBattery = str : if cfg.battery-plugin.enable then str else "";
+ battery_id = ifBattery '' '';
+ battery_xml = ifBattery '' '';
+
+ applications_cfg = cfg.applications
+ |> lib.filter ( elm : !( lib.hasAttr "enable" elm) || elm.enable )
+ |> lib.imap0 ( ptr : elm : rec {
+ # we start IDs in the 20 range to not get confilics with other plugins
+ plugin_id = "2" + builtins.toString ptr;
+ plugin_desktop = let
+ desc = if elm ? description then elm.description else "";
+ term = if elm ? term && elm.term then "true" else "false";
+ exec = if elm ? pkg then lib.getExe elm.pkg else elm.exe;
+ in pkgs.writeTextFile {
+ name = "${elm.name}.desktop";
+ text = ''
+ [Desktop Entry]
+ Version=1.0
+ Type=Application
+ Name=${elm.name}
+ Icon=${elm.icon}
+ Exec=${exec}
+ Comment=${desc}
+ Terminal=${term}
+ '';
+ };
+ plugin_xml = ''
+
+
+
+
+
+
+ '';
+ });
+
+ app_ids = applications_cfg
+ |> lib.map ( elm : '' '' )
+ |> lib.concatStringsSep "\n";
+ app_xml = applications_cfg
+ |> lib.map ( elm : elm.plugin_xml )
+ |> lib.concatStringsSep "\n";
+
+ in {
+ force = true;
+ text = ''
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${app_ids}
+
+
+
+
+ ${battery_id}
+
+
+
+
+
+
+
+
+
+
+
+ ${app_xml}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${battery_xml}
+
+
+ '';
+ };
+
+ };
+
+ };
+ };
+
}