/** * For now this just hard copies the config file. * This can be improved by allowing users to define there own task bar config */ { config, lib, pkgs, ... }: let cfg = config.nixos95.taskbar; user = config.nixos95.user; t = lib.types; in { options.nixos95.taskbar = { 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; }; }; 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} ''; }; }; }; }; }