From 3ff2e6e742ef911e8930f41d42956c3f74ad8b90 Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Fri, 6 May 2022 22:55:24 +0200 Subject: [PATCH] Update dot_config/polybar/custom_modules.ini Add dot_config/polybar/scripts/executable_beep.sh Add dot_config/polybar/scripts/executable_colors.sh Add dot_config/polybar/scripts/executable_colors.sh.base Add dot_config/polybar/scripts/executable_launch_polybar Add dot_config/polybar/scripts/executable_michurin Add dot_config/polybar/scripts/executable_polybar_bluetooth_speaker.sh Add dot_config/polybar/scripts/executable_polybar_custom_time.sh Add dot_config/polybar/scripts/executable_polybar_dunst_indicator.sh Add dot_config/polybar/scripts/executable_polybar_healthbar.sh Add dot_config/polybar/scripts/executable_polybar_michurin.py Add dot_config/polybar/scripts/executable_polybar_net_indicator.sh Add dot_config/polybar/scripts/executable_polybar_net_speed.sh Add dot_config/polybar/scripts/executable_polybar_redshift_indicator.sh Add dot_config/polybar/scripts/executable_polybar_wifibar.sh Add dot_config/polybar/scripts/executable_refresh_wpg_wallpapers Add dot_config/polybar/scripts/executable_regkernel Add dot_config/polybar/scripts/executable_setbg Add dot_config/polybar/scripts/executable_theme.sh Add dot_config/polybar/scripts/executable_transmission_indicator.sh Add dot_config/polybar/scripts/executable_tresorit_indicator.sh --- dot_config/polybar/custom_modules.ini | 34 +- dot_config/polybar/scripts/executable_beep.sh | 4 + .../polybar/scripts/executable_colors.sh | 20 + .../polybar/scripts/executable_colors.sh.base | 20 + .../polybar/scripts/executable_launch_polybar | 23 + .../polybar/scripts/executable_michurin | 9 + .../executable_polybar_bluetooth_speaker.sh | 21 + .../scripts/executable_polybar_custom_time.sh | 18 + .../executable_polybar_dunst_indicator.sh | 19 + .../scripts/executable_polybar_healthbar.sh | 104 + .../scripts/executable_polybar_michurin.py | 160 + .../executable_polybar_net_indicator.sh | 51 + .../scripts/executable_polybar_net_speed.sh | 17 + .../executable_polybar_redshift_indicator.sh | 20 + .../scripts/executable_polybar_wifibar.sh | 34 + .../scripts/executable_refresh_wpg_wallpapers | 13 + .../polybar/scripts/executable_regkernel | 3 + dot_config/polybar/scripts/executable_setbg | 19 + .../polybar/scripts/executable_theme.sh | 5990 +++++++++++++++++ .../executable_transmission_indicator.sh | 25 + .../scripts/executable_tresorit_indicator.sh | 22 + 21 files changed, 6609 insertions(+), 17 deletions(-) create mode 100644 dot_config/polybar/scripts/executable_beep.sh create mode 100644 dot_config/polybar/scripts/executable_colors.sh create mode 100644 dot_config/polybar/scripts/executable_colors.sh.base create mode 100644 dot_config/polybar/scripts/executable_launch_polybar create mode 100644 dot_config/polybar/scripts/executable_michurin create mode 100644 dot_config/polybar/scripts/executable_polybar_bluetooth_speaker.sh create mode 100644 dot_config/polybar/scripts/executable_polybar_custom_time.sh create mode 100644 dot_config/polybar/scripts/executable_polybar_dunst_indicator.sh create mode 100644 dot_config/polybar/scripts/executable_polybar_healthbar.sh create mode 100644 dot_config/polybar/scripts/executable_polybar_michurin.py create mode 100644 dot_config/polybar/scripts/executable_polybar_net_indicator.sh create mode 100644 dot_config/polybar/scripts/executable_polybar_net_speed.sh create mode 100644 dot_config/polybar/scripts/executable_polybar_redshift_indicator.sh create mode 100644 dot_config/polybar/scripts/executable_polybar_wifibar.sh create mode 100644 dot_config/polybar/scripts/executable_refresh_wpg_wallpapers create mode 100644 dot_config/polybar/scripts/executable_regkernel create mode 100644 dot_config/polybar/scripts/executable_setbg create mode 100644 dot_config/polybar/scripts/executable_theme.sh create mode 100644 dot_config/polybar/scripts/executable_transmission_indicator.sh create mode 100644 dot_config/polybar/scripts/executable_tresorit_indicator.sh diff --git a/dot_config/polybar/custom_modules.ini b/dot_config/polybar/custom_modules.ini index a16924a..5fca07a 100644 --- a/dot_config/polybar/custom_modules.ini +++ b/dot_config/polybar/custom_modules.ini @@ -1,6 +1,6 @@ [module/healthbar] type = custom/script -exec = ~/.local/bin/scripts/polybar_healthbar.sh +exec = ~/.config/polybar/scripts/polybar_healthbar.sh tail = true interval = 3 @@ -10,7 +10,7 @@ format-padding = 1 [module/wifibar] type = custom/script -exec = ~/.local/bin/scripts/polybar_wifibar.sh +exec = ~/.config/polybar/scripts/polybar_wifibar.sh tail = true interval = 3 @@ -20,7 +20,7 @@ format-padding = 1 [module/netspeed] type = custom/script -exec = ~/.local/bin/scripts/polybar_net_speed.sh +exec = ~/.config/polybar/scripts/polybar_net_speed.sh tail = true interval = 2 @@ -30,7 +30,7 @@ format-padding = 1 [module/bluetooth_speaker] type = custom/script -exec = ~/.local/bin/scripts/polybar_bluetooth_speaker.sh +exec = ~/.config/polybar/scripts/polybar_bluetooth_speaker.sh tail = true interval = 3 @@ -39,20 +39,20 @@ format-foreground = ${colors.light0_soft} format-padding = 1 format-font = 1 -[module/michurin] -type = custom/script -exec = ~/.cache/pypoetry/virtualenvs/machaerus-afsOMv7y-py3.10/bin/python ~/.local/bin/scripts/polybar_michurin.py -tail = true -interval = 5 +#[module/michurin] +#type = custom/script +#exec = ~/.cache/pypoetry/virtualenvs/machaerus-afsOMv7y-py3.10/bin/python ~/.local/bin/scripts/polybar_michurin.py +#tail = true +#interval = 5 -format-background = ${colors.dark0_hard} -format-foreground = ${colors.light0_soft} -format-padding = 1 -format-font = 1 +#format-background = ${colors.dark0_hard} +#format-foreground = ${colors.light0_soft} +#format-padding = 1 +#format-font = 1 [module/net_indicator] type = custom/script -exec = ~/.local/bin/scripts/polybar_net_indicator.sh +exec = ~/.config/polybar/scripts/polybar_net_indicator.sh tail = true interval = 3 @@ -65,7 +65,7 @@ click-left = kitty -e nmtui-connect [module/tresorit_indicator] type = custom/script -exec = ~/.local/bin/scripts/tresorit_indicator.sh +exec = ~/.config/polybar/scripts/tresorit_indicator.sh tail = true interval = 2 @@ -78,7 +78,7 @@ click-left = tresorit [module/dunst_indicator] type = custom/script -exec = ~/.local/bin/scripts/polybar_dunst_indicator.sh +exec = ~/.config/polybar/scripts/polybar_dunst_indicator.sh tail = true interval = 1 @@ -91,7 +91,7 @@ click-left = dunstctl set-paused toggle [module/custom_time] type = custom/script -exec = ~/.local/bin/scripts/polybar_custom_time.sh +exec = ~/.config/polybar/scripts/polybar_custom_time.sh tail = true interval = 1 diff --git a/dot_config/polybar/scripts/executable_beep.sh b/dot_config/polybar/scripts/executable_beep.sh new file mode 100644 index 0000000..70766eb --- /dev/null +++ b/dot_config/polybar/scripts/executable_beep.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +play /usr/share/sounds/freedesktop/stereo/message-new-instant.oga 2> /dev/null +notify-send "Achtung!" \ No newline at end of file diff --git a/dot_config/polybar/scripts/executable_colors.sh b/dot_config/polybar/scripts/executable_colors.sh new file mode 100644 index 0000000..797ca65 --- /dev/null +++ b/dot_config/polybar/scripts/executable_colors.sh @@ -0,0 +1,20 @@ +dark0_hard=%{F#121519} +dark0_soft=%{F#29313c} +light0_hard=%{F#eaeadd} +light0_soft=%{F#d3ccc4} + +faded_red=%{F#FD3044} +faded_green=%{F#946D5A} +faded_yellow=%{F#C49965} +faded_blue=%{F#EFB590} +faded_purple=%{F#D23243} +faded_aqua=%{F#A2817D} + +bright_red=%{F#ff2a48} +bright_green=%{F#cf8865} +bright_yellow=%{F#ffc86f} +bright_blue=%{F#ffe5a2} +bright_purple=%{F#ff3049} +bright_aqua=%{F#e5998f} + +RESET=%{F-} \ No newline at end of file diff --git a/dot_config/polybar/scripts/executable_colors.sh.base b/dot_config/polybar/scripts/executable_colors.sh.base new file mode 100644 index 0000000..0eb86a0 --- /dev/null +++ b/dot_config/polybar/scripts/executable_colors.sh.base @@ -0,0 +1,20 @@ +dark0_hard=%{{F{color0}}} +dark0_soft=%{{F{color8}}} +light0_hard=%{{F{color15}}} +light0_soft=%{{F{color7}}} + +faded_red=%{{F{color1}}} +faded_green=%{{F{color2}}} +faded_yellow=%{{F{color3}}} +faded_blue=%{{F{color4}}} +faded_purple=%{{F{color5}}} +faded_aqua=%{{F{color6}}} + +bright_red=%{{F{color9}}} +bright_green=%{{F{color10}}} +bright_yellow=%{{F{color11}}} +bright_blue=%{{F{color12}}} +bright_purple=%{{F{color13}}} +bright_aqua=%{{F{color14}}} + +RESET=%{{F-}} \ No newline at end of file diff --git a/dot_config/polybar/scripts/executable_launch_polybar b/dot_config/polybar/scripts/executable_launch_polybar new file mode 100644 index 0000000..b1ec775 --- /dev/null +++ b/dot_config/polybar/scripts/executable_launch_polybar @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +## Add this to your wm startup file. + +# Terminate already running bar instances +pkill polybar + +# Wait until the processes have been shut down +#while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done +sleep 1 + +rm /tmp/polybar* +rm /tmp/ipc-polybar* +# Launch bar1 and bar2 +polybar --reload -c ~/.config/polybar/config.ini main & +ln -s /tmp/polybar_mqueue.$! /tmp/ipc-polybar-top +polybar --reload -c ~/.config/polybar/config_bottom.ini main & +ln -s /tmp/polybar_mqueue.$! /tmp/ipc-polybar-bottom +#polybar --reload -c ~/.config/polybar/config_monitor_2.ini main & + +# Hide the bottom bar by default. Can be toggled with a shortcut. +sleep 1 +echo cmd:hide > /tmp/ipc-polybar-bottom diff --git a/dot_config/polybar/scripts/executable_michurin b/dot_config/polybar/scripts/executable_michurin new file mode 100644 index 0000000..b08c22b --- /dev/null +++ b/dot_config/polybar/scripts/executable_michurin @@ -0,0 +1,9 @@ +#!/bin/bash +# Shortcut for a Michurin CLI client. +# +# Author: machaerus +# https://gitlab.com/machaerus + +# "$HOME/.conda/envs/michurin/bin/python" "$HOME/Sync/Projekty/project_michurin/client/michurin.py" "$@" + +"$HOME/.cache/pypoetry/virtualenvs/michurin-client-_yjGt9yr-py3.10/bin/python" "$HOME/Sync/Projekty/project_michurin/client/michurin.py" "$@" diff --git a/dot_config/polybar/scripts/executable_polybar_bluetooth_speaker.sh b/dot_config/polybar/scripts/executable_polybar_bluetooth_speaker.sh new file mode 100644 index 0000000..7cc5f4b --- /dev/null +++ b/dot_config/polybar/scripts/executable_polybar_bluetooth_speaker.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Bluetooth speaker indicator for polybar. +# Change the MAC address to the MAC of your speaker, after it is paired. +# I cannot guarantee it will work for you. This script does nothing to +# actually connect to the speaker, it only displays a status icon. +# +# Author: machaerus +# https://gitlab.com/machaerus + +source colors.sh + +bluetooth_speaker() { + SPEAKER_CONNECTED=$(bt-device -i 78:44:05:F6:E9:15 | grep Connected | xargs | cut -d ' ' -f 2) + if [ "$SPEAKER_CONNECTED" -eq 1 ]; then + speaker_indicator="${faded_green}${RESET}" + else + speaker_indicator="${dark0_soft}${RESET}" + fi + echo $speaker_indicator +} +# bluetooth_speaker diff --git a/dot_config/polybar/scripts/executable_polybar_custom_time.sh b/dot_config/polybar/scripts/executable_polybar_custom_time.sh new file mode 100644 index 0000000..6986a2d --- /dev/null +++ b/dot_config/polybar/scripts/executable_polybar_custom_time.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Custom clock/calendar for polybar. +# +# Author: machaerus +# https://gitlab.com/machaerus + +source colors.sh + +custom_time() { + WEEKDAY=$(date +%A) + TIME=$(date +%H:%M:%S) + DATE=$(date +"%e %b %Y") + + echo "$light0_soft $WEEKDAY $faded_yellow $TIME $light0_soft $DATE $RESET" +} + +custom_time diff --git a/dot_config/polybar/scripts/executable_polybar_dunst_indicator.sh b/dot_config/polybar/scripts/executable_polybar_dunst_indicator.sh new file mode 100644 index 0000000..aee6b56 --- /dev/null +++ b/dot_config/polybar/scripts/executable_polybar_dunst_indicator.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Dunst "do not disturb" indicator for polybar. You should be able +# to snooze and unsnooze notification by left-clicking the icon. +# +# Author: machaerus +# https://gitlab.com/machaerus + +source colors.sh + +dunst_notifications() { + dunst_enabled=$(dunstctl is-paused) + if [ "$dunst_enabled" == "false" ]; then + dunst_indicator="${faded_green}${RESET}" + else + dunst_indicator="${faded_red}${RESET}" + fi + echo $dunst_indicator +} +dunst_notifications \ No newline at end of file diff --git a/dot_config/polybar/scripts/executable_polybar_healthbar.sh b/dot_config/polybar/scripts/executable_polybar_healthbar.sh new file mode 100644 index 0000000..aaad7db --- /dev/null +++ b/dot_config/polybar/scripts/executable_polybar_healthbar.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# +# Battery status as am RPG-like "health bar" with hearts and half-hearts. +# To be used with polybar or similar. This should work for a ThinkPad with +# two batteries installed. +# +# It also shows desktop notifications when the battery is low (notify-send). +# +# Author: machaerus +# https://gitlab.com/machaerus +# +# Original idea for calculating the battery % is not mine, unfortunately +# I don't remember the source. + +source colors.sh + +healthbar_print() { + + PATH_AC="/sys/class/power_supply/AC" + PATH_BATTERY_0="/sys/class/power_supply/BAT0" + PATH_BATTERY_1="/sys/class/power_supply/BAT1" + + ac=0 + battery_level_0=0 + battery_level_1=0 + battery_max_0=0 + battery_max_1=0 + + if [ -f "$PATH_AC/online" ]; then + ac=$(cat "$PATH_AC/online") + fi + + if [ -f "$PATH_BATTERY_0/energy_now" ]; then + battery_level_0=$(cat "$PATH_BATTERY_0/energy_now") + fi + + if [ -f "$PATH_BATTERY_0/energy_full" ]; then + battery_max_0=$(cat "$PATH_BATTERY_0/energy_full") + fi + + if [ -f "$PATH_BATTERY_1/energy_now" ]; then + battery_level_1=$(cat "$PATH_BATTERY_1/energy_now") + fi + + if [ -f "$PATH_BATTERY_1/energy_full" ]; then + battery_max_1=$(cat "$PATH_BATTERY_1/energy_full") + fi + + battery_level=$(("$battery_level_0 + $battery_level_1")) + battery_max=$(("$battery_max_0 + $battery_max_1")) + + battery_percent=$(("$battery_level * 100")) + battery_percent=$(("$battery_percent / $battery_max")) + + # notify-send "Battery below 90%" + # notify-send "$battery_percent" + if [[ "$battery_percent" -lt 3 ]] && [[ ! "$ac" -eq 1 ]]; then + play /usr/share/sounds/freedesktop/stereo/message.oga 2> /dev/null + notify-send -u critical "Battery below 3%!" + elif [[ "$battery_percent" -lt 10 ]] && [[ ! "$ac" -eq 1 ]]; then + play /usr/share/sounds/freedesktop/stereo/message.oga 2> /dev/null + notify-send -u critical "Battery below 10%!" + fi + + # if [ "$battery_percent" -gt 88 ]; then + # hp="$faded_red   $RESET" + # elif [ "$battery_percent" -gt 75 ]; then + # hp="$faded_red   ﯜ$RESET" + # elif [ "$battery_percent" -gt 63 ]; then + # hp="$faded_red   $RESET$dark0_soft$RESET" + # elif [ "$battery_percent" -gt 50 ]; then + # hp="$faded_red  ﯜ $RESET$dark0_soft$RESET" + # elif [ "$battery_percent" -gt 38 ]; then + # hp="$faded_red  $RESET$dark0_soft $RESET" + # elif [ "$battery_percent" -gt 25 ]; then + # hp="$faded_red ﯜ $RESET$dark0_soft $RESET" + # elif [ "$battery_percent" -gt 13 ]; then + # hp="$faded_red $RESET$dark0_soft  $RESET" + # else + # hp="$faded_redﯜ $RESET$dark0_soft  $RESET" + # fi + + # if [ "$ac" -eq 1 ]; then + # echo "$dark0_soft[$faded_yellow$dark0_soft]$RESET $battery_percent" + # else + # echo " $battery_percent" + # fi + + if [ "$battery_percent" -gt 25 ]; then + battery_color="$faded_green" + elif [ "$battery_percent" -gt 10 ]; then + battery_color="$faded_yellow" + else + battery_color="$faded_red" + fi + + if [ "$ac" -eq 1 ]; then + echo "$battery_color$RESET $battery_percent" + else + echo "$battery_color$RESET $battery_percent" + fi +} + +healthbar_print \ No newline at end of file diff --git a/dot_config/polybar/scripts/executable_polybar_michurin.py b/dot_config/polybar/scripts/executable_polybar_michurin.py new file mode 100644 index 0000000..e142831 --- /dev/null +++ b/dot_config/polybar/scripts/executable_polybar_michurin.py @@ -0,0 +1,160 @@ +#!/usr/bin/env python +# +# A polybar indicator for Project Michurin. Displays an icon along with +# a status message to indicate the status of a plant with a Michurin moisture +# sensor. This is just a proof of concept and may have to be completely +# rewritten soon. +# +# Requires MICHURIN_ENDPOINT and MICHURIN_TOKEN environmental variables to be +# set, or present in `michurin.env` file, for the purpose of communication +# with your Michurin server. +# +# Author: machaerus +# https://gitlab.com/machaerus + +from dateutil import parser +from datetime import datetime as dt +from datetime import timedelta +import json +from pathlib import Path +import os +import sys + +import pytz +import requests +from dotenv import load_dotenv + + +class MichurinPolybar: + + def __init__(self): + + try: + # Load environment + env_path = os.path.join( + os.path.dirname(sys.argv[0]), "michurin.env") + load_dotenv(dotenv_path=env_path) + colors_path = os.path.join( + os.path.dirname(sys.argv[0]), "colors.sh") + load_dotenv(dotenv_path=colors_path) + + # server access + self.MICHURIN_TOKEN = os.getenv("MICHURIN_TOKEN") + self.MICHURIN_ENDPOINT = os.getenv("MICHURIN_ENDPOINT") + + assert self.MICHURIN_TOKEN is not None + assert self.MICHURIN_ENDPOINT is not None + except AssertionError: + print("Michurin: Environment not loaded!") + sys.exit(1) + + # color definitions + self.faded_green = os.getenv("faded_green") + self.faded_yellow = os.getenv("faded_yellow") + self.faded_red = os.getenv("faded_red") + self.RESET = os.getenv("RESET") + # self.RESET = "%{F#3e565e}" + + def get_info(self, sensor_id: int): + """ + Fetch the sensor info from the server. + + Parameters + ---------- + sensor_id : int + ID of the sensor (plant). + + Returns + ------- + name : str + Display name of the sensor (plant). + """ + endpoint = self.MICHURIN_ENDPOINT + f"sensors/{sensor_id}" + headers = {"Authorization": self.MICHURIN_TOKEN} + res = requests.get(endpoint, headers=headers) + + assert res.status_code == 200 + res_json = res.json() + name = res_json['display_name'] + return name + + def get_values(self, sensor_id: int): + """ + Fetch the sensor data from the server. + + Parameters + ---------- + sensor_id : int + ID of the sensor (plant). + + Returns + ------- + moistureRelative : float + Moisture level (latest value). + timestamp : datetime.datetime + Measurement time. + """ + endpoint = self.MICHURIN_ENDPOINT + f"sensors/{sensor_id}/data/latest" + headers = {"Authorization": self.MICHURIN_TOKEN} + res = requests.get(endpoint, headers=headers) + + assert res.status_code == 200 + res_json = res.json() + # print(res_json) + + # value = res_json['data']['value'] + moistureRelative = res_json['data']['moistureRelative'] + assert type(moistureRelative) == float + timestamp = parser.parse(res_json['data']['timestamp']) + + return moistureRelative, timestamp + + def show(self, sensor_id: int): + """ + Build and show the indicator. + + Parameters + ---------- + sensor_id : int + ID of the sensor (plant) to be displayed. + """ + try: + info = self.get_info(sensor_id) + except Exception as e: + info = None + + try: + moistureRelative, timestamp = self.get_values(sensor_id) + except Exception as e: + moistureRelative = None + timestamp = None + + if moistureRelative is not None: + value_f = f"{(moistureRelative * 100):.1f}%" + if moistureRelative > 0.5: + plant_indicator = f"{self.faded_green}{self.RESET}" + elif moistureRelative > 0.3: + plant_indicator = f"{self.faded_yellow}{self.RESET}" + else: + plant_indicator = f"{self.faded_red}{self.RESET}" + else: + value_f = "--" + plant_indicator = "" + + if timestamp is not None: + now = dt.now(tz=pytz.timezone('utc')) + if now - timestamp > timedelta(hours=3): + plant_indicator += " (offline) " + + # print(f"[ мичурин {plant_indicator} {value_f} ]") + return f"{self.RESET}[ {plant_indicator} {value_f} ]" + + +if __name__ == "__main__": + + # ID of your plant + SENSOR = 5 + + mp = MichurinPolybar() + indicator = mp.show(SENSOR) + print(indicator) diff --git a/dot_config/polybar/scripts/executable_polybar_net_indicator.sh b/dot_config/polybar/scripts/executable_polybar_net_indicator.sh new file mode 100644 index 0000000..fbd3155 --- /dev/null +++ b/dot_config/polybar/scripts/executable_polybar_net_indicator.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# Show a custom network connection indicator in polybar. +# Includes code for wifi, VPN, ZeroTier, and Hamachi. +# +# Author: machaerus +# https://gitlab.com/machaerus + +source colors.sh + +net_print() { + + # CONNECTED_WIFI=$(iwconfig wlan0 | grep ESSID | wc -l) + ESSID=$(iwconfig wlan0 | grep ESSID | cut -d: -f2 | xargs) + [ "$ESSID" = "off/any" ] && CONNECTED_WIFI=0 || CONNECTED_WIFI=1 + CONNECTED_VPN=$(ifconfig -a | grep tun0 | wc -l) + # CONNECTED_HAMACHI=$(hamachi | grep status | cut -d ':' -f 2 | xargs) + CONNECTED_ZEROTIER=$(zerotier-cli info | cut -d ' ' -f 5 | xargs) + + if [ "$CONNECTED_WIFI" -eq 1 ]; then + wifi_indicator="${faded_green}${RESET}" + else + wifi_indicator="${dark0_soft}${RESET}" + fi + + if [ "$CONNECTED_VPN" -eq 1 ]; then + vpn_indicator="${faded_green}${RESET}" + else + vpn_indicator="${dark0_soft}${RESET}" + fi + + # if [ "$CONNECTED_HAMACHI" = "logged in" ]; then + # hamachi_indicator="${faded_green}${RESET}" + # else + # hamachi_indicator="${dark0_soft}${RESET}" + # fi + + if [ "$CONNECTED_ZEROTIER" = "ONLINE" ]; then + zerotier_indicator="${faded_green}${RESET}" + else + zerotier_indicator="${dark0_soft}${RESET}" + fi + + # echo "$dark2[$wifi_indicator$dark2]$dark2[$vpn_indicator$dark2]" + echo "$wifi_indicator $vpn_indicator $zerotier_indicator" + # echo " $wifi_indicator $vpn_indicator " +} + +# net_print + + diff --git a/dot_config/polybar/scripts/executable_polybar_net_speed.sh b/dot_config/polybar/scripts/executable_polybar_net_speed.sh new file mode 100644 index 0000000..b94bd0e --- /dev/null +++ b/dot_config/polybar/scripts/executable_polybar_net_speed.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# +# Custom network download/upload speed indicator for polybar. +# +# Author: machaerus +# https://gitlab.com/machaerus + +source colors.sh + +net_speed() { + UP_NETSPEED=$(awk '{if(l1){printf "%6.1f", ($10-l2)/1024} else{l1=$2; l2=$10;}}' <(grep wlan0 /proc/net/dev) <(sleep 1; grep wlan0 /proc/net/dev)) + DOWN_NETSPEED=$(awk '{if(l1){printf "%6.1f", ($2-l1)/1024} else{l1=$2; l2=$10;}}' <(grep wlan0 /proc/net/dev) <(sleep 1; grep wlan0 /proc/net/dev)) + # echo "$dark0_soft [ $faded_aqua $UP_NETSPEED KB/s$RESET $faded_green↓ $DOWN_NETSPEED KB/s$RESET $dark0_soft]" + echo "$dark0_soft $faded_aqua  $UP_NETSPEED KB/s$RESET $faded_green  $DOWN_NETSPEED KB/s$RESET $dark0_soft" +} + +# net_speed diff --git a/dot_config/polybar/scripts/executable_polybar_redshift_indicator.sh b/dot_config/polybar/scripts/executable_polybar_redshift_indicator.sh new file mode 100644 index 0000000..5fd5e70 --- /dev/null +++ b/dot_config/polybar/scripts/executable_polybar_redshift_indicator.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# Redshift indicator for polybar. +# +# THIS DOESN'T CURRENTLY WORK +# +# Author: machaerus +# https://gitlab.com/machaerus + +source colors.sh + +dunst_notifications() { + dunst_enabled=$(dunstctl is-paused) + if [ "$dunst_enabled" == "false" ]; then + dunst_indicator="${faded_green}${RESET}" + else + dunst_indicator="${faded_red}${RESET}" + fi + echo $dunst_indicator +} +dunst_notifications diff --git a/dot_config/polybar/scripts/executable_polybar_wifibar.sh b/dot_config/polybar/scripts/executable_polybar_wifibar.sh new file mode 100644 index 0000000..bbcddfc --- /dev/null +++ b/dot_config/polybar/scripts/executable_polybar_wifibar.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Custom RPG-like wifi signal strength indicator for polybar. +# +# Author: machaerus +# https://gitlab.com/machaerus + +source colors.sh + +manabar_print() { + ESSID=$(iwconfig wlan0 | grep ESSID | cut -d: -f2 | xargs) + [ "$ESSID" = "off/any" ] && CONNECTED_WIFI=0 || CONNECTED_WIFI=1 + WIFI_Q=$(awk 'NR==3 {printf("%.0f\n",$3*10/7)}' /proc/net/wireless) + if [ "$CONNECTED_WIFI" -eq 1 ]; then + if [ "$WIFI_Q" -gt 75 ]; then + wifi="$bright_blue   $RESET" + elif [ "$WIFI_Q" -gt 50 ]; then + wifi="$bright_blue   $RESET$dark0_soft$RESET" + elif [ "$WIFI_Q" -gt 25 ]; then + wifi="$bright_blue  $RESET$dark0_soft $RESET" + elif [ "$WIFI_Q" -gt 0 ]; then + wifi="$bright_blue $RESET$dark0_soft  $RESET" + else + wifi="$dark0_soft   $RESET" + fi + else + wifi="$dark0_soft   $RESET" + fi + echo "$wifi" +} + +manabar_print + + diff --git a/dot_config/polybar/scripts/executable_refresh_wpg_wallpapers b/dot_config/polybar/scripts/executable_refresh_wpg_wallpapers new file mode 100644 index 0000000..7122cca --- /dev/null +++ b/dot_config/polybar/scripts/executable_refresh_wpg_wallpapers @@ -0,0 +1,13 @@ +#!/bin/bash +# +# Generate/refresh colorschemes for all your wallpapers for wpg. + +shopt -s nullglob + +cd "$HOME/Pictures/Wallpapers" || exit +for f in * +do + echo "$f" + wpg -a "$f" + sleep 0.1 +done diff --git a/dot_config/polybar/scripts/executable_regkernel b/dot_config/polybar/scripts/executable_regkernel new file mode 100644 index 0000000..2d0e4bb --- /dev/null +++ b/dot_config/polybar/scripts/executable_regkernel @@ -0,0 +1,3 @@ +#!/bin/bash +# Usage: regkernel your-py-kernel "Your favourite kernel" +python -m ipykernel install --user --name $1 --display-name "$2" diff --git a/dot_config/polybar/scripts/executable_setbg b/dot_config/polybar/scripts/executable_setbg new file mode 100644 index 0000000..0cf3271 --- /dev/null +++ b/dot_config/polybar/scripts/executable_setbg @@ -0,0 +1,19 @@ +#!/bin/sh + +# In LARBS, ~/.config/wall.png is the location of the system wallpaper. This +# script, if given an argument, moves it there. This script without an +# argument sets ~/.config/wall.png as the wallpaper, which is required on login +# if you don't want a black screen. +# +# Original author: Luke Smith. + +[ ! -z "$1" ] && cp "$1" ~/.config/wall.png && notify-send -i "$HOME/.config/wall.png" "Wallpaper changed." + +# If pywal is installed, use it. +type wal >/dev/null && { wal -c ; + wal -s -i ~/.config/wall.png -o ~/.config/wal/postrun; + xsetroot -name "fsignal:xrdb"; + killall dwmblocks; + setsid dwmblocks >/dev/null 2>&1 & } + +xwallpaper --zoom ~/.config/wall.png diff --git a/dot_config/polybar/scripts/executable_theme.sh b/dot_config/polybar/scripts/executable_theme.sh new file mode 100644 index 0000000..64565f4 --- /dev/null +++ b/dot_config/polybar/scripts/executable_theme.sh @@ -0,0 +1,5990 @@ +#!/bin/sh + +# Written by Aetnaeus. +# Source: https://github.com/lemnos/theme.sh. +# Licensed under the WTFPL provided this notice is preserved. + +# Find a broken theme? Want to add a missing one? PRs are welcome. + +themes=$(cat < /etc/symlink", fgesc(a[6]), fgesc(fg), bgesc(bg))) + + + while(nr > 0) puts("") + + printf "\x1b[0m" + } + ' +} + +preview2() { + printf '\033[30mColor 0\n' + printf '\033[31mColor 1\n' + printf '\033[32mColor 2\n' + printf '\033[33mColor 3\n' + printf '\033[34mColor 4\n' + printf '\033[35mColor 5\n' + printf '\033[36mColor 6\n' + printf '\033[37mColor 7\n' + + printf '\033[90mColor 8\n' + printf '\033[91mColor 9\n' + printf '\033[92mColor 10\n' + printf '\033[93mColor 11\n' + printf '\033[94mColor 12\n' + printf '\033[95mColor 13\n' + printf '\033[96mColor 14\n' + printf '\033[97mColor 15\n' + + printf '\n\033[0m' + printf '# ls --color -lF\n' + printf ' total 4\n' + printf ' -rw-r--r-- 1 user user 0 Jan 0 02:39 file\n' + printf ' drwxr-xr-x 2 user user 4096 Jan 0 02:39 \033[01;34mdir/\033[0m\n' + printf ' -rwxr-xr-x 1 user user 0 Jan 0 02:39 \033[01;32mexecutable\033[0m*\n' + printf ' lrwxrwxrwx 1 user user 15 Jan 0 02:40 \033[01;36msymlink\033[0m -> /etc/symlink\n' + + printf '\033[0m' +} + +apply() { + echo "$themes"| awk -F": " -v target="$1" ' + function tmuxesc(s) { return sprintf("\033Ptmux;\033%s\033\\", s) } + function normalize_term() { + # Term detection voodoo + + if(ENVIRON["TERM_PROGRAM"] == "iTerm.app") + term="iterm" + else if(ENVIRON["TMUX"]) { + "tmux display-message -p \"#{client_termname}\"" | getline term + is_tmux++ + } else + term=ENVIRON["TERM"] + } + + BEGIN { + normalize_term() + + if(term == "iterm") { + bgesc="\033]Ph%s\033\\" + fgesc="\033]Pg%s\033\\" + colesc="\033]P%x%s\033\\" + curesc="\033]Pl%s\033\\" + } else if(term ~ /st-.*/) { + fgesc="\033]4;7;#%s\007" + bgesc="\033]4;0;#%s\007" + colesc="\033]4;%d;#%s\007" + curesc="\033]4;256;#%s\007" + } else { + #Terms that play nice :) + + fgesc="\033]10;#%s\007" + bgesc="\033]11;#%s\007" + curesc="\033]12;#%s\007" + colesc="\033]4;%d;#%s\007" + } + + if(is_tmux) { + fgesc=tmuxesc(fgesc) + bgesc=tmuxesc(bgesc) + curesc=tmuxesc(curesc) + colesc=tmuxesc(colesc) + } + } + + $0 == target {found++} + + found && /^foreground:/ {fg=$2} + found && /^background:/ {bg=$2} + found && /^[0-9]+:/ {colors[int($1)]=$2} + found && /^cursorColor:/ {cursor=$2} + + found && /^ *$/ { exit } + + END { + if(found) { + for(c in colors) { + if(!(term ~ /st-.*/ && (c == 0 || c == 7))) + printf colesc, c, substr(colors[c], 2) > "/dev/tty" + } + + printf fgesc, substr(fg, 2) > "/dev/tty" + printf bgesc, substr(bg, 2) > "/dev/tty" + printf curesc, substr(cursor, 2) > "/dev/tty" + + f=ENVIRON["THEME_HISTFILE"] + if(f) { + while((getline < f) > 0) + if($0 != target) + out = out $0 "\n" + close(f) + + out = out target + print out > f + } + } + } + ' +} + +list() { + echo "$themes"| awk ' + BEGIN { + f = ENVIRON["THEME_HISTFILE"] + if(f) { + while((getline < f) > 0) { + mru[nmru++] = $0 + seen[$0] = 1 + } + } + + s = 1 + } + + /^ *$/ { s=1; next } + + s { + if(!seen[$0]) + print + + s = 0 + } + + END { + for(i = 0;i < nmru;i++) + print mru[i] + } + ' +} + +if [ -z "$1" ]; then + echo "Usage: $(basename "$0") [-l|--list] [-i|--interactive] [-i2|--interactive2] [-r|--random] " + exit +fi + +case "$1" in +-i2|--interactive2) + command -v fzf > /dev/null 2>&1 || { echo "ERROR: -i requires fzf" >&2; exit 1; } + "$0" -l|fzf\ + --tac\ + --bind "enter:execute-silent($0 {})"\ + --bind "down:down+execute-silent(THEME_HISTFILE= $0 {})"\ + --bind "up:up+execute-silent(THEME_HISTFILE= $0 {})"\ + --bind "change:execute-silent(THEME_HISTFILE= $0 {})"\ + --bind "ctrl-c:execute($0 {};echo {})+abort"\ + --bind "esc:execute($0 {};echo {})+abort"\ + --no-sort\ + --preview "$0 --preview2" + ;; +-r|--random) + theme=$($0 -l|sort -R|head -n1) + $0 "$theme" + echo "Theme: $theme" + ;; +-i|--interactive) + command -v fzf > /dev/null 2>&1 || { echo "ERROR: -i requires fzf" >&2; exit 1; } + if [ -z "$COLORTERM" ]; then + echo "This does not appear to be a truecolor terminal, try -i2 instead or set COLORTERM if your terminal has truecolor support." + exit 1 + else + "$0" -l|fzf\ + --tac\ + --bind "ctrl-c:execute(echo {})+abort"\ + --bind "esc:execute(echo {})+abort"\ + --bind "enter:execute-silent($0 {})"\ + --no-sort\ + --preview "$0 --preview {}" + fi + ;; +-l|--list) + list + ;; +--preview2) + preview2 "$2" + ;; +--preview) + preview "$2" + ;; +*) + apply "$1" + ;; +esac + diff --git a/dot_config/polybar/scripts/executable_transmission_indicator.sh b/dot_config/polybar/scripts/executable_transmission_indicator.sh new file mode 100644 index 0000000..d043d05 --- /dev/null +++ b/dot_config/polybar/scripts/executable_transmission_indicator.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Transmission indicator for polybar. +# +# THIS DOESN'T CURRENTLY WORK +# +# Author: machaerus +# https://gitlab.com/machaerus + +source colors.sh + +transmission_indicator() { + + TSTATUS=$(tresorit-cli status | head -1 | grep -oE '[^ ]+$') + [ "$TSTATUS" = "running" ] && RUNNING=1 || RUNNING=0 + + if [ "$RUNNING" -eq 1 ]; then + TTRANSFERS=$(tresorit-cli transfers | grep syncing | wc -l) + [ "$TTRANSFERS" -gt 0 ] && echo "$bright_yellow$RESET" || echo "$bright_green$RESET" + else + echo "$bright_red$RESET" + fi +} + +transmission_indicator diff --git a/dot_config/polybar/scripts/executable_tresorit_indicator.sh b/dot_config/polybar/scripts/executable_tresorit_indicator.sh new file mode 100644 index 0000000..dde49fb --- /dev/null +++ b/dot_config/polybar/scripts/executable_tresorit_indicator.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Custom Tresorit indicator for polybar. +# +# Author: machaerus +# https://gitlab.com/machaerus + +source colors.sh + +tresorit_indicator() { + TSTATUS=$(tresorit-cli status | head -1 | grep -oE '[^ ]+$') + [ "$TSTATUS" = "running" ] && RUNNING=1 || RUNNING=0 + + if [ "$RUNNING" -eq 1 ]; then + TTRANSFERS=$(tresorit-cli transfers | grep syncing | wc -l) + [ "$TTRANSFERS" -gt 0 ] && echo "$faded_yellow$RESET" || echo "$faded_green$RESET" + else + echo "$faded_red$RESET" + fi +} + +# tresorit_indicator