Swayscript : Add vpn toggle.
This commit is contained in:
parent
eeb3f670a2
commit
fb328fa4cb
|
@ -3,10 +3,11 @@
|
||||||
in {
|
in {
|
||||||
text = ''
|
text = ''
|
||||||
bindsym ${mod}+c exec 'systemctl reboot -i'
|
bindsym ${mod}+c exec 'systemctl reboot -i'
|
||||||
|
bindsym ${mod}+g exec 'swayscript gamingtoggle'
|
||||||
bindsym ${mod}+l exec 'powerlimit toggle'
|
bindsym ${mod}+l exec 'powerlimit toggle'
|
||||||
bindsym ${mod}+m exec 'swayscript montoggle'
|
bindsym ${mod}+m exec 'swayscript montoggle'
|
||||||
bindsym ${mod}+p exec 'powersave toggle'
|
bindsym ${mod}+p exec 'powersave toggle'
|
||||||
bindsym ${mod}+v exec 'swayscript vrrtoggle'
|
bindsym ${mod}+v exec 'swayscript vpntoggle'
|
||||||
bindsym ${mod}+x exec 'systemctl poweroff -i'
|
bindsym ${mod}+x exec 'systemctl poweroff -i'
|
||||||
bindsym ${mod}+z exec 'systemctl suspend -i'
|
bindsym ${mod}+z exec 'systemctl suspend -i'
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -134,7 +134,7 @@ in {
|
||||||
exec = "swayscript monbar";
|
exec = "swayscript monbar";
|
||||||
interval = refreshInterval;
|
interval = refreshInterval;
|
||||||
on-click = "sleep 0.1 && swayscript montoggle"; # FIXME: remove sleep when resolved: https://github.com/Alexays/Waybar/issues/216
|
on-click = "sleep 0.1 && swayscript montoggle"; # FIXME: remove sleep when resolved: https://github.com/Alexays/Waybar/issues/216
|
||||||
on-click-right = "sleep 0.1 && swayscript vrrtoggle";
|
on-click-right = "sleep 0.1 && swayscript gamingtoggle";
|
||||||
return-type = "json";
|
return-type = "json";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,44 +1,43 @@
|
||||||
# TODO: Add different modes for different screens.
|
|
||||||
{ ... }: {
|
{ ... }: {
|
||||||
text = ''
|
text = ''
|
||||||
# Enable VRR.
|
# Enable Gaming.
|
||||||
function vrron() {
|
function gamingon() {
|
||||||
on() {
|
on() {
|
||||||
swaymsg "output \"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622\" adaptive_sync on"
|
swaymsg "output \"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622\" adaptive_sync on"
|
||||||
swaymsg "output \"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622\" mode 3440x1440@164.999Hz"
|
swaymsg "output \"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622\" mode 3440x1440@164.999Hz"
|
||||||
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" adaptive_sync on"
|
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" adaptive_sync on"
|
||||||
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" mode 1920x1080@144.000Hz"
|
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" mode 1920x1080@144.000Hz"
|
||||||
_vrrstate on
|
_gamingstate on
|
||||||
}
|
}
|
||||||
_sway_iterate_sockets on
|
_sway_iterate_sockets on
|
||||||
}
|
}
|
||||||
|
|
||||||
# Disable VRR.
|
# Disable Gaming.
|
||||||
function vrroff() {
|
function gamingoff() {
|
||||||
off() {
|
off() {
|
||||||
swaymsg "output \"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622\" adaptive_sync off"
|
swaymsg "output \"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622\" adaptive_sync off"
|
||||||
swaymsg "output \"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622\" mode 3440x1440@59.973Hz"
|
swaymsg "output \"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622\" mode 3440x1440@59.973Hz"
|
||||||
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" adaptive_sync off"
|
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" adaptive_sync off"
|
||||||
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" mode 1920x1080@60.000Hz"
|
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" mode 1920x1080@60.000Hz"
|
||||||
_vrrstate off
|
_gamingstate off
|
||||||
}
|
}
|
||||||
_sway_iterate_sockets off
|
_sway_iterate_sockets off
|
||||||
}
|
}
|
||||||
|
|
||||||
# Toggle VRR.
|
# Toggle gaming.
|
||||||
function vrrtoggle() {
|
function gamingtoggle() {
|
||||||
if [[ "$(_vrrstate)" = "on" ]]; then
|
if [[ "$(_gamingstate)" = "on" ]]; then
|
||||||
vrroff
|
gamingoff
|
||||||
else
|
else
|
||||||
vrron
|
gamingon
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _vrrstate() {
|
function _gamingstate() {
|
||||||
if [[ "''${1}" = "" ]]; then
|
if [[ "''${1}" = "" ]]; then
|
||||||
cat /tmp/.vrrstate 2> /dev/null || echo off
|
cat /tmp/.gamingstate 2> /dev/null || echo off
|
||||||
else
|
else
|
||||||
echo "''${*}" > /tmp/.vrrstate
|
echo "''${*}" > /tmp/.gamingstate
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
'';
|
'';
|
|
@ -33,14 +33,14 @@
|
||||||
|
|
||||||
function monbar() {
|
function monbar() {
|
||||||
local __monstate=$(_monstate)
|
local __monstate=$(_monstate)
|
||||||
local __vrrstate=$(_vrrstate)
|
local __gamingstate=$(_gamingstate)
|
||||||
local class=""
|
local class=""
|
||||||
|
|
||||||
if [[ "''${__monstate}" = "off" ]] || [[ "''${__vrrstate}" = "on" ]]; then
|
if [[ "''${__monstate}" = "off" ]] || [[ "''${__gamingstate}" = "on" ]]; then
|
||||||
class="modified"
|
class="modified"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "{\"text\": \"\", \"tooltip\": \"Mon: ''${__monstate^} / Vrr: ''${__vrrstate^}\", \"class\": \"''${class}\"}\n"
|
printf "{\"text\": \"\", \"tooltip\": \"Monitor: ''${__monstate^} / Gaming: ''${__gamingstate^}\", \"class\": \"''${class}\"}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _monstate() {
|
function _monstate() {
|
||||||
|
|
29
package/swayscript/script/Vpn.nix
Normal file
29
package/swayscript/script/Vpn.nix
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{ ... }: {
|
||||||
|
text = ''
|
||||||
|
# Enable VPN.
|
||||||
|
function vpnon() {
|
||||||
|
nmcli connection up vpn
|
||||||
|
_vpnstate on
|
||||||
|
}
|
||||||
|
|
||||||
|
# Disable vpn.
|
||||||
|
function vpnoff() {
|
||||||
|
nmcli connection down vpn
|
||||||
|
_vpnstate off
|
||||||
|
}
|
||||||
|
|
||||||
|
# Toggle vpn.
|
||||||
|
function vpntoggle() {
|
||||||
|
if [[ "$(_vpnstate)" = "on" ]]; then
|
||||||
|
vpnoff
|
||||||
|
else
|
||||||
|
vpnon
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function _vpnstate() {
|
||||||
|
local state=$(nmcli connection show vpn | rg -i state.*activated)
|
||||||
|
[ "''${state}" != "" ] && printf on || printf off
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue