Swayscript : Add vpn toggle.
This commit is contained in:
parent
eeb3f670a2
commit
fb328fa4cb
|
@ -3,10 +3,11 @@
|
|||
in {
|
||||
text = ''
|
||||
bindsym ${mod}+c exec 'systemctl reboot -i'
|
||||
bindsym ${mod}+g exec 'swayscript gamingtoggle'
|
||||
bindsym ${mod}+l exec 'powerlimit toggle'
|
||||
bindsym ${mod}+m exec 'swayscript montoggle'
|
||||
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}+z exec 'systemctl suspend -i'
|
||||
'';
|
||||
|
|
|
@ -134,7 +134,7 @@ in {
|
|||
exec = "swayscript monbar";
|
||||
interval = refreshInterval;
|
||||
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";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,44 +1,43 @@
|
|||
# TODO: Add different modes for different screens.
|
||||
{ ... }: {
|
||||
text = ''
|
||||
# Enable VRR.
|
||||
function vrron() {
|
||||
# Enable Gaming.
|
||||
function gamingon() {
|
||||
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 \"AOC 24G2W1G4 ATNL61A129625\" adaptive_sync on"
|
||||
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" mode 1920x1080@144.000Hz"
|
||||
_vrrstate on
|
||||
_gamingstate on
|
||||
}
|
||||
_sway_iterate_sockets on
|
||||
}
|
||||
|
||||
# Disable VRR.
|
||||
function vrroff() {
|
||||
# Disable Gaming.
|
||||
function gamingoff() {
|
||||
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 \"AOC 24G2W1G4 ATNL61A129625\" adaptive_sync off"
|
||||
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" mode 1920x1080@60.000Hz"
|
||||
_vrrstate off
|
||||
_gamingstate off
|
||||
}
|
||||
_sway_iterate_sockets off
|
||||
}
|
||||
|
||||
# Toggle VRR.
|
||||
function vrrtoggle() {
|
||||
if [[ "$(_vrrstate)" = "on" ]]; then
|
||||
vrroff
|
||||
# Toggle gaming.
|
||||
function gamingtoggle() {
|
||||
if [[ "$(_gamingstate)" = "on" ]]; then
|
||||
gamingoff
|
||||
else
|
||||
vrron
|
||||
gamingon
|
||||
fi
|
||||
}
|
||||
|
||||
function _vrrstate() {
|
||||
function _gamingstate() {
|
||||
if [[ "''${1}" = "" ]]; then
|
||||
cat /tmp/.vrrstate 2> /dev/null || echo off
|
||||
cat /tmp/.gamingstate 2> /dev/null || echo off
|
||||
else
|
||||
echo "''${*}" > /tmp/.vrrstate
|
||||
echo "''${*}" > /tmp/.gamingstate
|
||||
fi
|
||||
}
|
||||
'';
|
|
@ -33,14 +33,14 @@
|
|||
|
||||
function monbar() {
|
||||
local __monstate=$(_monstate)
|
||||
local __vrrstate=$(_vrrstate)
|
||||
local __gamingstate=$(_gamingstate)
|
||||
local class=""
|
||||
|
||||
if [[ "''${__monstate}" = "off" ]] || [[ "''${__vrrstate}" = "on" ]]; then
|
||||
if [[ "''${__monstate}" = "off" ]] || [[ "''${__gamingstate}" = "on" ]]; then
|
||||
class="modified"
|
||||
fi
|
||||
|
||||
printf "{\"text\": \"\", \"tooltip\": \"Mon: ''${__monstate^} / Vrr: ''${__vrrstate^}\", \"class\": \"''${class}\"}\n"
|
||||
printf "{\"text\": \"\", \"tooltip\": \"Monitor: ''${__monstate^} / Gaming: ''${__gamingstate^}\", \"class\": \"''${class}\"}\n"
|
||||
}
|
||||
|
||||
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