aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/modules/workstation/ui/i3/core/tools
diff options
context:
space:
mode:
Diffstat (limited to 'infra/libkookie/modules/workstation/ui/i3/core/tools')
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix8
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/tools/i3-move.nix17
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/tools/i3-rename.nix10
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/tools/i3-scrcap.nix10
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/tools/i3-switch.nix15
5 files changed, 60 insertions, 0 deletions
diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix
new file mode 100644
index 000000000000..40ce022c6144
--- /dev/null
+++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix
@@ -0,0 +1,8 @@
+{ pkgs, ... } @ args:
+
+{
+ libkookie-i3-move = (import ./i3-move.nix args);
+ libkookie-i3-switch = (import ./i3-switch.nix args);
+ libkookie-i3-rename = (import ./i3-rename.nix args);
+ libkookie-i3-scrcap = (import ./i3-scrcap.nix args);
+}
diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-move.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-move.nix
new file mode 100644
index 000000000000..1ba4a45bcab6
--- /dev/null
+++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-move.nix
@@ -0,0 +1,17 @@
+/** A utility script to move a window to a workspace
+ *
+ * This tool relies on i3-msg, jq, and dmenu to move a window to a
+ * different workspace. In the future, maybe the display mechanism
+ * (dmenu) could be made configurable, so not to rely on nazi code.
+ */
+
+{ pkgs, ... }: with pkgs; writeShellScript "libkookie-i3-move" ''
+
+ WS=$(${i3}/bin/i3-msg -t get_workspaces | \
+ ${jq}/bin/jq -M '.[] | .name' | tr -d '"' \
+ | sort -u | ${dmenu}/bin/dmenu -b -i "$@")
+
+
+ ${i3}/bin/i3-msg -t command move workspace $WS
+ ${i3}/bin/i3-msg workspace $WS
+''
diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-rename.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-rename.nix
new file mode 100644
index 000000000000..68bd32364452
--- /dev/null
+++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-rename.nix
@@ -0,0 +1,10 @@
+/** A utility to rename the current workspace
+ *
+ * This tool relies on i3-msg, jq, and dmenu to move a window to a
+ * different workspace. In the future, maybe the display mechanism
+ * (dmenu) could be made configurable, so not to rely on nazi code.
+ */
+
+{ pkgs, ... }: with pkgs; writeShellScript "libkookie-i3-rename" ''
+ exec i3-input -F 'rename workspace to \"%s\"' -P 'New name: '
+''
diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-scrcap.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-scrcap.nix
new file mode 100644
index 000000000000..6146dabee67a
--- /dev/null
+++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-scrcap.nix
@@ -0,0 +1,10 @@
+/** A utility script to take screenshots
+ *
+ * This tool relies on scrot to take screenshot, independent of a
+ * complete windowing compositor running. gnome-screenshot was
+ * used in the past, but has weird behaviour on non-gnome systems.
+ */
+
+{ pkgs, ... }: with pkgs; writeShellScript "libkookie-i3-move" ''
+ ${scrot}/bin/scrot -s
+''
diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-switch.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-switch.nix
new file mode 100644
index 000000000000..691e9470db83
--- /dev/null
+++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-switch.nix
@@ -0,0 +1,15 @@
+/** A utility script to switch to a workspace
+ *
+ * This tool relies on i3-msg, jq, and dmenu to switch to a different
+ * workspace. In the future, maybe the display mechanism (dmenu)
+ * could be made configurable, so not to rely on nazi code.
+ */
+
+{ pkgs, ... }: with pkgs; writeShellScript "libkookie-i3-switch" ''
+
+ WS=$(${i3}/bin/i3-msg -t get_workspaces | \
+ ${jq}/bin/jq -M '.[] | .name' | tr -d '"' \
+ | sort -u | ${dmenu}/bin/dmenu -b -i "$@")
+
+ ${i3}/bin/i3-msg workspace $WS
+''