diff --git a/config/.config/polybar/bars/colours.ini b/config/.config/polybar/bars/colours.ini index da81667..387ef16 100644 --- a/config/.config/polybar/bars/colours.ini +++ b/config/.config/polybar/bars/colours.ini @@ -28,7 +28,9 @@ orange- = #FEB548 orange = #F18F01 orange+ = #A26201 +apricot- = #FFAB85 apricot = #FFCAB1 +apricot+ = #FFF1EB rose- = #CC8FA0 rose = #AB4E68 diff --git a/config/.config/polybar/bars/modules/bluetooth.ini b/config/.config/polybar/bars/modules/bluetooth.ini index 6904f03..61f3bc4 100644 --- a/config/.config/polybar/bars/modules/bluetooth.ini +++ b/config/.config/polybar/bars/modules/bluetooth.ini @@ -2,7 +2,7 @@ type = custom/script exec = ~/.config/polybar/scripts/bluetooth.sh interval = 5 -click-left = ~/.config/polybar/scripts/bluetooth.sh --toggle & +click-left = ~/.config/rofi/bluetooth/bluetooth.sh format-background = ${colours/bluetooth.bg} format-foreground = ${colours/bluetooth.fg} diff --git a/config/.config/polybar/bars/modules/wireless.ini b/config/.config/polybar/bars/modules/wireless.ini index 4b48f99..87aa034 100644 --- a/config/.config/polybar/bars/modules/wireless.ini +++ b/config/.config/polybar/bars/modules/wireless.ini @@ -2,6 +2,7 @@ type = internal/network interface-type = wireless interval = 3.0 +click-left = ~/.config/rofi/wifi/wifi.sh accumulate-stats = true ;unknown-as-up = true diff --git a/config/.config/rofi/bluetooth/bluetooth.rasi b/config/.config/rofi/bluetooth/bluetooth.rasi index f8dc85e..f9ef9b0 100644 --- a/config/.config/rofi/bluetooth/bluetooth.rasi +++ b/config/.config/rofi/bluetooth/bluetooth.rasi @@ -27,7 +27,7 @@ window { location: center; anchor: center; fullscreen: false; - width: 500px; + width: 800px; x-offset: 0px; y-offset: 0px; diff --git a/config/.config/rofi/bluetooth/bluetooth.sh b/config/.config/rofi/bluetooth/bluetooth.sh index 28ca5ae..d7b328a 100755 --- a/config/.config/rofi/bluetooth/bluetooth.sh +++ b/config/.config/rofi/bluetooth/bluetooth.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash + #!/usr/bin/env bash # __ _ _ _ _ _ _ # _ __ ___ / _(_) | |__ | |_ _ ___| |_ ___ ___ | |_| |__ # | '__/ _ \| |_| |_____| '_ \| | | | |/ _ \ __/ _ \ / _ \| __| '_ \ @@ -17,14 +17,17 @@ # Arch repositories: rofi, bluez-utils (contains bluetoothctl) # Constants -divider="---------" +divider="" goback="Back" +# For debugging/development purposes +# PREFIX=projects/samfelag/config/ + # Rofi command to pipe into, can add any options here -dir="$HOME/.config/rofi/bluetooth/" +dir="$HOME/$PREFIX.config/rofi/bluetooth/" theme='bluetooth' -rofi_command="rofi -dmenu -no-fixed-num-lines -theme ${dir}/${theme}.rasi -i -p" +rofi_command="rofi -dmenu -theme ${dir}/${theme}.rasi -i -p" # rofi -dmenu \ # -theme ${dir}/${theme}.rasi diff --git a/config/.config/rofi/wifi/wifi.rasi b/config/.config/rofi/wifi/wifi.rasi new file mode 100755 index 0000000..c5a7b23 --- /dev/null +++ b/config/.config/rofi/wifi/wifi.rasi @@ -0,0 +1,156 @@ +/** + * + * Author : Marc Sastre, based on Aditya Shakya (adi1090x, Github : @adi1090x) + * + **/ + +/*****----- Configuration -----*****/ +configuration { + show-icons: false; +} + +/*****----- Global Properties -----*****/ +* { + font: "Iosevka Nerd Font 10"; + background: #FFAB85; + background-alt: #FFCAB1; + foreground: #444444; + selected: #CC8FA0; + active: #7E3A4D; + urgent: #7E3A4D; +} + +/*****----- Main Window -----*****/ +window { + /* properties for window widget */ + transparency: "real"; + location: center; + anchor: center; + fullscreen: false; + width: 800px; + x-offset: 0px; + y-offset: 0px; + + /* properties for all widgets */ + enabled: true; + margin: 0px; + padding: 0px; + border: 0px solid; + border-radius: 20px; + border-color: @selected; + cursor: "default"; + background-color: @background; +} + +/*****----- Main Box -----*****/ +mainbox { + enabled: true; + spacing: 15px; + margin: 0px; + padding: 30px; + border: 0px solid; + border-radius: 0px; + border-color: @selected; + background-color: transparent; + children: [ "inputbar", "listview" ]; +} +message { + enabled: true; + margin: 0px; + padding: 10px; + border: 0px solid; + border-radius: 10px; + border-color: @selected; + background-color: @background-alt; + text-color: @foreground; +} +textbox { + background-color: inherit; + text-color: inherit; + vertical-align: 0.5; + horizontal-align: 0.0; + placeholder-color: @foreground; + blink: true; + markup: true; +} + +/*****----- Inputbar -----*****/ +inputbar { + enabled: true; + spacing: 10px; + padding: 15px; + border-radius: 10px; + background-color: @background-alt; + text-color: @foreground; + children: [ "textbox-prompt-colon", "entry" ]; +} +textbox-prompt-colon { + enabled: true; + expand: false; + str: "яки"; + background-color: inherit; + text-color: inherit; +} +entry { + enabled: true; + background-color: inherit; + text-color: inherit; + cursor: text; +} + +/*****----- 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: 5px; + margin: 0px; + padding: 0px; + border: 0px solid; + border-radius: 0px; + border-color: @selected; + background-color: transparent; + text-color: @foreground; + cursor: "default"; +} + +/*****----- Elements -----*****/ +element { + enabled: true; + spacing: 0px; + margin: 0px; + padding: 12px; + border: 0px solid; + border-radius: 100%; + border-color: @selected; + background-color: transparent; + text-color: @foreground; + cursor: pointer; +} +element-text { + background-color: transparent; + text-color: inherit; + cursor: inherit; + vertical-align: 0.5; + horizontal-align: 0.0; +} +element selected.normal { + background-color: var(selected); + text-color: var(background); +} +element active { + background-color: var(active); + text-color: var(background); +} +element selected.active { + background-color: var(selected); + text-color: var(background); +} diff --git a/config/.config/rofi/wifi/wifi.sh b/config/.config/rofi/wifi/wifi.sh new file mode 100755 index 0000000..6dfb73b --- /dev/null +++ b/config/.config/rofi/wifi/wifi.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +# Shamelessly stolen from https://github.com/zbaylin/rofi-wifi-menu + +# Starts a scan of available broadcasting SSIDs +# nmcli dev wifi rescan + + +# For debugging/development purposes +# PREFIX=projects/samfelag/config/ + +# Rofi command to pipe into, can add any options here +dir="$HOME/$PREFIX.config/rofi/wifi/" +theme='wifi' + +rofi_command="rofi -dmenu -i -theme ${dir}/${theme}.rasi" + +FIELDS=SSID,SECURITY,BARS + +LIST=$(nmcli --fields "$FIELDS" device wifi list | sed '/^--/d') +# Gives a list of known connections so we can parse it later +KNOWNCON=$(nmcli connection show) +# Really janky way of telling if there is currently a connection +CONSTATE=$(nmcli -fields WIFI g) +CURRSSID=$(LANGUAGE=C nmcli -t -f active,ssid dev wifi | awk -F: '$1 ~ /^yes/ {print $2}') + +if [[ ! -z $CURRSSID ]]; then + HIGHLINE=$(echo "$(echo "$LIST" | awk -F "[ ]{2,}" '{print $1}' | grep -Fxn -m 1 "$CURRSSID" | awk -F ":" '{print $1}') + 1" | bc ) +fi + +if [[ "$CONSTATE" =~ "habilitat" ]]; then + TOGGLE="toggle off" +elif [[ "$CONSTATE" =~ "deshabilitat" ]]; then + TOGGLE="toggle on" +fi + + +CHENTRY=$(echo -e "$TOGGLE\nmanual\n$LIST" | uniq -u | $rofi_command -p "Wi-Fi SSID: " -a "$HIGHLINE") +#echo "$CHENTRY" +CHSSID=$(echo "$CHENTRY" | sed 's/\s\{2,\}/\|/g' | awk -F "|" '{print $1}') +#echo "$CHSSID" + +# If the user inputs "manual" as their SSID in the start window, it will bring them to this screen +if [ "$CHENTRY" = "manual" ] ; then + # Manual entry of the SSID and password (if appplicable) + MSSID=$(echo "enter the SSID of the network (SSID,password)" | $rofi_command -p "Manual Entry: " -lines 1) + # Separating the password from the entered string + MPASS=$(echo "$MSSID" | awk -F "," '{print $2}') + + #echo "$MSSID" + #echo "$MPASS" + + # If the user entered a manual password, then use the password nmcli command + if [ "$MPASS" = "" ]; then + nmcli dev wifi con "$MSSID" + else + nmcli dev wifi con "$MSSID" password "$MPASS" + fi + +elif [ "$CHENTRY" = "toggle on" ]; then + nmcli radio wifi on + +elif [ "$CHENTRY" = "toggle off" ]; then + nmcli radio wifi off + +else + + # If the connection is already in use, then this will still be able to get the SSID + if [ "$CHSSID" = "*" ]; then + CHSSID=$(echo "$CHENTRY" | sed 's/\s\{2,\}/\|/g' | awk -F "|" '{print $3}') + fi + + # Parses the list of preconfigured connections to see if it already contains the chosen SSID. This speeds up the connection process + if [[ $(echo "$KNOWNCON" | grep "$CHSSID") = "$CHSSID" ]]; then + nmcli con up "$CHSSID" + else + if [[ "$CHENTRY" =~ "WPA2" ]] || [[ "$CHENTRY" =~ "WEP" ]]; then + WIFIPASS=$(echo "Enter password, if connection is stored, hit enter" | $rofi_command -p "Password: " -lines 1 ) + fi + nmcli dev wifi con "$CHSSID" password "$WIFIPASS" + fi + +fi diff --git a/modules/desktop/polybar.nix b/modules/desktop/polybar.nix index 6067414..0e2bd7b 100644 --- a/modules/desktop/polybar.nix +++ b/modules/desktop/polybar.nix @@ -2,6 +2,7 @@ let cfg = config.samfelag.modules.desktop.polybar; + i3Cfg = config.samfelag.modules.desktop.i3; polybar_pkg = pkgs.polybar.override { i3Support = true; pulseSupport = true; @@ -34,6 +35,12 @@ in { hm.xdg.configFile."polybar/bars".source = paths.bars; hm.xdg.configFile."polybar/scripts".source = paths.scripts; + # The polybar modules use rofi + samfelag.modules.desktop.rofi.enable = true; + samfelag.modules.desktop.i3.extraKeybindings = lib.mkIf i3Cfg.enable { + "${i3Cfg.mod}+Shift+w" = "exec $HOME/.config/rofi/wifi/wifi.sh"; + }; + hm.systemd.user.services.polybar = { Unit = { Description = "Polybar status bar"; diff --git a/modules/system/utils.nix b/modules/system/utils.nix index 0d8ed94..02c2312 100644 --- a/modules/system/utils.nix +++ b/modules/system/utils.nix @@ -9,6 +9,7 @@ in }; config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ + bc zip unzip ];