Skip to content

Instantly share code, notes, and snippets.

@moetelo
Last active September 20, 2023 09:50
Show Gist options
  • Save moetelo/84c8bc791f9db5de379857953410500d to your computer and use it in GitHub Desktop.
Save moetelo/84c8bc791f9db5de379857953410500d to your computer and use it in GitHub Desktop.
Toggles proxy in kde5 assuming that proxy settings are set up.
#!/bin/bash
# Get the current proxy type
current_proxy_type=$(kreadconfig5 --file kioslaverc --group "Proxy Settings" --key ProxyType)
if [ $? -ne 0 ]; then
echo "Failed to execute kreadconfig5"
exit 1
fi
# Toggle the proxy type
toggled_proxy_type=$((current_proxy_type == 1 ? 0 : 1))
# Update the proxy type
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key ProxyType "$toggled_proxy_type"
if [ $? -ne 0 ]; then
echo "kwriteconfig5 error"
exit 1
fi
echo "$toggled_proxy_type"
@moetelo
Copy link
Author

moetelo commented Sep 20, 2023

sudo sh -c "curl -sS https://gist.githubusercontent.com/Shifu462/84c8bc791f9db5de379857953410500d/raw/proxy-toggle.sh > /usr/bin/proxy-toggle"
chmod +x /usr/bin/proxy-toggle

# usage
proxy-toggle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment