diff --git a/.config/i3/scripts/blur-lock b/.config/i3/scripts/blur-lock new file mode 100755 index 0000000..4ff7ed6 --- /dev/null +++ b/.config/i3/scripts/blur-lock @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +PICTURE=/tmp/i3lock.png +SCREENSHOT="scrot -z $PICTURE" + +BLUR="5x4" + +$SCREENSHOT +convert $PICTURE -blur $BLUR $PICTURE +i3lock -i $PICTURE +rm $PICTURE diff --git a/.config/i3/scripts/disk b/.config/i3/scripts/disk new file mode 100755 index 0000000..e18c7aa --- /dev/null +++ b/.config/i3/scripts/disk @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# Copyright (C) 2014 Julien Bonjean + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +DIR="${DIR:-$BLOCK_INSTANCE}" +DIR="${DIR:-$HOME}" +ALERT_LOW="${ALERT_LOW:-$1}" +ALERT_LOW="${ALERT_LOW:-10}" # color will turn red under this value (default: 10%) + +LOCAL_FLAG="-l" +if [ "$1" = "-n" ] || [ "$2" = "-n" ]; then + LOCAL_FLAG="" +fi + +df -h -P $LOCAL_FLAG "$DIR" | awk -v label="$LABEL" -v alert_low=$ALERT_LOW ' +/\/.*/ { + # full text + print label $4 + + # short text + print label $4 + + use=$5 + + # no need to continue parsing + exit 0 +} + +END { + gsub(/%$/,"",use) + if (100 - use < alert_low) { + # color + print "#FF0000" + } +} +' diff --git a/.config/i3/scripts/i3exit.sh b/.config/i3/scripts/i3exit.sh new file mode 100755 index 0000000..a10bd9c --- /dev/null +++ b/.config/i3/scripts/i3exit.sh @@ -0,0 +1,28 @@ +#!/bin/sh + + +case "$1" in + lock) + betterlockscreen -l dimblur -- --timestr="%H:%M" + ;; + logout) + i3-msg exit + ;; + suspend) + systemctl suspend + ;; + hibernate) + systemctl hibernate + ;; + reboot) + systemctl reboot + ;; + shutdown) + systemctl poweroff + ;; + *) + echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}" + exit 2 +esac + +exit 0 diff --git a/.config/i3/scripts/keyhint b/.config/i3/scripts/keyhint new file mode 100755 index 0000000..8b8c3e3 --- /dev/null +++ b/.config/i3/scripts/keyhint @@ -0,0 +1,25 @@ +#!/bin/bash + +Main() { + source /usr/share/endeavouros/scripts/eos-script-lib-yad || return 1 + + local command=( + eos_yad --title="EndeavourOS i3-wm keybindings:" --no-buttons --geometry=400x345-15-400 --list + --column=key: --column=description: --column=command: + "ESC" "close this app" "" + "=" "modkey" "(set mod Mod4)" + "+enter" "open a terminal" "" + "+Shift+n" "new empty workspace" "" + "+w" "open Browser" "" + "+n" "open Filebrowser" "" + "+d" "app menu" "" + "+q" "close focused app" "" + "Print-key" "screenshot" "" + "+Shift+e" "logout menu" "" + "F1" "open keybinding helper" "" + ) + + "${command[@]}" +} + +Main "$@" diff --git a/.config/i3/scripts/memory b/.config/i3/scripts/memory new file mode 100755 index 0000000..e60be50 --- /dev/null +++ b/.config/i3/scripts/memory @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# Copyright (C) 2014 Julien Bonjean + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +TYPE="${BLOCK_INSTANCE:-mem}" + +awk -v type=$TYPE ' +/^MemTotal:/ { + mem_total=$2 +} +/^MemFree:/ { + mem_free=$2 +} +/^Buffers:/ { + mem_free+=$2 +} +/^Cached:/ { + mem_free+=$2 +} +/^SwapTotal:/ { + swap_total=$2 +} +/^SwapFree:/ { + swap_free=$2 +} +END { + if (type == "swap") { + free=swap_free/1024/1024 + used=(swap_total-swap_free)/1024/1024 + total=swap_total/1024/1024 + } else { + free=mem_free/1024/1024 + used=(mem_total-mem_free)/1024/1024 + total=mem_total/1024/1024 + } + + pct=0 + if (total > 0) { + pct=used/total*100 + } + + # full text + # printf("%.1fG/%.1fG (%.f%%)\n", used, total, pct) + + # short text + printf("%02.f%%\n", pct) + + # color + if (pct > 90) { + print("#FF0000") + } else if (pct > 80) { + print("#FFAE00") + } else if (pct > 70) { + print("#FFF600") + } +} +' /proc/meminfo diff --git a/.config/i3/scripts/openweather-city b/.config/i3/scripts/openweather-city new file mode 100755 index 0000000..5f05eda --- /dev/null +++ b/.config/i3/scripts/openweather-city @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +command -v jq >/dev/null 2>&1 || { echo >&2 "Program 'jq' required but it is not installed. +Aborting."; exit 1; } +command -v wget >/dev/null 2>&1 || { echo >&2 "Program 'wget' required but is not installed. +Aborting."; exit 1; } + +# To use this script you need to create an API key here https://home.openweathermap.org +# You need to put your Open Weather APIKEY here: +APIKEY="0b4c4fbf6f9bbb8403a997c4cc861237" +# find your City ID here: https://openweathermap.org/ +# search for your city and copy the ID from the URL inside the browser. +# You need to put your Open Weather APIKEY here: +APIKEY="0b4c4fbf6f9bbb8403a997c4cc861237" +CITY_ID="3065617" +URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&units=metric&APPID=${APIKEY}" + +WEATHER_RESPONSE=$(wget -qO- "${URL}") + +WEATHER_CONDITION=$(echo $WEATHER_RESPONSE | jq '.weather[0].main' | sed 's/"//g') +WEATHER_TEMP=$(echo $WEATHER_RESPONSE | jq '.main.temp') +WIND_DIR=$( echo "$WEATHER_RESPONSE" | jq '.wind.deg') +WIND_SPEED=$( echo "$WEATHER_RESPONSE" | jq '.wind.speed') + +WIND_SPEED=$(awk "BEGIN {print 60*60*$WIND_SPEED/1000}") +WIND_DIR=$(awk "BEGIN {print int(($WIND_DIR % 360)/22.5)}") +DIR_ARRAY=( N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW N ) +WIND_DIR=${DIR_ARRAY[WIND_DIR]} + +case $WEATHER_CONDITION in + 'Clouds') + WEATHER_ICON="" + ;; + 'Rain') + WEATHER_ICON="" + ;; + 'Snow') + WEATHER_ICON="" + ;; + *) + WEATHER_ICON="" + ;; +esac + +echo "${WEATHER_ICON} ${WEATHER_TEMP}°C: ${WIND_SPEED} km/h ${WIND_DIR}" diff --git a/.config/i3/scripts/openweather.sh b/.config/i3/scripts/openweather.sh new file mode 100755 index 0000000..8e1b647 --- /dev/null +++ b/.config/i3/scripts/openweather.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +# Edited by Andreas Lindlbauer + +temps=("#0600FF" "#0500FF" "#0400FF" "#0300FF" "#0200FF" "#0100FF" "#0000FF" "#0002FF" "#0012FF" "#0022FF" "#0032FF" "#0044FF" "#0054FF" "#0064FF" "#0074FF" "#0084FF" "#0094FF" "#00A4FF" "#00B4FF" "#00C4FF" "#00D4FF" "#00E4FF" "#00FFF4" "#00FFD0" "#00FFA8" "#00FF83" "#00FF5C" "#00FF36" "#00FF10" "#17FF00" "#3EFF00" "#65FF00" "#B0FF00" "#FDFF00" "#FFF000" "#FFDC00" "#FFC800" "#FFB400" "#FFA000" "#FF8C00" "#FF7800" "#FF6400" "#FF5000" "#FF3C00" "#FF2800" "#FF1400" "#FF0000") + +command -v jq >/dev/null 2>&1 || { echo >&2 "Program 'jq' required but it is not installed. +Aborting."; exit 1; } +command -v wget >/dev/null 2>&1 || { echo >&2 "Program 'wget' required but is not installed. +Aborting."; exit 1; } + +# To use this script you need to create an API key here https://home.openweathermap.org +# You need to put your Open Weather APIKEY here: +APIKEY="0b4c4fbf6f9bbb8403a997c4cc861237" +# And get your Latitute and Longitudes to put in here: +LAT="50.1813" +LON="12.6401" +URL="http://api.openweathermap.org/data/2.5/onecall?lat=${LAT}&lon=${LON}&units=metric&exclude=minutely,hourly,daily&APPID=${APIKEY}" +WEATHER_RESPONSE=$(wget -qO- "${URL}") + +WEATHER_CONDITION=$(echo "$WEATHER_RESPONSE" | jq '.current.weather[0].main' | sed 's/"//g') +WEATHER_TEMP=$(echo "$WEATHER_RESPONSE" | jq '.current.feels_like') +WEATHER_INT=${WEATHER_TEMP%.*} + +TIME_NOW=$( echo "$WEATHER_RESPONSE" | jq '.current.dt') +SUNRISE=$( echo "$WEATHER_RESPONSE" | jq '.current.sunrise') +SUNSET=$( echo "$WEATHER_RESPONSE" | jq '.current.sunset') +DESCRIPTION=$( echo "$WEATHER_RESPONSE" | jq '.current.weather[0].description' | sed 's/"//g') +WEATHER_ALERT=$( echo "$WEATHER_RESPONSE" | jq '.alerts[0].event' | sed 's/"//g') +DAYTIME="n" + +if [[ "$TIME_NOW" > "$SUNRISE" ]] && [[ "$TIME_NOW" < "$SUNSET" ]]; then + DAYTIME="d" +fi + +case $WEATHER_CONDITION in + 'Clouds') + if [ "$DAYTIME" == "d" ]; then + WEATHER_ICON="" + else + WEATHER_ICON="" + fi + ;; + 'Rain') + WEATHER_ICON="" + ;; + 'Drizzle') + if [ "$DAYTIME" == "d" ]; then + WEATHER_ICON="" + else + WEATHER_ICON="" + fi + ;; + 'Thunderstorm') + WEATHER_ICON="" + ;; + 'Snow') + WEATHER_ICON="" + ;; + 'Clear') + if [ "$DAYTIME" == "d" ]; then + WEATHER_ICON="" + else + WEATHER_ICON="" + fi + ;; + *) + WEATHER_ICON="🌫" + ;; +esac + +WEATHER_COLOR="#FFFFFF" +if [ "$WEATHER_INT" -lt "-11" ]; then + WEATHER_COLOR="#0000FF" +elif [ "$WEATHER_INT" -gt 35 ]; then + WEATHER_COLOR="#FF0000" +else + WEATHER_INT=$(( WEATHER_INT + 11 )) + WEATHER_COLOR="${temps[$WEATHER_INT]}" +fi + +full_text="${WEATHER_ICON} ${WEATHER_TEMP}°C: ${DESCRIPTION} " +if [ "$WEATHER_ALERT" != "null" ]; then + WARN_START=$(echo "$WEATHER_RESPONSE" | jq '.alerts[0].start') + WARN_END=$(echo "$WEATHER_RESPONSE" | jq '.alerts[0].end') + WARN_START=$(date -d @"$WARN_START" +%a_%k:%M) + WARN_END=$(date -d @"$WARN_END" +%a_%k:%M) + full_text="${WEATHER_ICON} ${WEATHER_TEMP}°C: ${DESCRIPTION}  ${WEATHER_ALERT} from ${WARN_START} to ${WARN_END}  " +fi + + +echo "${full_text}" +echo "${WEATHER_TEMP}°C " +echo "${WEATHER_COLOR}" diff --git a/.config/i3/scripts/powermenu b/.config/i3/scripts/powermenu new file mode 100755 index 0000000..791a9e4 --- /dev/null +++ b/.config/i3/scripts/powermenu @@ -0,0 +1,186 @@ +#!/usr/bin/env bash +# +# Use rofi/zenity to change system runstate thanks to systemd. +# +# Note: this currently relies on associative array support in the shell. +# +# Inspired from i3pystatus wiki: +# https://github.com/enkore/i3pystatus/wiki/Shutdown-Menu +# +# Copyright 2015 Benjamin Chrétien +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# modified to work with latest rofi update by joekamprad + +####################################################################### +# BEGIN CONFIG # +####################################################################### + +# Use a custom lock script +#LOCKSCRIPT="i3lock-extra -m pixelize" + +# Colors: FG (foreground), BG (background), HL (highlighted) +FG_COLOR="#bbbbbb" +BG_COLOR="#111111" +HLFG_COLOR="#111111" +HLBG_COLOR="#bbbbbb" +BORDER_COLOR="#222222" + +# Options not related to colors (most rofi options do not work anymore) +ROFI_OPTIONS=(-theme ~/.config/rofi/powermenu.rasi) +# Zenity options +ZENITY_TITLE="Power Menu" +ZENITY_TEXT="Action:" +ZENITY_OPTIONS=(--column= --hide-header) + +####################################################################### +# END CONFIG # +####################################################################### + +# Whether to ask for user's confirmation +enable_confirmation=false + +# Preferred launcher if both are available +preferred_launcher="rofi" + +usage="$(basename "$0") [-h] [-c] [-p name] -- display a menu for shutdown, reboot, lock etc. + +where: + -h show this help text + -c ask for user confirmation + -p preferred launcher (rofi or zenity) + +This script depends on: + - systemd, + - i3, + - rofi or zenity." + +# Check whether the user-defined launcher is valid +launcher_list=(rofi zenity) +function check_launcher() { + if [[ ! "${launcher_list[@]}" =~ (^|[[:space:]])"$1"($|[[:space:]]) ]]; then + echo "Supported launchers: ${launcher_list[*]}" + exit 1 + else + # Get array with unique elements and preferred launcher first + # Note: uniq expects a sorted list, so we cannot use it + i=1 + launcher_list=($(for l in "$1" "${launcher_list[@]}"; do printf "%i %s\n" "$i" "$l"; let i+=1; done \ + | sort -uk2 | sort -nk1 | cut -d' ' -f2- | tr '\n' ' ')) + fi +} + +# Parse CLI arguments +while getopts "hcp:" option; do + case "${option}" in + h) echo "${usage}" + exit 0 + ;; + c) enable_confirmation=true + ;; + p) preferred_launcher="${OPTARG}" + check_launcher "${preferred_launcher}" + ;; + *) exit 1 + ;; + esac +done + +# Check whether a command exists +function command_exists() { + command -v "$1" &> /dev/null 2>&1 +} + +# systemctl required +if ! command_exists systemctl ; then + exit 1 +fi + +# menu defined as an associative array +typeset -A menu + +# Menu with keys/commands + +menu=( + [ Shutdown]="systemctl poweroff" + [ Reboot]="systemctl reboot" + [ Suspend]="systemctl suspend" + [ Hibernate]="systemctl hibernate" + [ Lock]="~/.config/i3/scripts/blur-lock" + [ Logout]="i3-msg exit" + [ Cancel]="" +) + +menu_nrows=${#menu[@]} + +# Menu entries that may trigger a confirmation message +menu_confirm="Shutdown Reboot Hibernate Suspend Halt Logout" + +launcher_exe="" +launcher_options="" +rofi_colors="" + +function prepare_launcher() { + if [[ "$1" == "rofi" ]]; then + rofi_colors=(-bc "${BORDER_COLOR}" -bg "${BG_COLOR}" -fg "${FG_COLOR}" \ + -hlfg "${HLFG_COLOR}" -hlbg "${HLBG_COLOR}") + launcher_exe="rofi" + launcher_options=(-dmenu -i -lines "${menu_nrows}" -p "${ROFI_TEXT}" \ + "${rofi_colors}" "${ROFI_OPTIONS[@]}") + elif [[ "$1" == "zenity" ]]; then + launcher_exe="zenity" + launcher_options=(--list --title="${ZENITY_TITLE}" --text="${ZENITY_TEXT}" \ + "${ZENITY_OPTIONS[@]}") + fi +} + +for l in "${launcher_list[@]}"; do + if command_exists "${l}" ; then + prepare_launcher "${l}" + break + fi +done + +# No launcher available +if [[ -z "${launcher_exe}" ]]; then + exit 1 +fi + +launcher=(${launcher_exe} "${launcher_options[@]}") +selection="$(printf '%s\n' "${!menu[@]}" | sort | "${launcher[@]}")" + +function ask_confirmation() { + if [ "${launcher_exe}" == "rofi" ]; then + confirmed=$(echo -e "Yes\nNo" | rofi -dmenu -i -lines 2 -p "${selection}?" \ + "${rofi_colors}" "${ROFI_OPTIONS[@]}") + [ "${confirmed}" == "Yes" ] && confirmed=0 + elif [ "${launcher_exe}" == "zenity" ]; then + zenity --question --text "Are you sure you want to ${selection,,}?" + confirmed=$? + fi + + if [ "${confirmed}" == 0 ]; then + i3-msg -q "exec --no-startup-id ${menu[${selection}]}" + fi +} + +if [[ $? -eq 0 && ! -z ${selection} ]]; then + if [[ "${enable_confirmation}" = true && \ + ${menu_confirm} =~ (^|[[:space:]])"${selection}"($|[[:space:]]) ]]; then + ask_confirmation + else + i3-msg -q "exec --no-startup-id ${menu[${selection}]}" + fi +fi diff --git a/.config/i3/scripts/ppd-status b/.config/i3/scripts/ppd-status new file mode 100755 index 0000000..8e6eb7b --- /dev/null +++ b/.config/i3/scripts/ppd-status @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# +# power-profiles-daemon implementation: +# needs package power-profiles-daemon installed and the service running see here: +# https://wiki.archlinux.org/title/CPU_frequency_scaling#power-profiles-daemon +# used in i3-blocks: ~/.config/i3/i3blocks.conf together with: ~/.config/i3/scripts/power-profiles + +# script to show current power profile + +current_profile=$(/usr/bin/powerprofilesctl get) +echo "$current_profile" diff --git a/.config/i3/scripts/volume b/.config/i3/scripts/volume new file mode 100755 index 0000000..39618e1 --- /dev/null +++ b/.config/i3/scripts/volume @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +# Copyright (C) 2014 Julien Bonjean +# Copyright (C) 2014 Alexander Keller + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# original source: https://github.com/vivien/i3blocks-contrib/tree/master/volume +# check the readme: https://github.com/vivien/i3blocks-contrib/blob/master/volume/README.md +#------------------------------------------------------------------------ + +# The second parameter overrides the mixer selection +# For PulseAudio users, eventually use "pulse" +# For Jack/Jack2 users, use "jackplug" +# For ALSA users, you may use "default" for your primary card +# or you may use hw:# where # is the number of the card desired +if [[ -z "$MIXER" ]] ; then + MIXER="default" + if command -v pulseaudio >/dev/null 2>&1 && pulseaudio --check ; then + # pulseaudio is running, but not all installations use "pulse" + if amixer -D pulse info >/dev/null 2>&1 ; then + MIXER="pulse" + fi + fi + [ -n "$(lsmod | grep jack)" ] && MIXER="jackplug" + MIXER="${2:-$MIXER}" +fi + +# The instance option sets the control to report and configure +# This defaults to the first control of your selected mixer +# For a list of the available, use `amixer -D $Your_Mixer scontrols` +if [[ -z "$SCONTROL" ]] ; then + SCONTROL="${BLOCK_INSTANCE:-$(amixer -D $MIXER scontrols | + sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | + head -n1 + )}" +fi + +# The first parameter sets the step to change the volume by (and units to display) +# This may be in in % or dB (eg. 5% or 3dB) +if [[ -z "$STEP" ]] ; then + STEP="${1:-5%}" +fi + +# AMIXER(1): +# "Use the mapped volume for evaluating the percentage representation like alsamixer, to be +# more natural for human ear." +NATURAL_MAPPING=${NATURAL_MAPPING:-0} +if [[ "$NATURAL_MAPPING" != "0" ]] ; then + AMIXER_PARAMS="-M" +fi + +#------------------------------------------------------------------------ + +capability() { # Return "Capture" if the device is a capture device + amixer $AMIXER_PARAMS -D $MIXER get $SCONTROL | + sed -n "s/ Capabilities:.*cvolume.*/Capture/p" +} + +volume() { + amixer $AMIXER_PARAMS -D $MIXER get $SCONTROL $(capability) +} + +format() { + + perl_filter='if (/.*\[(\d+%)\] (\[(-?\d+.\d+dB)\] )?\[(on|off)\]/)' + perl_filter+='{CORE::say $4 eq "off" ? "MUTE" : "' + # If dB was selected, print that instead + perl_filter+=$([[ $STEP = *dB ]] && echo '$3' || echo '$1') + perl_filter+='"; exit}' + output=$(perl -ne "$perl_filter") + echo "$LABEL$output" +} + +#------------------------------------------------------------------------ + +case $BLOCK_BUTTON in + 3) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute + 4) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase + 5) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease +esac + +volume | format diff --git a/.config/i3/scripts/vpn b/.config/i3/scripts/vpn new file mode 100755 index 0000000..a348f96 --- /dev/null +++ b/.config/i3/scripts/vpn @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2021 Andreas Lindlbauer +# Licensed under the terms of EUPLv1.2. +# +# i3blocks blocklet script to monitor the (nord)vpn connection + +vpnstatus="📢" +nordvpn_output=$(nordvpn status | cat -v | head -1 | sed -e 's/\^M-^M ^M//g' ) +if [ "${nordvpn_output}" = "Status: Connected" ]; then + vpnstatus="🥸" +elif [ "${nordvpn_output}" = "A new version of NordVPN is available! Please update the application." ]; then + nordvpn_output=$(nordvpn status | cat -v | head -2 | tail -1 | sed -e 's/\^M-^M ^M//g' ) + if [ "${nordvpn_output}" = "Status: Connected" ]; then + vpnstatus="🥴" + elif [ "${nordvpn_output}" = "Status: Disconnected" ]; then + vpnstatus="📢" + fi +elif [ "${nordvpn_output}" = "Status: Disconnected" ]; then + vpnstatus="📢" +elif [[ "$nordvpn_output" == *\/* ]] || [[ "$nordvpn_output" == *\\* ]]; then + vpnstatus="Something's very wrong" +fi + +echo "$vpnstatus"