Skip to content

Commit

Permalink
feat(pager): init (#386)
Browse files Browse the repository at this point in the history
Co-authored-by: Heitor Augusto <[email protected]>
  • Loading branch information
tucho and HeitorAugustoLN authored Oct 15, 2024
1 parent c6d4b6f commit df72af4
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/widgets/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let
./kicker.nix
./kickerdash.nix
./kickoff.nix
./pager.nix
./panel-spacer.nix
./plasma-panel-colorizer.nix
./plasmusic-toolbar.nix
Expand Down
110 changes: 110 additions & 0 deletions modules/widgets/pager.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{ lib, ... }:
let
inherit (import ./lib.nix { inherit lib; }) configValueType;
inherit (import ./default.nix { inherit lib; }) positionType sizeType;

mkBoolOption =
description:
lib.mkOption {
type = with lib.types; nullOr bool;
default = null;
example = true;
inherit description;
};

capitalizeWord =
word:
with lib.strings;
if word == null then
null
else
concatImapStrings (pos: char: if pos == 1 then toUpper char else char) (stringToCharacters word);
in
{
pager = {
description = "The desktop pager is a plasma widget that helps you to organize virtual desktops.";

opts = {
position = lib.mkOption {
type = positionType;
example = {
horizontal = 250;
vertical = 50;
};
description = "The position of the widget. (Only for desktop widget)";
};
size = lib.mkOption {
type = sizeType;
example = {
width = 500;
height = 500;
};
description = "The size of the widget. (Only for desktop widget)";
};
general = {
showWindowOutlines = mkBoolOption "Whether to show window outlines";
showApplicationIconsOnWindowOutlines = mkBoolOption "Whether to show application icons on window outlines";
showOnlyCurrentScreen = mkBoolOption "Whether to limit the Pager to the set of windows and the geometry of the screen the widget resides on";
navigationWrapsAround = mkBoolOption "Whether to wrap around when navigating the desktops";
displayedText =
let
options = {
none = "None";
desktopNumber = "Number";
desktopName = "Name";
};
in
lib.mkOption {
type = with lib.types; nullOr (enum (builtins.attrNames options));
default = null;
example = "desktopNumber";
description = "The text to show inside the desktop rectangles";
apply = option: if option == null then null else options.${option};
};
selectingCurrentVirtualDesktop = lib.mkOption {
type =
with lib.types;
nullOr (enum [
"doNothing"
"showDesktop"
]);
default = null;
example = "showDesktop";
description = "What to do on left-mouse click on a desktop rectangle";
apply = capitalizeWord;
};
};
settings = lib.mkOption {
type = configValueType;
default = null;
example = {
General = {
showWindowOutlines = true;
};
};
description = "Extra configuration options for the widget.";
apply = settings: if settings == null then { } else settings;
};
};
convert =
{
position,
size,
general,
settings,
}:
{
name = "org.kde.plasma.pager";
config = lib.recursiveUpdate {
General = lib.filterAttrs (_: v: v != null) {
showWindowOutlines = general.showWindowOutlines;
showWindowIcons = general.showApplicationIconsOnWindowOutlines;
showOnlyCurrentScreen = general.showOnlyCurrentScreen;
wrapPage = general.navigationWrapsAround;
displayedText = general.displayedText;
currentDesktopSelected = general.selectingCurrentVirtualDesktop;
};
} settings;
};
};
}

0 comments on commit df72af4

Please sign in to comment.