summaryrefslogtreecommitdiff
path: root/rofi/.config
diff options
context:
space:
mode:
authorShubham Saini <shubham6405@gmail.com>2019-12-02 12:21:04 +0000
committerShubham Saini <shubham6405@gmail.com>2019-12-02 12:21:04 +0000
commita42df546ce34429759a20bc2c4c240de045dbd0a (patch)
tree4e7153d41d6a1b710f8002f2eb7b64231889b6cf /rofi/.config
using stow
Diffstat (limited to 'rofi/.config')
-rw-r--r--rofi/.config/rofi/config11
-rwxr-xr-xrofi/.config/rofi/rofi-power.sh38
-rwxr-xr-xrofi/.config/rofi/rofi-wifi.sh108
-rw-r--r--rofi/.config/rofi/wifi19
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 @@
1rofi.theme: ~/.cache/wal/colors-rofi-dark.rasi
2rofi.lines: 6
3!rofi.separator-style: none
4!rofi.columns: 1
5rofi.font: Hermit 12
6!rofi.bw: 0
7!rofi.eh: 2
8!rofi.hide-scrollbar: true
9rofi.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
3OPTIONS="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
12if [ ${#1} -gt 0 ]; then
13 OPTIONS="Exit window manager\n$OPTIONS"
14fi
15
16option=`echo -e $OPTIONS | $LAUNCHER | awk '{print $1}' | tr -d '\r\n'`
17if [ ${#option} -gt 0 ]
18then
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
38fi
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
6DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7
8FIELDS=SSID,SECURITY
9POSITION=5
10#YOFF=-40
11#XOFF=-120
12FONT="Hermit 10"
13
14if [ -r "$DIR/config" ]; then
15 source ./config
16elif [ -r "~/.config/rofi/config" ]; then
17 source "~/.config/rofi/config"
18else
19 echo "WARNING: config file not found! Using default values."
20fi
21
22LIST=$(nmcli --fields "$FIELDS" device wifi list | sed '/^--/d')
23# For some reason rofi always approximates character width 2 short... hmmm
24RWIDTH=$(($(echo "$LIST" | head -n 1 | awk '{print length($0); }')+2))
25# Dynamically change the height of the rofi menu
26LINENUM=$(echo "$LIST" | wc -l)
27# Gives a list of known connections so we. can parse it later
28KNOWNCON=$(nmcli connection show)
29# Really janky way of telling if there is currently a connection
30CONSTATE=$(nmcli -fields WIFI g)
31
32CURRSSID=$(iwgetid -r)
33
34if [[ ! -z $CURRSSID ]]; then
35 HIGHLINE=$(echo "$(echo "$LIST" | awk -F "[ ]{2,}" '{print $1}' | grep -Fxn -m 1 "$CURRSSID" | awk -F ":" '{print $1}') + 1" | bc )
36fi
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
40if [ "$LINENUM" -gt 8 ] && [[ "$CONSTATE" =~ "enabled" ]]; then
41 LINENUM=8
42elif [[ "$CONSTATE" =~ "disabled" ]]; then
43 LINENUM=1
44fi
45
46
47if [[ "$CONSTATE" =~ "enabled" ]]; then
48 TOGGLE="toggle off"
49elif [[ "$CONSTATE" =~ "disabled" ]]; then
50 TOGGLE="toggle on"
51fi
52
53eval FIELDSARR=( $(cat ./config | awk 'BEGIN { FS=","; OFS="\n" } /^FIELDS/ { $1 = substr($1, 8); print $0; }') )
54
55for i in "${!FIELDSARR[@]}"; do
56 if [[ "${FIELDSARR[$i]}" = "SSID" ]]; then
57 SSID_POS="${i}";
58 fi
59done
60
61let AWKSSIDPOS=$SSID_POS+1
62
63CHENTRY=$(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"
65CHSSID=$(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
69if [ "$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
85elif [ "$CHENTRY" = "toggle on" ]; then
86 nmcli radio wifi on
87
88elif [ "$CHENTRY" = "toggle off" ]; then
89 nmcli radio wifi off
90
91else
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
108fi
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
7POSITION=3
8
9#y-offset
10YOFF=17
11
12#x-offset
13XOFF=0
14
15#fields to be displayed
16FIELDS=SSID,SECURITY,BARS
17
18#font
19FONT="Source Code Pro 12"