Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plasma-panel-spacer-extended widget-specific options #290

Open
wants to merge 10 commits into
base: trunk
Choose a base branch
from
1 change: 1 addition & 0 deletions modules/widgets/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let
./digital-clock.nix
./icon-tasks.nix
./kickoff.nix
./panel-spacer-extended.nix
./plasmusic-toolbar.nix
./system-monitor.nix
./system-tray.nix
Expand Down
325 changes: 325 additions & 0 deletions modules/widgets/panel-spacer-extended.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
{ lib, ... }:
let
inherit (lib) mkOption types;

actionType = types.submodule {
options = {
action = mkOption {
type = types.str;
example = "pausemedia";
description = "The action to perform.";
};
component = mkOption {
type = types.str;
example = "mediacontrol";
description = "The component to perform the action on.";
};
command = mkOption {
type = types.nullOr types.str;
example = ''date="$(date -u)"; notify-send "Single Click" "$date"'';
description = "The command to log.";
};
appUrl = mkOption {
type = types.nullOr types.str;
description = "The application URL";
};
};
};
in {
panelSpacerExtended = {
description = "Spacer with Mouse gestures for the KDE Plasma Panel featuring Latte Dock/Gnome/Unity drag window gesture.";

opts = {
expanding = mkOption {
type = types.nullOr types.bool;
default = null;
example = true;
description = "Whether the spacer should expand to fill the available space.";
};
length = mkOption {
type = types.nullOr types.ints.unsigned;
default = null;
example = 32;
description = ''
The length in pixels of the spacer.
Configuration effective only if expanding is set to false.
'';
};
highlight = {
enable = mkOption {
type = types.nullOr types.bool;
default = null;
example = true;
description = "Whether the spacer should highlight when hovered.";
};
radius = mkOption {
type = types.nullOr types.ints.unsigned;
default = null;
example = 4;
description = ''
The radius in pixels of the highlight.
Configuration effective only if enable is set to true.
'';
};
fillPanel = mkOption {
type = types.nullOr types.bool;
default = null;
example = true;
description = ''
Whether the highlight should fill the entire panel.
Configuration effective only if enable is set to true.
'';
};
};
showTooltip = mkOption {
type = types.nullOr types.bool;
default = null;
example = true;
description = "Whether to show list of actions when hovering the spacer.";
};
scrollThreshold = mkOption {
type = types.nullOr types.ints.unsigned;
default = null;
example = 10;
description = ''
The scroll sensitivity

Higher values may help reducing repeated scrolling events on some devices.
'';
};
actions = {
singleClick = mkOption {
type = types.nullOr actionType;
default = null;
example = {
action = "pausemedia";
component = "mediacontrol";
command = ''date="$(date -u)"; notify-send "Single Click" "$date"'';
};
description = "The action to perform on single click.";
apply = singleClick: let
convertAction = action: component: "${component},${action}";
in lib.optionalAttrs (singleClick != null) {
singleClickAction = convertAction singleClick.action singleClick.component;
singleClickCommand = singleClick.command;
singleClickAppUrl = singleClick.appUrl;
};
};
doubleClick = mkOption {
type = types.nullOr actionType;
default = null;
example = {
action = "pausemedia";
component = "mediacontrol";
command = ''date="$(date -u)"; notify-send "Double Click" "$date"'';
};
description = "The action to perform on double click.";
apply = doubleClick: let
convertAction = action: component: "${component},${action}";
in lib.optionalAttrs (doubleClick != null) {
doubleClickAction = convertAction doubleClick.action doubleClick.component;
doubleClickCommand = doubleClick.command;
doubleClickAppUrl = doubleClick.appUrl;
};
};
middleClick = mkOption {
type = types.nullOr actionType;
default = null;
example = {
action = "pausemedia";
component = "mediacontrol";
command = ''date="$(date -u)"; notify-send "Middle Click" "$date"'';
};
description = "The action to perform on middle click.";
apply = middleClick: let
convertAction = action: component: "${component},${action}";
in lib.optionalAttrs (middleClick != null) {
middleClickAction = convertAction middleClick.action middleClick.component;
middleClickCommand = middleClick.command;
middleClickAppUrl = middleClick.appUrl;
};
};
mouseWheelUp = mkOption {
type = types.nullOr actionType;
default = null;
example = {
action = "pausemedia";
component = "mediacontrol";
command = ''date="$(date -u)"; notify-send "Wheel Up" "$date"'';
};
description = "The action to perform on mouse wheel up.";
apply = mouseWheelUp: let
convertAction = action: component: "${component},${action}";
in lib.optionalAttrs (mouseWheelUp != null) {
mouseWheelUpAction = convertAction mouseWheelUp.action mouseWheelUp.component;
mouseWheelUpCommand = mouseWheelUp.command;
mouseWheelUpAppUrl = mouseWheelUp.appUrl;
};
};
mouseWheelDown = mkOption {
type = types.nullOr actionType;
default = null;
example = {
action = "pausemedia";
component = "mediacontrol";
command = ''date="$(date -u)"; notify-send "Wheel Down" "$date"'';
};
description = "The action to perform on mouse wheel down.";
apply = mouseWheelDown: let
convertAction = action: component: "${component},${action}";
in lib.optionalAttrs (mouseWheelDown != null) {
mouseWheelDownAction = convertAction mouseWheelDown.action mouseWheelDown.component;
mouseWheelDownCommand = mouseWheelDown.command;
mouseWheelDownAppUrl = mouseWheelDown.appUrl;
};
};
mouseDragUp = mkOption {
type = types.nullOr actionType;
default = null;
example = {
action = "pausemedia";
component = "mediacontrol";
command = ''date="$(date -u)"; notify-send "Drag Up" "$date"'';
};
description = "The action to perform on mouse drag up.";
apply = mouseDragUp: let
convertAction = action: component: "${component},${action}";
in lib.optionalAttrs (mouseDragUp != null) {
mouseDragUpAction = convertAction mouseDragUp.action mouseDragUp.component;
mouseDragUpCommand = mouseDragUp.command;
mouseDragUpAppUrl = mouseDragUp.appUrl;
};
};
mouseDragDown = mkOption {
type = types.nullOr actionType;
default = null;
example = {
action = "pausemedia";
component = "mediacontrol";
command = ''date="$(date -u)"; notify-send "Drag Down" "$date"'';
};
description = "The action to perform on mouse drag down.";
apply = mouseDragDown: let
convertAction = action: component: "${component},${action}";
in lib.optionalAttrs (mouseDragDown != null) {
mouseDragDownAction = convertAction mouseDragDown.action mouseDragDown.component;
mouseDragDownCommand = mouseDragDown.command;
mouseDragDownAppUrl = mouseDragDown.appUrl;
};
};
mouseDragLeft = mkOption {
type = types.nullOr actionType;
default = null;
example = {
action = "pausemedia";
component = "mediacontrol";
command = ''date="$(date -u)"; notify-send "Drag Left" "$date"'';
};
description = "The action to perform on mouse drag left.";
apply = mouseDragLeft: let
convertAction = action: component: "${component},${action}";
in lib.optionalAttrs (mouseDragLeft != null) {
mouseDragLeftAction = convertAction mouseDragLeft.action mouseDragLeft.component;
mouseDragLeftCommand = mouseDragLeft.command;
mouseDragLeftAppUrl = mouseDragLeft.appUrl;
};
};
mouseDragRight = mkOption {
type = types.nullOr actionType;
default = null;
example = {
action = "pausemedia";
component = "mediacontrol";
command = ''date="$(date -u)"; notify-send "Drag Right" "$date"'';
};
description = "The action to perform on mouse drag right.";
apply = mouseDragRight: let
convertAction = action: component: "${component},${action}";
in lib.optionalAttrs (mouseDragRight != null) {
mouseDragRightAction = convertAction mouseDragRight.action mouseDragRight.component;
mouseDragRightCommand = mouseDragRight.command;
mouseDragRightAppUrl = mouseDragRight.appUrl;
};
};
longPress = mkOption {
type = types.nullOr actionType;
default = null;
example = {
action = "pausemedia";
component = "mediacontrol";
command = ''date="$(date -u)"; notify-send "Long Press" "$date"'';
};
description = "The action to perform on long press.";
apply = longPress: let
convertAction = action: component: "${component},${action}";
in lib.optionalAttrs (longPress != null) {
pressHoldAction = convertAction longPress.action longPress.component;
pressHoldCommand = longPress.command;
pressHoldAppUrl = longPress.appUrl;
};
};
};
troubleshooting = {
debugMessages.enable = mkOption {
type = types.nullOr types.bool;
default = null;
example = true;
description = "Whether to enable debug messages.";
};
};
settings = mkOption {
type = with types; nullOr (attrsOf (attrsOf (either (oneOf [ bool float int str ]) (listOf (oneOf [ bool float int str ])))));
default = null;
example = {
General = {
expanding = true;
};
};
description = ''
Extra configuration for the widget

See available options at https://github.com/antroids/application-title-bar/blob/main/package/contents/config/main.xml
'';
apply = settings: if settings == null then {} else settings;
};
};

convert =
{ expanding
, length
, highlight
, showTooltip
, scrollThreshold
, actions
, troubleshooting
, settings
}: {
name = "luisbocanegra.panelspacer.extended";
config = lib.recursiveUpdate {
General = lib.filterAttrs (_: v: v != null) (
{
inherit expanding length showTooltip;

showHoverBg = highlight.enable;
hoverBgRadius = highlight.radius;
bgFillPanel = highlight.fillPanel;

scrollSensitivity = scrollThreshold;

enableDebug = troubleshooting.debugMessages.enable;
}
// actions.singleClick
// actions.doubleClick
// actions.middleClick
// actions.mouseWheelUp
// actions.mouseWheelDown
// actions.mouseDragUp
// actions.mouseDragDown
// actions.mouseDragLeft
// actions.mouseDragRight
// actions.longPress
Comment on lines +310 to +319
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if // actions would work here.

);
} settings;
};
};
}
Loading