mirror of
https://github.imc.re/void-land/hyprland-void-dots
synced 2025-06-07 09:43:43 +02:00
feat: dns changer shell
This commit is contained in:
parent
a85926d2e4
commit
151a590093
3 changed files with 55 additions and 8 deletions
53
dots/zsh/.sh_custom/dns-changer.sh
Executable file
53
dots/zsh/.sh_custom/dns-changer.sh
Executable file
|
@ -0,0 +1,53 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
declare -A dns_servers=(
|
||||||
|
["Google"]="8.8.8.8,8.8.4.4"
|
||||||
|
["Cloudflare"]="1.1.1.1"
|
||||||
|
["403"]="10.202.10.202,10.202.10.102"
|
||||||
|
["Shecan"]="178.22.122.100,185.51.200.2"
|
||||||
|
)
|
||||||
|
|
||||||
|
display_dns_list() {
|
||||||
|
echo "Available DNS Servers:"
|
||||||
|
i=1
|
||||||
|
for dns_name in "${!dns_servers[@]}"; do
|
||||||
|
echo "$i. ${dns_name}"
|
||||||
|
((i++))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
select_dns() {
|
||||||
|
read -p "Select a DNS server (enter the name or number): " selected_input
|
||||||
|
|
||||||
|
if [[ $selected_input =~ ^[0-9]+$ ]]; then
|
||||||
|
if ((selected_input >= 1 && selected_input <= ${#dns_servers[@]})); then
|
||||||
|
selected_name=$(echo "${!dns_servers[@]}" | cut -d ' ' -f $selected_input)
|
||||||
|
selected_dns=${dns_servers[$selected_name]}
|
||||||
|
echo "Selected DNS server: $selected_dns"
|
||||||
|
else
|
||||||
|
echo "Invalid number. Please select a valid number."
|
||||||
|
select_dns
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ -n ${dns_servers[$selected_input]} ]]; then
|
||||||
|
selected_dns=${dns_servers[$selected_input]}
|
||||||
|
echo "Selected DNS server: $selected_dns"
|
||||||
|
else
|
||||||
|
echo "Invalid name. Please select a valid name."
|
||||||
|
select_dns
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
update_resolv_conf() {
|
||||||
|
sudo sh -c "echo '' > /etc/resolv.conf"
|
||||||
|
IFS=',' read -ra dns_array <<<"$1"
|
||||||
|
for dns in "${dns_array[@]}"; do
|
||||||
|
echo "nameserver $dns" | sudo tee -a /etc/resolv.conf >/dev/null
|
||||||
|
done
|
||||||
|
echo "Updated /etc/resolv.conf with DNS servers: $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
display_dns_list
|
||||||
|
select_dns
|
||||||
|
update_resolv_conf "$selected_dns"
|
|
@ -17,6 +17,7 @@ alias yo="echo '¯\_(ツ)_/¯'"
|
||||||
alias hardware="inxi -b"
|
alias hardware="inxi -b"
|
||||||
alias psfind="ps -aux | grep"
|
alias psfind="ps -aux | grep"
|
||||||
alias edit-dns="sudo nano /etc/resolv.conf"
|
alias edit-dns="sudo nano /etc/resolv.conf"
|
||||||
|
alias dns-changer="sudo $DNS_CHANGER"
|
||||||
alias mpv='mpvpaper "*" -o "no-audio --loop-playlist shuffle" ~/Wallpapers/Live'
|
alias mpv='mpvpaper "*" -o "no-audio --loop-playlist shuffle" ~/Wallpapers/Live'
|
||||||
|
|
||||||
# directories :
|
# directories :
|
||||||
|
|
|
@ -3,18 +3,11 @@ export ZELLIJ_START=false
|
||||||
export ZSH="$HOME/.oh-my-zsh"
|
export ZSH="$HOME/.oh-my-zsh"
|
||||||
export OS_ID="$(grep -i -w 'ID=' /etc/os-release | awk -F= '{print $2}')"
|
export OS_ID="$(grep -i -w 'ID=' /etc/os-release | awk -F= '{print $2}')"
|
||||||
export OS="$(grep -i -w "ID=" /etc/os-release | grep -oP '(?<=")[^"]*')"
|
export OS="$(grep -i -w "ID=" /etc/os-release | grep -oP '(?<=")[^"]*')"
|
||||||
|
|
||||||
# nekoray :
|
|
||||||
export NEKORAY_PATH=/opt/nekoray/nekoray
|
export NEKORAY_PATH=/opt/nekoray/nekoray
|
||||||
|
|
||||||
# vscode :
|
|
||||||
export CODE_PATH=/opt/vscode/code
|
export CODE_PATH=/opt/vscode/code
|
||||||
|
|
||||||
# dotfiles :
|
|
||||||
export DOTFILES=$HOME/.dots-hyprland
|
export DOTFILES=$HOME/.dots-hyprland
|
||||||
|
|
||||||
# void packages :
|
|
||||||
export VOID_PACKAGES_PATH=$HOME/.local/pkgs/void-packages
|
export VOID_PACKAGES_PATH=$HOME/.local/pkgs/void-packages
|
||||||
|
export DNS_CHANGER=$HOME/.sh_custom/dns-changer.sh
|
||||||
|
|
||||||
# adb :
|
# adb :
|
||||||
if [ -d "$HOME/platform-tools" ]; then
|
if [ -d "$HOME/platform-tools" ]; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue