This commit is contained in:
ayushDumasia 2024-10-21 22:35:37 +05:30
parent b8de2e70f8
commit d1bbbcbb15
16 changed files with 1538 additions and 3 deletions

110
rofi/wifi/enable.rasi Normal file
View file

@ -0,0 +1,110 @@
/*****----- Configuration -----*****/
configuration {
show-icons: false;
}
/*****----- Global Properties -----*****/
* {
font: "JetBrains Mono Nerd Font 12";
background: #11111b;
background-alt: #313244;
foreground: #eff1f5;
selected: #cba6f7;
active: #6E77FF;
urgent: #8E3596;
}
/*****----- Main Window -----*****/
window {
transparency: "real";
location: center;
anchor: center;
fullscreen: false;
width: 320px;
x-offset: 0px;
y-offset: 0px;
/* properties for all widgets */
enabled: true;
border-radius: 8px;
cursor: "default";
background-color: @background;
}
/*****----- Main Box -----*****/
mainbox {
enabled: true;
spacing: 0px;
background-color: transparent;
orientation: horizontal;
children: [ "inputbar", "listview" ];
}
/*****----- Inputbar -----*****/
inputbar {
enabled: true;
spacing: 0px;
padding: 28px 0px 28px 24px;
background-color: transparent;
text-color: @foreground;
orientation: horizontal;
children: [ "textbox-prompt-colon" ];
}
textbox-prompt-colon {
enabled: true;
expand: false;
str: "";
padding: 12px 24px 12px 14px;
border-radius: 100%;
background-color: #a6e3a1;
text-color: @background;
}
/*****----- Listview -----*****/
listview {
enabled: true;
columns: 1;
lines: 1;
cycle: true;
dynamic: false;
scrollbar: false;
layout: vertical;
reverse: false;
spacing: 0px;
margin: 28px 24px;
border-radius: 8px;
background-color: #1e1e2e;
text-color: @foreground;
cursor: "default";
}
/*****----- Elements -----*****/
element {
enabled: true;
spacing: 0px;
padding: 12px 8px;
border-radius: 8px;
background-color: transparent;
text-color: @foreground;
cursor: pointer;
}
element selected.normal {
background-color: @selected;
text-color: @background;
}
element-icon {
background-color: transparent;
text-color: inherit;
size: 0px;
cursor: inherit;
}
element-text {
padding: 0px 16px;
background-color: transparent;
text-color: inherit;
cursor: inherit;
vertical-align: 0.5;
horizontal-align: 0;
}

126
rofi/wifi/list.rasi Normal file
View file

@ -0,0 +1,126 @@
/*****----- Configuration -----*****/
configuration {
show-icons: false;
}
/*****----- Global Properties -----*****/
* {
font: "JetBrains Mono Nerd Font 12";
background: #11111b;
background-alt: #313244;
foreground: #eff1f5;
selected: #cba6f7;
active: #6E77FF;
urgent: #8E3596;
}
/*****----- Main Window -----*****/
window {
transparency: "real";
location: center;
anchor: center;
fullscreen: false;
width: 500px;
x-offset: 0px;
y-offset: 0px;
/* properties for all widgets */
enabled: true;
border-radius: 8px;
cursor: "default";
background-color: @background;
}
/*****----- Main Box -----*****/
mainbox {
enabled: true;
spacing: 0px;
background-color: transparent;
orientation: vertical;
children: [ "inputbar", "listview" ];
}
/*****----- Inputbar -----*****/
inputbar {
enabled: true;
spacing: 0px;
padding: 28px 24px 0px 24px;
background-color: transparent;
text-color: @foreground;
orientation: horizontal;
children: [ "textbox-prompt-colon", "dummy", "entry" ];
}
dummy {
background-color: transparent;
}
entry {
enabled: true;
expand: false;
width: 250px;
padding: 12px 16px 8px 16px;
border-radius: 8px;
background-color: @background-alt;
text-color: inherit;
cursor: text;
placeholder: "Search";
placeholder-color: inherit;
}
textbox-prompt-colon {
enabled: true;
expand: false;
str: "";
padding: 12px 24px 12px 14px;
border-radius: 100%;
background-color: #a6e3a1;
text-color: @background;
}
/*****----- Listview -----*****/
listview {
enabled: true;
columns: 1;
lines: 5;
cycle: true;
dynamic: true;
scrollbar: false;
layout: vertical;
reverse: false;
fixed-height: true;
fixed-columns: true;
spacing: 0px;
margin: 32px 24px;
border-radius: 8px;
background-color: #1e1e2e;
text-color: @foreground;
cursor: "default";
}
/*****----- Elements -----*****/
element {
enabled: true;
spacing: 0px;
padding: 12px 8px;
border-radius: 8px;
background-color: transparent;
text-color: @foreground;
cursor: pointer;
}
element.selected {
background-color: @selected;
text-color: @background;
}
element-icon {
size: 0px;
}
element-text {
padding: 0px 16px;
background-color: transparent;
text-color: inherit;
cursor: inherit;
vertical-align: 0.5;
horizontal-align: 0;
}

90
rofi/wifi/password.rasi Normal file
View file

@ -0,0 +1,90 @@
/*****----- Configuration -----*****/
configuration {
show-icons: false;
}
/*****----- Global Properties -----*****/
* {
font: "JetBrains Mono Nerd Font 12";
background: #11111b;
background-alt: #313244;
foreground: #eff1f5;
selected: #cba6f7;
active: #6E77FF;
urgent: #8E3596;
}
/*****----- Main Window -----*****/
window {
width: 700px;
transparency: "real";
location: center;
anchor: center;
fullscreen: false;
x-offset: 0px;
y-offset: 0px;
/* properties for all widgets */
enabled: true;
border-radius: 8px;
padding: 24px;
cursor: "default";
background-color: @background;
}
/*****----- Main Box -----*****/
mainbox {
enabled: true;
spacing: 0px;
background-color: transparent;
orientation: vertical;
children: [ "inputbar" ];
}
/*****----- Inputbar -----*****/
inputbar {
enabled: true;
spacing: 16px;
padding: 0px;
background-color: transparent;
text-color: @foreground;
orientation: horizontal;
children: [ "textbox-prompt-colon", "prompt", "dummy", "entry" ];
}
entry {
enabled: true;
expand: false;
width: 300px;
padding: 12px 16px 8px 16px;
border-radius: 8px;
background-color: @background-alt;
text-color: inherit;
cursor: text;
placeholder: "Enter Password";
placeholder-color: inherit;
}
textbox-prompt-colon {
enabled: true;
expand: false;
str: "";
padding: 12px 24px 12px 14px;
border-radius: 100%;
background-color: #a6e3a1;
text-color: @background;
}
prompt {
enabled: true;
margin: 0px;
padding: 0px;
border-radius: 8px;
background-color: @background;
text-color: #a6e3a1;
vertical-align: 0.5;
}
dummy {
background-color: transparent;
}

90
rofi/wifi/ssid.rasi Normal file
View file

@ -0,0 +1,90 @@
/*****----- Configuration -----*****/
configuration {
show-icons: false;
}
/*****----- Global Properties -----*****/
* {
font: "JetBrains Mono Nerd Font 12";
background: #11111b;
background-alt: #313244;
foreground: #eff1f5;
selected: #cba6f7;
active: #6E77FF;
urgent: #8E3596;
}
/*****----- Main Window -----*****/
window {
width: 659px;
transparency: "real";
location: center;
anchor: center;
fullscreen: false;
x-offset: 0px;
y-offset: 0px;
/* properties for all widgets */
enabled: true;
border-radius: 8px;
padding: 24px;
cursor: "default";
background-color: @background;
}
/*****----- Main Box -----*****/
mainbox {
enabled: true;
spacing: 0px;
background-color: transparent;
orientation: vertical;
children: [ "inputbar" ];
}
/*****----- Inputbar -----*****/
inputbar {
enabled: true;
spacing: 16px;
padding: 0px;
background-color: transparent;
text-color: @foreground;
orientation: horizontal;
children: [ "textbox-prompt-colon", "prompt", "dummy", "entry" ];
}
entry {
enabled: true;
expand: false;
width: 300px;
padding: 12px 16px 8px 16px;
border-radius: 8px;
background-color: @background-alt;
text-color: inherit;
cursor: text;
placeholder: "Enter SSID";
placeholder-color: inherit;
}
textbox-prompt-colon {
enabled: true;
expand: false;
str: "";
padding: 12px 24px 12px 14px;
border-radius: 100%;
background-color: #a6e3a1;
text-color: @background;
}
prompt {
enabled: true;
margin: 0px;
padding: 0px;
border-radius: 8px;
background-color: @background;
text-color: #a6e3a1;
vertical-align: 0.5;
}
dummy {
background-color: transparent;
}

83
rofi/wifi/wifi.sh Executable file
View file

@ -0,0 +1,83 @@
#!/usr/bin/env bash
# Check if wifi is on
check_wifi_on=$( nmcli --field WIFI g | sed 1d | sed 's/ //g' )
# Get the SSID of the connected wifi network
connected_wifi=$( nmcli -t -f active,ssid device wifi | grep -i 'yes' | sed 's/yes://g' )
# Get the list of all avalaible wifi network
wifi_list=$( nmcli --fields "SECURITY,SSID" device wifi list | sed 1d | sed -E "s/WPA*.?//g"| sed "s/802.1X//g" | sed "s/^--/ /g" | sed "s/ //g" | sed "/--/d" | sed "s/ */ /g" | sed 's/[[:space:]]*$//' )
# Generate the string to pass on
if [ -z "$connected_wifi" ] ; then
string_to_pass=""
else
string_to_pass=" Connected to ${connected_wifi}\n"
fi
# Rofi skeleton for enable
enable_menu() {
rofi -markup-rows -dmenu -theme "$HOME/.config/rofi/wifi/enable.rasi"
}
# Rofi skeleton for list
list_menu() {
rofi -markup-rows -dmenu -theme "$HOME/.config/rofi/wifi/list.rasi"
}
# Rofi menu for wifi enable
enable_wifi() {
echo -e "󰤨 Enable Wifi" | enable_menu
}
# Rofi menu for the wifi list
list_wifi() {
echo -e "󰤭 Disable Wifi\n${string_to_pass} Manual Setup\n${wifi_list}" | list_menu
}
# Rofi menu for the details of the active connection
show_details() {
rofi -e "${details}"
}
# Rofi menu for the ssid
take_ssid() {
ssid=$( echo "" | rofi -dmenu -p "${choice}" -theme "$HOME/.config/rofi/wifi/ssid.rasi" )
}
# Rofi menu for the password
take_password() {
password=$( echo "" | rofi -dmenu -p "${choice}" -theme "$HOME/.config/rofi/wifi/password.rasi" )
}
# Show the menu accordingly
if [ "$check_wifi_on" == "enabled" ] ; then
choice=$(list_wifi)
else
choice=$(enable_wifi)
fi
# Remove the junk from the string
choice="${choice:4}"
# Perform tasks based on the choice
if [ "$choice" == "Enable Wifi" ] ; then
nmcli radio wifi on
elif [ "$choice" == "Disable Wifi" ] ; then
nmcli radio wifi off
elif [ "$choice" == "Manual Setup" ] ; then
take_ssid
if [[ "$ssid" != "" ]] ; then
take_password
nmcli device wifi connect "$ssid" hidden yes password "$password"
fi
elif [[ $choice =~ "Connected to" ]] ; then
kitty -e sh -c "nmcli dev wifi show-password; read -p 'Press Return to close...'"
elif [[ $choice != "" ]] ; then
take_password
nmcli device wifi connect "$choice" password "$password"
fi