From 8f3899b7bf6a30e1af09fbbd239a97b8edf75495 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Sat, 30 Mar 2024 02:36:34 +0300 Subject: [PATCH] Sway : Replace bin dir with shell functions and dmenu support. --- module/Sway.nix | 3 +-- module/common/Monitor.sh | 9 +++++++++ module/common/bash/module/Dmenu.sh | 5 +++++ module/common/bash/module/Network.sh | 9 +++++++++ module/common/bash/module/Sound.sh | 4 ++++ module/common/bash/module/Vrr.sh | 9 +++++++++ module/sway/bin/bluetooth | 3 --- module/sway/bin/bye | 3 --- module/sway/bin/monoff | 3 --- module/sway/bin/monon | 3 --- module/sway/bin/network | 3 --- module/sway/bin/slp | 3 --- module/sway/bin/sound | 3 --- module/sway/bin/vrroff | 3 --- module/sway/bin/vrron | 3 --- module/sway/module/10-Launcher | 2 +- 16 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 module/common/Monitor.sh create mode 100644 module/common/bash/module/Dmenu.sh create mode 100644 module/common/bash/module/Network.sh create mode 100644 module/common/bash/module/Sound.sh create mode 100644 module/common/bash/module/Vrr.sh delete mode 100755 module/sway/bin/bluetooth delete mode 100755 module/sway/bin/bye delete mode 100755 module/sway/bin/monoff delete mode 100755 module/sway/bin/monon delete mode 100755 module/sway/bin/network delete mode 100755 module/sway/bin/slp delete mode 100755 module/sway/bin/sound delete mode 100755 module/sway/bin/vrroff delete mode 100755 module/sway/bin/vrron diff --git a/module/Sway.nix b/module/Sway.nix index bf3459c..8838844 100644 --- a/module/Sway.nix +++ b/module/Sway.nix @@ -35,8 +35,7 @@ variables = { FOOT_CONFIG = ./foot/Foot.ini; SWAY_CONFIG = ./sway/module; - PATH = [ "/etc/swaybin" ]; + # PATH = [ "/etc/swaybin" ]; # NOTE: Kept as an example on PATH modification. }; - etc.swaybin.source = ./sway/bin; }; } diff --git a/module/common/Monitor.sh b/module/common/Monitor.sh new file mode 100644 index 0000000..961329e --- /dev/null +++ b/module/common/Monitor.sh @@ -0,0 +1,9 @@ +# Enable monitors. +function monon() { + swaymsg 'output "ASUSTek COMPUTER INC ASUS VA24E R2LMTF127165" power on' +} + +# Disable monitors. +function monoff() { + swaymsg 'output "ASUSTek COMPUTER INC ASUS VA24E R2LMTF127165" power off' +} diff --git a/module/common/bash/module/Dmenu.sh b/module/common/bash/module/Dmenu.sh new file mode 100644 index 0000000..bb37cdd --- /dev/null +++ b/module/common/bash/module/Dmenu.sh @@ -0,0 +1,5 @@ +# Wrapped dmenu_path to include my functions. +function _dmenu_path_wrapped() { + dmenu_path + find_function | grep -v ^_ +} diff --git a/module/common/bash/module/Network.sh b/module/common/bash/module/Network.sh new file mode 100644 index 0000000..be49f9e --- /dev/null +++ b/module/common/bash/module/Network.sh @@ -0,0 +1,9 @@ +# Open bluetooth control panel. +function bluetooth() { + blueman-manager +} + +# Open network control panel. +function network() { + nm-connection-editor +} diff --git a/module/common/bash/module/Sound.sh b/module/common/bash/module/Sound.sh new file mode 100644 index 0000000..8b5d9bd --- /dev/null +++ b/module/common/bash/module/Sound.sh @@ -0,0 +1,4 @@ +# Open a sound control panel. +function sound() { + pavucontrol +} diff --git a/module/common/bash/module/Vrr.sh b/module/common/bash/module/Vrr.sh new file mode 100644 index 0000000..d60eb8d --- /dev/null +++ b/module/common/bash/module/Vrr.sh @@ -0,0 +1,9 @@ +# Enable VRR. +function vrron() { + swaymsg 'output "Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622" adaptive_sync on' +} + +# Disable VRR. +function vrroff() { + swaymsg 'output "Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622" adaptive_sync off' +} diff --git a/module/sway/bin/bluetooth b/module/sway/bin/bluetooth deleted file mode 100755 index 9a8ff53..0000000 --- a/module/sway/bin/bluetooth +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -blueman-manager diff --git a/module/sway/bin/bye b/module/sway/bin/bye deleted file mode 100755 index 2b114db..0000000 --- a/module/sway/bin/bye +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -poweroff diff --git a/module/sway/bin/monoff b/module/sway/bin/monoff deleted file mode 100755 index 3fab0f5..0000000 --- a/module/sway/bin/monoff +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -swaymsg 'output "ASUSTek COMPUTER INC ASUS VA24E R2LMTF127165" power off' diff --git a/module/sway/bin/monon b/module/sway/bin/monon deleted file mode 100755 index 53bbe88..0000000 --- a/module/sway/bin/monon +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -swaymsg 'output "ASUSTek COMPUTER INC ASUS VA24E R2LMTF127165" power on' diff --git a/module/sway/bin/network b/module/sway/bin/network deleted file mode 100755 index 0f1a80b..0000000 --- a/module/sway/bin/network +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -nm-connection-editor diff --git a/module/sway/bin/slp b/module/sway/bin/slp deleted file mode 100755 index f0ec081..0000000 --- a/module/sway/bin/slp +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -systemctl suspend diff --git a/module/sway/bin/sound b/module/sway/bin/sound deleted file mode 100755 index c44ccea..0000000 --- a/module/sway/bin/sound +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -pavucontrol diff --git a/module/sway/bin/vrroff b/module/sway/bin/vrroff deleted file mode 100755 index 475f9f4..0000000 --- a/module/sway/bin/vrroff +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -swaymsg 'output "Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622" adaptive_sync off' diff --git a/module/sway/bin/vrron b/module/sway/bin/vrron deleted file mode 100755 index dca0bda..0000000 --- a/module/sway/bin/vrron +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -swaymsg 'output "Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622" adaptive_sync on' diff --git a/module/sway/module/10-Launcher b/module/sway/module/10-Launcher index e8b6bb9..29d2e65 100644 --- a/module/sway/module/10-Launcher +++ b/module/sway/module/10-Launcher @@ -1,4 +1,4 @@ # Application launcher. # Note: pass the final command to swaymsg so that the resulting window can be opened # on the original workspace that the command was run on. -set $menu dmenu_path | wmenu -S d79921 -s 000000 -f "SF Pro Display Medium 14" | xargs swaymsg exec -- +set $menu _dmenu_path_wrapped | wmenu -S d79921 -s 000000 -f "SF Pro Display Medium 14" | xargs swaymsg exec --