diff options
| author | Shubham Saini <shubham6405@gmail.com> | 2019-12-02 12:21:04 +0000 |
|---|---|---|
| committer | Shubham Saini <shubham6405@gmail.com> | 2019-12-02 12:21:04 +0000 |
| commit | a42df546ce34429759a20bc2c4c240de045dbd0a (patch) | |
| tree | 4e7153d41d6a1b710f8002f2eb7b64231889b6cf /rofi | |
using stow
Diffstat (limited to 'rofi')
| -rw-r--r-- | rofi/.config/rofi/config | 11 | ||||
| -rwxr-xr-x | rofi/.config/rofi/rofi-power.sh | 38 | ||||
| -rwxr-xr-x | rofi/.config/rofi/rofi-wifi.sh | 108 | ||||
| -rw-r--r-- | rofi/.config/rofi/wifi | 19 |
4 files changed, 176 insertions, 0 deletions
diff --git a/rofi/.config/rofi/config b/rofi/.config/rofi/config new file mode 100644 index 0000000..b096ad7 --- /dev/null +++ b/rofi/.config/rofi/config | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | rofi.theme: ~/.cache/wal/colors-rofi-dark.rasi | ||
| 2 | rofi.lines: 6 | ||
| 3 | !rofi.separator-style: none | ||
| 4 | !rofi.columns: 1 | ||
| 5 | rofi.font: Hermit 12 | ||
| 6 | !rofi.bw: 0 | ||
| 7 | !rofi.eh: 2 | ||
| 8 | !rofi.hide-scrollbar: true | ||
| 9 | rofi.auto-select: false | ||
| 10 | !rofi.display-drun:? | ||
| 11 | |||
diff --git a/rofi/.config/rofi/rofi-power.sh b/rofi/.config/rofi/rofi-power.sh new file mode 100755 index 0000000..2b6f3ab --- /dev/null +++ b/rofi/.config/rofi/rofi-power.sh | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | |||
| 3 | OPTIONS="Reboot\nShut-down\nSuspend\nLock" | ||
| 4 | |||
| 5 | # source configuration or use default values | ||
| 6 | LAUNCHER="rofi -location 5 -width 15 -lines 4 -dmenu -i -p power -show-icons " | ||
| 7 | USE_LOCKER="true" | ||
| 8 | LOCKER="/home/ssaini/.config/lock.sh" | ||
| 9 | |||
| 10 | |||
| 11 | # Show exit wm option if exit command is provided as an argument | ||
| 12 | if [ ${#1} -gt 0 ]; then | ||
| 13 | OPTIONS="Exit window manager\n$OPTIONS" | ||
| 14 | fi | ||
| 15 | |||
| 16 | option=`echo -e $OPTIONS | $LAUNCHER | awk '{print $1}' | tr -d '\r\n'` | ||
| 17 | if [ ${#option} -gt 0 ] | ||
| 18 | then | ||
| 19 | case $option in | ||
| 20 | Exit) | ||
| 21 | eval $1 | ||
| 22 | ;; | ||
| 23 | Reboot) | ||
| 24 | sudo reboot | ||
| 25 | ;; | ||
| 26 | Shut-down) | ||
| 27 | sudo poweroff | ||
| 28 | ;; | ||
| 29 | Suspend) | ||
| 30 | sudo zzz | ||
| 31 | ;; | ||
| 32 | Lock) | ||
| 33 | /home/ssaini/.config/lock.sh | ||
| 34 | ;; | ||
| 35 | *) | ||
| 36 | ;; | ||
| 37 | esac | ||
| 38 | fi | ||
diff --git a/rofi/.config/rofi/rofi-wifi.sh b/rofi/.config/rofi/rofi-wifi.sh new file mode 100755 index 0000000..938fa48 --- /dev/null +++ b/rofi/.config/rofi/rofi-wifi.sh | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | |||
| 3 | # Starts a scan of available broadcasting SSIDs | ||
| 4 | # nmcli dev wifi rescan | ||
| 5 | |||
| 6 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| 7 | |||
| 8 | FIELDS=SSID,SECURITY | ||
| 9 | POSITION=5 | ||
| 10 | #YOFF=-40 | ||
| 11 | #XOFF=-120 | ||
| 12 | FONT="Hermit 10" | ||
| 13 | |||
| 14 | if [ -r "$DIR/config" ]; then | ||
| 15 | source ./config | ||
| 16 | elif [ -r "~/.config/rofi/config" ]; then | ||
| 17 | source "~/.config/rofi/config" | ||
| 18 | else | ||
| 19 | echo "WARNING: config file not found! Using default values." | ||
| 20 | fi | ||
| 21 | |||
| 22 | LIST=$(nmcli --fields "$FIELDS" device wifi list | sed '/^--/d') | ||
| 23 | # For some reason rofi always approximates character width 2 short... hmmm | ||
| 24 | RWIDTH=$(($(echo "$LIST" | head -n 1 | awk '{print length($0); }')+2)) | ||
| 25 | # Dynamically change the height of the rofi menu | ||
| 26 | LINENUM=$(echo "$LIST" | wc -l) | ||
| 27 | # Gives a list of known connections so we. can parse it later | ||
| 28 | KNOWNCON=$(nmcli connection show) | ||
| 29 | # Really janky way of telling if there is currently a connection | ||
| 30 | CONSTATE=$(nmcli -fields WIFI g) | ||
| 31 | |||
| 32 | CURRSSID=$(iwgetid -r) | ||
| 33 | |||
| 34 | if [[ ! -z $CURRSSID ]]; then | ||
| 35 | HIGHLINE=$(echo "$(echo "$LIST" | awk -F "[ ]{2,}" '{print $1}' | grep -Fxn -m 1 "$CURRSSID" | awk -F ":" '{print $1}') + 1" | bc ) | ||
| 36 | fi | ||
| 37 | |||
| 38 | # HOPEFULLY you won't need this as often as I do | ||
| 39 | # If there are more than 8 SSIDs, the menu will still only have 8 lines | ||
| 40 | if [ "$LINENUM" -gt 8 ] && [[ "$CONSTATE" =~ "enabled" ]]; then | ||
| 41 | LINENUM=8 | ||
| 42 | elif [[ "$CONSTATE" =~ "disabled" ]]; then | ||
| 43 | LINENUM=1 | ||
| 44 | fi | ||
| 45 | |||
| 46 | |||
| 47 | if [[ "$CONSTATE" =~ "enabled" ]]; then | ||
| 48 | TOGGLE="toggle off" | ||
| 49 | elif [[ "$CONSTATE" =~ "disabled" ]]; then | ||
| 50 | TOGGLE="toggle on" | ||
| 51 | fi | ||
| 52 | |||
| 53 | eval FIELDSARR=( $(cat ./config | awk 'BEGIN { FS=","; OFS="\n" } /^FIELDS/ { $1 = substr($1, 8); print $0; }') ) | ||
| 54 | |||
| 55 | for i in "${!FIELDSARR[@]}"; do | ||
| 56 | if [[ "${FIELDSARR[$i]}" = "SSID" ]]; then | ||
| 57 | SSID_POS="${i}"; | ||
| 58 | fi | ||
| 59 | done | ||
| 60 | |||
| 61 | let AWKSSIDPOS=$SSID_POS+1 | ||
| 62 | |||
| 63 | CHENTRY=$(echo -e "$TOGGLE\nmanual\n$LIST" | uniq -u | rofi -dmenu -p "Wi-Fi SSID: " -lines "$LINENUM" -a "$HIGHLINE" -location "$POSITION" -yoffset "$YOFF" -xoffset "$XOFF" -font "$FONT" -width -"$RWIDTH") | ||
| 64 | #echo "$CHENTRY" | ||
| 65 | CHSSID=$(echo "$CHENTRY" | sed 's/\s\{2,\}/\|/g' | awk -F "|" '{print $'$AWKSSIDPOS'}') | ||
| 66 | #echo "$CHSSID" | ||
| 67 | |||
| 68 | # If the user inputs "manual" as their SSID in the start window, it will bring them to this screen | ||
| 69 | if [ "$CHENTRY" = "manual" ] ; then | ||
| 70 | # Manual entry of the SSID and password (if appplicable) | ||
| 71 | MSSID=$(echo "enter the SSID of the network (SSID,password)" | rofi -dmenu -p "Manual Entry: " -font "$FONT" -lines 1) | ||
| 72 | # Separating the password from the entered string | ||
| 73 | MPASS=$(echo "$MSSID" | awk -F "," '{print $2}') | ||
| 74 | |||
| 75 | #echo "$MSSID" | ||
| 76 | #echo "$MPASS" | ||
| 77 | |||
| 78 | # If the user entered a manual password, then use the password nmcli command | ||
| 79 | if [ "$MPASS" = "" ]; then | ||
| 80 | nmcli dev wifi con "$MSSID" | ||
| 81 | else | ||
| 82 | nmcli dev wifi con "$MSSID" password "$MPASS" | ||
| 83 | fi | ||
| 84 | |||
| 85 | elif [ "$CHENTRY" = "toggle on" ]; then | ||
| 86 | nmcli radio wifi on | ||
| 87 | |||
| 88 | elif [ "$CHENTRY" = "toggle off" ]; then | ||
| 89 | nmcli radio wifi off | ||
| 90 | |||
| 91 | else | ||
| 92 | |||
| 93 | # If the connection is already in use, then this will still be able to get the SSID | ||
| 94 | if [ "$CHSSID" = "*" ]; then | ||
| 95 | CHSSID=$(echo "$CHENTRY" | sed 's/\s\{2,\}/\|/g' | awk -F "|" '{print $3}') | ||
| 96 | fi | ||
| 97 | |||
| 98 | # Parses the list of preconfigured connections to see if it already contains the chosen SSID. This speeds up the connection process | ||
| 99 | if [[ $(echo "$KNOWNCON" | grep "$CHSSID") = "$CHSSID" ]]; then | ||
| 100 | nmcli con up "$CHSSID" | ||
| 101 | else | ||
| 102 | if [[ "$CHENTRY" =~ "WPA2" ]] || [[ "$CHENTRY" =~ "WEP" ]]; then | ||
| 103 | WIFIPASS=$(echo "if connection is stored, hit enter" | rofi -dmenu -p "password: " -lines 1 -font "$FONT" ) | ||
| 104 | fi | ||
| 105 | nmcli dev wifi con "$CHSSID" password "$WIFIPASS" | ||
| 106 | fi | ||
| 107 | |||
| 108 | fi | ||
diff --git a/rofi/.config/rofi/wifi b/rofi/.config/rofi/wifi new file mode 100644 index 0000000..954e4ae --- /dev/null +++ b/rofi/.config/rofi/wifi | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | # Config for rofi-wifi-menu | ||
| 2 | |||
| 3 | # position values: | ||
| 4 | # 1 2 3 | ||
| 5 | # 8 0 4 | ||
| 6 | # 7 6 5 | ||
| 7 | POSITION=3 | ||
| 8 | |||
| 9 | #y-offset | ||
| 10 | YOFF=17 | ||
| 11 | |||
| 12 | #x-offset | ||
| 13 | XOFF=0 | ||
| 14 | |||
| 15 | #fields to be displayed | ||
| 16 | FIELDS=SSID,SECURITY,BARS | ||
| 17 | |||
| 18 | #font | ||
| 19 | FONT="Source Code Pro 12" | ||
