configuration form the arch linux stored
This commit is contained in:
0
polybar/scripts/.notifs
Normal file
0
polybar/scripts/.notifs
Normal file
27
polybar/scripts/adjust_brightness.sh
Executable file
27
polybar/scripts/adjust_brightness.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
current_brightness=$(brightnessctl g | cut -d '(' -f 2 | cut -d ')' -f 1)
|
||||
|
||||
if [ "$1" == "+" ]; then
|
||||
if [ $current_brightness -lt 10 ]; then
|
||||
brightnessctl set +1
|
||||
elif [ $current_brightness -ge 10 ] && [ $current_brightness -lt 100 ]; then
|
||||
brightnessctl set +7
|
||||
else
|
||||
brightnessctl set +50
|
||||
fi
|
||||
elif [ "$1" == "-" ]; then
|
||||
if [ $current_brightness -le 10 ]; then
|
||||
brightnessctl set 1-
|
||||
elif [ $current_brightness -gt 10 ] && [ $current_brightness -le 130 ]; then
|
||||
brightnessctl set 7-
|
||||
else
|
||||
brightnessctl set 50-
|
||||
fi
|
||||
|
||||
# Make sure brightness doesn't go below 2
|
||||
new_brightness=$(brightnessctl g | cut -d '(' -f 2 | cut -d ')' -f 1)
|
||||
if [ $new_brightness -lt 2 ]; then
|
||||
brightnessctl set 2
|
||||
fi
|
||||
fi
|
||||
36
polybar/scripts/adjust_brightness_xrandr.sh
Executable file
36
polybar/scripts/adjust_brightness_xrandr.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set your display identifier
|
||||
DISPLAY_IDENTIFIER="DVI-I-0"
|
||||
|
||||
# Get the current brightness
|
||||
current_brightness=$(xrandr --verbose | grep -m 1 -i brightness | cut -f2 -d ' ')
|
||||
|
||||
# Determine the step value for brightness changes based on current brightness
|
||||
if (( $(echo "$current_brightness < 0.2" | bc -l) )); then
|
||||
step=0.0125 # Finer step for the dimmest settings
|
||||
elif (( $(echo "$current_brightness < 0.5" | bc -l) )); then
|
||||
step=0.0375 # Smaller step for dim settings
|
||||
else
|
||||
step=0.075 # Larger step for brighter settings
|
||||
fi
|
||||
|
||||
# Increase or decrease brightness based on the first argument
|
||||
if [ "$1" == "+" ]; then
|
||||
new_brightness=$(echo "$current_brightness + $step" | bc)
|
||||
elif [ "$1" == "-" ]; then
|
||||
new_brightness=$(echo "$current_brightness - $step" | bc)
|
||||
fi
|
||||
|
||||
# Format the brightness to avoid locale issues with decimal separator
|
||||
new_brightness=$(LC_ALL=C printf "%.4f" $new_brightness)
|
||||
|
||||
# Clamp the new brightness values to be within 0.1 and 1
|
||||
if (( $(echo "$new_brightness < 0.1" | bc -l) )); then
|
||||
new_brightness=0.1
|
||||
elif (( $(echo "$new_brightness > 1" | bc -l) )); then
|
||||
new_brightness=1
|
||||
fi
|
||||
|
||||
# Apply the new brightness value
|
||||
xrandr --output $DISPLAY_IDENTIFIER --brightness $new_brightness
|
||||
66
polybar/scripts/battery.sh
Executable file
66
polybar/scripts/battery.sh
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
BATTERY="BAT1"
|
||||
CAPACITY=$(cat /sys/class/power_supply/$BATTERY/capacity)
|
||||
STATUS=$(cat /sys/class/power_supply/$BATTERY/status)
|
||||
|
||||
# Define icons
|
||||
ICON_FULL="" # nf-fa-battery_full
|
||||
ICON_HIGH="" # nf-fa-battery_three_quarters
|
||||
ICON_MEDIUM="" # nf-fa-battery_half
|
||||
ICON_LOW="" # nf-fa-battery_quarter
|
||||
ICON_EMPTY="" # nf-fa-battery_empty
|
||||
ICON_CHARGING_HIGH="" # nf-md-battery_charging_outline
|
||||
ICON_CHARGING_MEDIUM="" # nf-md-battery_charging_medium
|
||||
ICON_CHARGING_LOW="" # nf-md-battery_charging_low
|
||||
ICON_CHARGING_OUTLINE="" # nf-md-battery_charging_high
|
||||
|
||||
# Define colors
|
||||
COLOR_NORMAL="#FFFFFF" # White
|
||||
COLOR_WARNING="#FFA500" # Orange
|
||||
COLOR_CRITICAL="#FF0000" # Red
|
||||
|
||||
# Set icon based on capacity and status
|
||||
if [ "$STATUS" = "Charging" ] || [ "$STATUS" = "Full" ]; then
|
||||
if [ $CAPACITY -ge 90 ]; then
|
||||
ICON=$ICON_CHARGING_HIGH
|
||||
elif [ $CAPACITY -ge 60 ]; then
|
||||
ICON=$ICON_CHARGING_MEDIUM
|
||||
elif [ $CAPACITY -ge 30 ]; then
|
||||
ICON=$ICON_CHARGING_LOW
|
||||
else
|
||||
ICON=$ICON_CHARGING_OUTLINE
|
||||
fi
|
||||
else
|
||||
if [ $CAPACITY -ge 80 ]; then
|
||||
ICON=$ICON_FULL
|
||||
elif [ $CAPACITY -ge 60 ]; then
|
||||
ICON=$ICON_HIGH
|
||||
elif [ $CAPACITY -ge 30 ]; then
|
||||
ICON=$ICON_MEDIUM
|
||||
elif [ $CAPACITY -ge 10 ]; then
|
||||
ICON=$ICON_LOW
|
||||
else
|
||||
ICON=$ICON_EMPTY
|
||||
fi
|
||||
fi
|
||||
|
||||
# Set color based on capacity
|
||||
if [ $CAPACITY -le 20 ] && [ "$STATUS" != "Charging" ] && [ "$STATUS" != "Full" ]; then
|
||||
COLOR=$COLOR_WARNING
|
||||
if [ $CAPACITY -le 10 ]; then
|
||||
COLOR=$COLOR_CRITICAL
|
||||
fi
|
||||
else
|
||||
COLOR=$COLOR_NORMAL
|
||||
fi
|
||||
|
||||
# Read the toggle state
|
||||
TOGGLE_STATE=$(cat ~/.config/polybar/scripts/battery_toggle_state)
|
||||
|
||||
# Output for Polybar
|
||||
if [ "$TOGGLE_STATE" == "icon" ]; then
|
||||
echo "%{F$COLOR}$ICON%{F-}"
|
||||
else
|
||||
echo "%{F$COLOR}$CAPACITY%%{F-}"
|
||||
fi
|
||||
44
polybar/scripts/battery_format.sh
Executable file
44
polybar/scripts/battery_format.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
TOGGLE_FILE="$HOME/.toggle_battery_label"
|
||||
|
||||
# Function to get battery status and percentage
|
||||
get_battery_info() {
|
||||
# Use acpi to get battery status and percentage
|
||||
read -r status percentage <<< $(acpi -b | awk -F', ' '{print $1, $2}' | awk '{print $3, $4}' | tr -d '%,')
|
||||
|
||||
# Determine the battery icon based on the current percentage level
|
||||
if [[ $status = *Charging* ]]; then
|
||||
if [ "$percentage" -ge 80 ]; then
|
||||
icon="" # nf-md-battery_charging_high
|
||||
elif [ "$percentage" -ge 60 ]; then
|
||||
icon="" # nf-md-battery_charging_medium
|
||||
elif [ "$percentage" -ge 40 ]; then
|
||||
icon="" # nf-md-battery_charging_low
|
||||
else
|
||||
icon="" # nf-md-battery_charging_outline
|
||||
fi
|
||||
else
|
||||
if [ "$percentage" -ge 80 ]; then
|
||||
icon="" # Battery full
|
||||
elif [ "$percentage" -ge 60 ]; then
|
||||
icon="" # Battery 3/4
|
||||
elif [ "$percentage" -ge 40 ]; then
|
||||
icon="" # Battery 1/2
|
||||
elif [ "$percentage" -ge 20 ]; then
|
||||
icon="" # Battery 1/4
|
||||
else
|
||||
icon="" # Battery empty
|
||||
fi
|
||||
fi
|
||||
|
||||
# If the toggle file exists, only show the percentage, otherwise show the icon with percentage
|
||||
if [ -f "$TOGGLE_FILE" ]; then
|
||||
echo "$percentage%"
|
||||
else
|
||||
echo "$icon"
|
||||
fi
|
||||
}
|
||||
|
||||
# Output the battery information
|
||||
get_battery_info
|
||||
1
polybar/scripts/battery_toggle_state
Normal file
1
polybar/scripts/battery_toggle_state
Normal file
@@ -0,0 +1 @@
|
||||
icon
|
||||
72
polybar/scripts/brightness.sh
Executable file
72
polybar/scripts/brightness.sh
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
|
||||
DEVICE="intel_backlight"
|
||||
BRIGHTNESS=$(brightnessctl get)
|
||||
MAX_BRIGHTNESS=$(brightnessctl max)
|
||||
PERCENTAGE=$((BRIGHTNESS * 100 / MAX_BRIGHTNESS))
|
||||
|
||||
# Define icons
|
||||
ICON_BRIGHT=""
|
||||
ICON_DIM=""
|
||||
|
||||
# Set icon based on brightness level
|
||||
if [ $PERCENTAGE -ge 50 ]; then
|
||||
ICON=$ICON_BRIGHT
|
||||
else
|
||||
ICON=$ICON_DIM
|
||||
fi
|
||||
|
||||
# Function to calculate the step size dynamically
|
||||
calculate_step() {
|
||||
local percentage=$1
|
||||
local min_step=$((MAX_BRIGHTNESS / 100)) # 1% step
|
||||
local max_step=$((MAX_BRIGHTNESS * 15 / 100)) # 15% step
|
||||
|
||||
# Scale the step size linearly between min_step and max_step
|
||||
local step=$((min_step + (max_step - min_step) * percentage / 100))
|
||||
|
||||
# Ensure the step is within bounds
|
||||
if [ $step -lt $min_step ]; then
|
||||
step=$min_step
|
||||
elif [ $step -gt $max_step ]; then
|
||||
step=$max_step
|
||||
fi
|
||||
|
||||
echo $step
|
||||
}
|
||||
|
||||
# Function to calculate the new brightness value
|
||||
calculate_new_brightness() {
|
||||
local current=$1
|
||||
local max=$2
|
||||
local change=$3
|
||||
|
||||
# Calculate the new brightness value
|
||||
local new_value=$((current + change))
|
||||
|
||||
# Ensure the new value is within the valid range (1% to 100%)
|
||||
if [ $new_value -lt 1 ]; then
|
||||
new_value=1
|
||||
elif [ $new_value -gt $max ]; then
|
||||
new_value=$max
|
||||
fi
|
||||
|
||||
echo $new_value
|
||||
}
|
||||
|
||||
# Handle click actions
|
||||
case $1 in
|
||||
"up")
|
||||
STEP=$(calculate_step $PERCENTAGE)
|
||||
NEW_BRIGHTNESS=$(calculate_new_brightness $BRIGHTNESS $MAX_BRIGHTNESS $STEP)
|
||||
brightnessctl set $NEW_BRIGHTNESS > /dev/null
|
||||
;;
|
||||
"down")
|
||||
STEP=$(calculate_step $PERCENTAGE)
|
||||
NEW_BRIGHTNESS=$(calculate_new_brightness $BRIGHTNESS $MAX_BRIGHTNESS $(( -STEP )))
|
||||
brightnessctl set $NEW_BRIGHTNESS > /dev/null
|
||||
;;
|
||||
esac
|
||||
|
||||
# Output for Polybar
|
||||
echo "$ICON $PERCENTAGE%"
|
||||
28
polybar/scripts/brightness_icon.sh
Normal file
28
polybar/scripts/brightness_icon.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
current_brightness=$(brightnessctl g | cut -d '(' -f 2 | cut -d ')' -f 1)
|
||||
|
||||
if [ "$1" == "+" ]; then
|
||||
if [ $current_brightness -lt 10 ]; then
|
||||
brightnessctl set +1
|
||||
elif [ $current_brightness -ge 10 ] && [ $current_brightness -lt 100 ]; then
|
||||
brightnessctl set +7
|
||||
else
|
||||
brightnessctl set +50
|
||||
fi
|
||||
elif [ "$1" == "-" ]; then
|
||||
if [ $current_brightness -le 10 ]; then
|
||||
brightnessctl set 1-
|
||||
elif [ $current_brightness -gt 10 ] && [ $current_brightness -le 130 ]; then
|
||||
brightnessctl set 7-
|
||||
else
|
||||
brightnessctl set 50-
|
||||
fi
|
||||
|
||||
# Make sure brightness doesn't go below 2
|
||||
new_brightness=$(brightnessctl g | cut -d '(' -f 2 | cut -d ')' -f 1)
|
||||
if [ $new_brightness -lt 2 ]; then
|
||||
brightnessctl set 2
|
||||
fi
|
||||
fi
|
||||
|
||||
24
polybar/scripts/brightness_icon_xrandr.sh
Executable file
24
polybar/scripts/brightness_icon_xrandr.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Define your display identifier, e.g., DVI-I-0
|
||||
DISPLAY_IDENTIFIER="DVI-I-0"
|
||||
|
||||
# Get the current brightness using xrandr
|
||||
brightness=$(xrandr --verbose | grep -m 1 'Brightness' | cut -f2 -d ' ')
|
||||
|
||||
# Compare brightness values as floating-point numbers
|
||||
if (( $(echo "$brightness <= 0.2" | bc -l) )); then
|
||||
icon="" # Dimmest
|
||||
elif (( $(echo "$brightness > 0.2 && $brightness <= 0.4" | bc -l) )); then
|
||||
icon="" # Dim
|
||||
elif (( $(echo "$brightness > 0.4 && $brightness <= 0.6" | bc -l) )); then
|
||||
icon="" # Moderate
|
||||
elif (( $(echo "$brightness > 0.6 && $brightness <= 0.8" | bc -l) )); then
|
||||
icon="" # Bright
|
||||
elif (( $(echo "$brightness > 0.8 && $brightness <= 1" | bc -l) )); then
|
||||
icon="" # Brighter
|
||||
else
|
||||
icon="" # Brightest
|
||||
fi
|
||||
|
||||
echo "$icon"
|
||||
9
polybar/scripts/launch.sh
Executable file
9
polybar/scripts/launch.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Terminate already running bar instances
|
||||
killall -q polybar
|
||||
|
||||
# Launch all three bars
|
||||
polybar --config=~/.config/polybar/config.ini bar1 &
|
||||
polybar --config=~/.config/polybar/config.ini bar2 &
|
||||
polybar --config=~/.config/polybar/config.ini bar3 &
|
||||
56
polybar/scripts/mic-volume.sh
Executable file
56
polybar/scripts/mic-volume.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
|
||||
DEFAULT_SOURCE_INDEX=$(pacmd list-sources | grep "\* index:" | cut -d' ' -f5)
|
||||
|
||||
display_volume() {
|
||||
if [ -z "$volume" ]; then
|
||||
echo "No Mic Found"
|
||||
else
|
||||
volume="${volume//[[:blank:]]/}"
|
||||
if [[ "$mute" == *"yes"* ]]; then
|
||||
echo ""
|
||||
elif [[ "$mute" == *"no"* ]]; then
|
||||
echo "$volume"
|
||||
else
|
||||
echo "$volume !"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
case $1 in
|
||||
"show-vol")
|
||||
if [ -z "$2" ]; then
|
||||
volume=$(pacmd list-sources | grep "index: $DEFAULT_SOURCE_INDEX" -A 7 | grep "volume" | awk -F/ '{print $2}')
|
||||
mute=$(pacmd list-sources | grep "index: $DEFAULT_SOURCE_INDEX" -A 11 | grep "muted")
|
||||
display_volume
|
||||
else
|
||||
volume=$(pacmd list-sources | grep "$2" -A 6 | grep "volume" | awk -F/ '{print $2}')
|
||||
mute=$(pacmd list-sources | grep "$2" -A 11 | grep "muted" )
|
||||
display_volume
|
||||
fi
|
||||
;;
|
||||
"inc-vol")
|
||||
if [ -z "$2" ]; then
|
||||
pactl set-source-volume $DEFAULT_SOURCE_INDEX +7%
|
||||
else
|
||||
pactl set-source-volume $2 +7%
|
||||
fi
|
||||
;;
|
||||
"dec-vol")
|
||||
if [ -z "$2" ]; then
|
||||
pactl set-source-volume $DEFAULT_SOURCE_INDEX -7%
|
||||
else
|
||||
pactl set-source-volume $2 -7%
|
||||
fi
|
||||
;;
|
||||
"mute-vol")
|
||||
if [ -z "$2" ]; then
|
||||
pactl set-source-mute $DEFAULT_SOURCE_INDEX toggle
|
||||
else
|
||||
pactl set-source-mute $2 toggle
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Invalid script option"
|
||||
;;
|
||||
esac
|
||||
25
polybar/scripts/next_wallpaper.sh
Executable file
25
polybar/scripts/next_wallpaper.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
COUNTER_FILE="$HOME/.wallpaper-counter"
|
||||
LAST_WALLPAPER_FILE="$HOME/.last-wallpaper"
|
||||
WALLPAPER_DIR="$HOME/wallpaper"
|
||||
|
||||
# Get a list of all wallpapers, exclude lock.png
|
||||
WALLPAPERS=($(find $WALLPAPER_DIR -type f \( -iname "*.jpg" -o -iname "*.png" \) ! -iname "lock.png"))
|
||||
NUM_WALLPAPERS=${#WALLPAPERS[@]}
|
||||
|
||||
# Read the counter
|
||||
COUNTER=$(cat $COUNTER_FILE)
|
||||
|
||||
# Increment the counter
|
||||
COUNTER=$(( (COUNTER + 1) % NUM_WALLPAPERS ))
|
||||
|
||||
# Update the counter file
|
||||
echo $COUNTER > $COUNTER_FILE
|
||||
|
||||
# Set the new wallpaper
|
||||
feh --bg-fill "${WALLPAPERS[$COUNTER]}"
|
||||
|
||||
# Store the last wallpaper
|
||||
echo "${WALLPAPERS[$COUNTER]}" > $LAST_WALLPAPER_FILE
|
||||
|
||||
1
polybar/scripts/offset.txt
Normal file
1
polybar/scripts/offset.txt
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
9
polybar/scripts/opacitytoggle.sh
Executable file
9
polybar/scripts/opacitytoggle.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/sh
|
||||
if (($(ps -aux | grep [p]icom | wc -l) > 0))
|
||||
then
|
||||
polybar-msg hook blur-toggle 1
|
||||
pkill -9 picom
|
||||
else
|
||||
polybar-msg hook blur-toggle 2
|
||||
picom -b --config=/home/r/.config/picom/picom.conf --experimental-backends --backend glx --blur-method dual_kawase &
|
||||
fi
|
||||
40
polybar/scripts/polytiramisu.sh
Executable file
40
polybar/scripts/polytiramisu.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
# Show tiramisu notifications in polybar.
|
||||
|
||||
# How many seconds notification is displayed:
|
||||
display_duration=7.0
|
||||
|
||||
# Maximum number of characters:
|
||||
char_limit=150
|
||||
|
||||
# Replace app names with nerd font logos
|
||||
use_nerd_font="true"
|
||||
|
||||
|
||||
# Stop old tiramisu processes if any:
|
||||
pgrep -x tiramisu >/dev/null && killall tiramisu
|
||||
|
||||
# Start a new tiramisu process:
|
||||
tiramisu -o '#summary #body' |
|
||||
while read -r line; do
|
||||
|
||||
# Replace app names with icons
|
||||
if [ $use_nerd_font == "true" ]; then
|
||||
line="$(echo "$line" | sed -r 's/Telegram Desktop//')"
|
||||
line="$(echo "$line" | sed -r 's/NordVPN//')"
|
||||
line="$(echo "$line" | sed -r 's/VLC//')"
|
||||
line="$(echo "$line" | sed -r 's/Kdenlive//')"
|
||||
line="$(echo "$line" | sed -r 's/Wifi//')"
|
||||
line="$(echo "$line" | sed -r 's/Firefox//')"
|
||||
fi
|
||||
|
||||
# Cut notification by character limit:
|
||||
if [ "${#line}" -gt "$char_limit" ]; then
|
||||
line="$(echo "$line" | cut -c1-$((char_limit-1)))…"
|
||||
fi
|
||||
|
||||
# Display notification for the duration time:
|
||||
echo "$line"
|
||||
sleep "$display_duration"
|
||||
echo " "
|
||||
done
|
||||
12
polybar/scripts/running_programs.sh
Executable file
12
polybar/scripts/running_programs.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Loop over all open windows
|
||||
wmctrl -lx | awk '{print $1,$3}' | while read -r id class; do
|
||||
# Extract the application name from the window class
|
||||
appname=$(echo $class | awk -F '.' '{print $2}' | awk '{print tolower($0)}')
|
||||
|
||||
# Format each application name as a clickable Polybar action
|
||||
echo -n "%{A1:wmctrl -ia $id:}$appname%{A} "
|
||||
done
|
||||
|
||||
echo
|
||||
5
polybar/scripts/showcrypto.sh
Executable file
5
polybar/scripts/showcrypto.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
polybar cryptobar &
|
||||
sleep 10
|
||||
kill $(pgrep polybar | tail -n 1)
|
||||
21
polybar/scripts/showtray.sh
Executable file
21
polybar/scripts/showtray.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##old
|
||||
#polybar traybar &
|
||||
#sleep 10
|
||||
#kill $(pgrep polybar | tail -n 1)
|
||||
##old
|
||||
|
||||
# Path to a file where the Polybar tray PID will be stored
|
||||
PID_FILE="/tmp/polybar_tray.pid"
|
||||
|
||||
# Check if the PID file exists and if the process is running
|
||||
if [ -f "$PID_FILE" ] && kill -0 $(cat "$PID_FILE") 2>/dev/null; then
|
||||
# If so, kill the process and remove the PID file
|
||||
kill $(cat "$PID_FILE") && rm -f "$PID_FILE"
|
||||
else
|
||||
# Otherwise, launch polybar and store its PID
|
||||
polybar traybar & echo $! > "$PID_FILE"
|
||||
# After 10 seconds, remove the PID file if the user hasn't already closed the tray
|
||||
sleep 10 && [ -f "$PID_FILE" ] && kill $(cat "$PID_FILE") && rm -f "$PID_FILE"
|
||||
fi
|
||||
16
polybar/scripts/toggle_module_batter_label.sh
Executable file
16
polybar/scripts/toggle_module_batter_label.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
TOGGLE_FILE=~/.config/polybar/scripts/battery_toggle_state
|
||||
|
||||
# Read the current state
|
||||
CURRENT_STATE=$(cat $TOGGLE_FILE)
|
||||
|
||||
# Toggle the state
|
||||
if [ "$CURRENT_STATE" == "icon" ]; then
|
||||
echo "percentage" > $TOGGLE_FILE
|
||||
else
|
||||
echo "icon" > $TOGGLE_FILE
|
||||
fi
|
||||
|
||||
# Notify Polybar to refresh the module
|
||||
polybar-msg hook battery 1
|
||||
12
polybar/scripts/toggle_module_label.sh
Executable file
12
polybar/scripts/toggle_module_label.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# The argument $1 should be the name of the module you want to toggle
|
||||
TOGGLE_FILE="$HOME/.toggle_${1}_label"
|
||||
|
||||
if [ -f "$TOGGLE_FILE" ]; then
|
||||
rm "$TOGGLE_FILE"
|
||||
else
|
||||
touch "$TOGGLE_FILE"
|
||||
fi
|
||||
|
||||
polybar-msg hook $1 1
|
||||
17
polybar/scripts/touchpad-toggle.sh
Executable file
17
polybar/scripts/touchpad-toggle.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare -i ID
|
||||
ID=`xinput list | grep -Eo 'Touchpad\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}'`
|
||||
# ID=16
|
||||
declare -i STATE
|
||||
STATE=`xinput list-props $ID|grep 'Device Enabled'|awk '{print $4}'`
|
||||
if [ $STATE -eq 1 ]
|
||||
then
|
||||
xinput disable $ID
|
||||
echo "Touchpad disabled."
|
||||
notify-send "Touchpad disabled"
|
||||
else
|
||||
xinput enable $ID
|
||||
echo "Touchpad enabled."
|
||||
notify-send "Touchpad enabled"
|
||||
fi
|
||||
331
polybar/scripts/weather.sh
Executable file
331
polybar/scripts/weather.sh
Executable file
@@ -0,0 +1,331 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SETTINGS vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
|
||||
# API settings ________________________________________________________________
|
||||
|
||||
# APIKEY=`cat $HOME/.owm-key`
|
||||
APIKEY=
|
||||
# if you leave these empty location will be picked based on your ip-adres
|
||||
CITY_NAME='Tokyo'
|
||||
COUNTRY_CODE='JP'
|
||||
# Desired output language
|
||||
LANG="en"
|
||||
# UNITS can be "metric", "imperial" or "kelvin". Set KNOTS to "yes" if you
|
||||
# want the wind in knots:
|
||||
|
||||
# | temperature | wind
|
||||
# -----------------------------------
|
||||
# metric | Celsius | km/h
|
||||
# imperial | Fahrenheit | miles/hour
|
||||
# kelvin | Kelvin | km/h
|
||||
|
||||
UNITS="metric"
|
||||
|
||||
# Color Settings ______________________________________________________________
|
||||
|
||||
COLOR_CLOUD="#5294e2"
|
||||
COLOR_THUNDER="#5294e2"
|
||||
COLOR_LIGHT_RAIN="#5294e2"
|
||||
COLOR_HEAVY_RAIN="#5294e2"
|
||||
COLOR_SNOW="#5294e2"
|
||||
COLOR_FOG="#5294e2"
|
||||
COLOR_TORNADO="#d3b987"
|
||||
COLOR_SUN="#5294e2"
|
||||
COLOR_MOON="#FFFFFF"
|
||||
COLOR_ERR="#f43753"
|
||||
COLOR_WIND="#5294e2"
|
||||
COLOR_COLD="#5294e2"
|
||||
COLOR_HOT="#5294e2"
|
||||
COLOR_NORMAL_TEMP="#5294e2"
|
||||
|
||||
# Leave "" if you want the default polybar color
|
||||
COLOR_TEXT=""
|
||||
# Polybar settings ____________________________________________________________
|
||||
|
||||
# Font for the weather icons
|
||||
WEATHER_FONT_CODE=7
|
||||
|
||||
# Font for the thermometer icon
|
||||
TEMP_FONT_CODE=8
|
||||
|
||||
# Wind settings _______________________________________________________________
|
||||
|
||||
# Display info about the wind or not. yes/no
|
||||
DISPLAY_WIND="no"
|
||||
|
||||
# Show beaufort level in windicon
|
||||
BEAUFORTICON="no"
|
||||
|
||||
# Display in knots. yes/no
|
||||
KNOTS="yes"
|
||||
|
||||
# How many decimals after the floating point
|
||||
DECIMALS=0
|
||||
|
||||
# Min. wind force required to display wind info (it depends on what
|
||||
# measurement unit you have set: knots, m/s or mph). Set to 0 if you always
|
||||
# want to display wind info. It's ignored if DISPLAY_WIND is false.
|
||||
|
||||
MIN_WIND=11
|
||||
|
||||
# Display the numeric wind force or not. If not, only the wind icon will
|
||||
# appear. yes/no
|
||||
|
||||
DISPLAY_FORCE="no"
|
||||
|
||||
# Display the wind unit if wind force is displayed. yes/no
|
||||
DISPLAY_WIND_UNIT="no"
|
||||
|
||||
# Thermometer settings ________________________________________________________
|
||||
|
||||
# When the thermometer icon turns red
|
||||
HOT_TEMP=25
|
||||
|
||||
# When the thermometer icon turns blue
|
||||
COLD_TEMP=0
|
||||
|
||||
# Other settings ______________________________________________________________
|
||||
|
||||
# Display the weather description. yes/no
|
||||
DISPLAY_LABEL="no"
|
||||
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
if [ "$COLOR_TEXT" != "" ]; then
|
||||
COLOR_TEXT_BEGIN="%{F$COLOR_TEXT}"
|
||||
COLOR_TEXT_END="%{F-}"
|
||||
fi
|
||||
if [ -z "$CITY_NAME" ]; then
|
||||
IP=`curl -s ifconfig.me` # == ip
|
||||
IPCURL=$(curl -s https://ipinfo.io/$IP)
|
||||
CITY_NAME=$(echo $IPCURL | jq -r ".city")
|
||||
COUNTRY_CODE=$(echo $IPCURL | jq -r ".country")
|
||||
fi
|
||||
|
||||
RESPONSE=""
|
||||
ERROR=0
|
||||
ERR_MSG=""
|
||||
if [ $UNITS = "kelvin" ]; then
|
||||
UNIT_URL=""
|
||||
else
|
||||
UNIT_URL="&units=$UNITS"
|
||||
fi
|
||||
URL="api.openweathermap.org/data/2.5/weather?appid=$APIKEY$UNIT_URL&lang=$LANG&q=$CITY_NAME,$COUNTRY_CODE"
|
||||
|
||||
function getData {
|
||||
ERROR=0
|
||||
# For logging purposes
|
||||
# echo " " >> "$HOME/.weather.log"
|
||||
# echo `date`" ################################" >> "$HOME/.weather.log"
|
||||
RESPONSE=`curl -s $URL`
|
||||
CODE="$?"
|
||||
if [ "$1" = "-d" ]; then
|
||||
echo $RESPONSE
|
||||
echo ""
|
||||
fi
|
||||
# echo "Response: $RESPONSE" >> "$HOME/.weather.log"
|
||||
RESPONSECODE=0
|
||||
if [ $CODE -eq 0 ]; then
|
||||
RESPONSECODE=`echo $RESPONSE | jq .cod`
|
||||
fi
|
||||
if [ $CODE -ne 0 ] || [ ${RESPONSECODE:=429} -ne 200 ]; then
|
||||
if [ $CODE -ne 0 ]; then
|
||||
ERR_MSG="curl Error $CODE"
|
||||
# echo "curl Error $CODE" >> "$HOME/.weather.log"
|
||||
else
|
||||
ERR_MSG="Conn. Err. $RESPONSECODE"
|
||||
# echo "API Error $RESPONSECODE" >> "$HOME/.weather.log"
|
||||
fi
|
||||
ERROR=1
|
||||
# else
|
||||
# echo "$RESPONSE" > "$HOME/.weather-last"
|
||||
# echo `date +%s` >> "$HOME/.weather-last"
|
||||
fi
|
||||
}
|
||||
function setIcons {
|
||||
if [ $WID -le 232 ]; then
|
||||
#Thunderstorm
|
||||
ICON_COLOR=$COLOR_THUNDER
|
||||
if [ $DATE -ge $SUNRISE -a $DATE -le $SUNSET ]; then
|
||||
ICON=""
|
||||
else
|
||||
ICON=""
|
||||
fi
|
||||
elif [ $WID -le 311 ]; then
|
||||
#Light drizzle
|
||||
ICON_COLOR=$COLOR_LIGHT_RAIN
|
||||
if [ $DATE -ge $SUNRISE -a $DATE -le $SUNSET ]; then
|
||||
ICON=""
|
||||
else
|
||||
ICON=""
|
||||
fi
|
||||
elif [ $WID -le 321 ]; then
|
||||
#Heavy drizzle
|
||||
ICON_COLOR=$COLOR_HEAVY_RAIN
|
||||
if [ $DATE -ge $SUNRISE -a $DATE -le $SUNSET ]; then
|
||||
ICON=""
|
||||
else
|
||||
ICON=""
|
||||
fi
|
||||
elif [ $WID -le 531 ]; then
|
||||
#Rain
|
||||
ICON_COLOR=$COLOR_HEAVY_RAIN
|
||||
if [ $DATE -ge $SUNRISE -a $DATE -le $SUNSET ]; then
|
||||
ICON=""
|
||||
else
|
||||
ICON=""
|
||||
fi
|
||||
elif [ $WID -le 622 ]; then
|
||||
#Snow
|
||||
ICON_COLOR=$COLOR_SNOW
|
||||
ICON=""
|
||||
elif [ $WID -le 771 ]; then
|
||||
#Fog
|
||||
ICON_COLOR=$COLOR_FOG
|
||||
ICON=""
|
||||
elif [ $WID -eq 781 ]; then
|
||||
#Tornado
|
||||
ICON_COLOR=$COLOR_TORNADO
|
||||
ICON=""
|
||||
elif [ $WID -eq 800 ]; then
|
||||
#Clear sky
|
||||
if [ $DATE -ge $SUNRISE -a $DATE -le $SUNSET ]; then
|
||||
ICON_COLOR=$COLOR_SUN
|
||||
ICON="盛"
|
||||
else
|
||||
ICON_COLOR=$COLOR_MOON
|
||||
ICON=""
|
||||
fi
|
||||
elif [ $WID -eq 801 ]; then
|
||||
# Few clouds
|
||||
if [ $DATE -ge $SUNRISE -a $DATE -le $SUNSET ]; then
|
||||
ICON_COLOR=$COLOR_SUN
|
||||
ICON=""
|
||||
else
|
||||
ICON_COLOR=$COLOR_MOON
|
||||
ICON=""
|
||||
fi
|
||||
elif [ $WID -le 804 ]; then
|
||||
# Overcast
|
||||
ICON_COLOR=$COLOR_CLOUD
|
||||
ICON=""
|
||||
else
|
||||
ICON_COLOR=$COLOR_ERR
|
||||
ICON=""
|
||||
fi
|
||||
WIND=""
|
||||
WINDFORCE=`echo "$RESPONSE" | jq .wind.speed`
|
||||
WINDICON=""
|
||||
if [ $BEAUFORTICON == "yes" ];then
|
||||
WINDFORCE2=`echo "scale=$DECIMALS;$WINDFORCE * 3.6 / 1" | bc`
|
||||
if [ $WINDFORCE2 -le 1 ]; then
|
||||
WINDICON=""
|
||||
elif [ $WINDFORCE2 -gt 1 ] && [ $WINDFORCE2 -le 5 ]; then
|
||||
WINDICON=""
|
||||
elif [ $WINDFORCE2 -gt 5 ] && [ $WINDFORCE2 -le 11 ]; then
|
||||
WINDICON=""
|
||||
elif [ $WINDFORCE2 -gt 11 ] && [ $WINDFORCE2 -le 19 ]; then
|
||||
WINDICON=""
|
||||
elif [ $WINDFORCE2 -gt 19 ] && [ $WINDFORCE2 -le 28 ]; then
|
||||
WINDICON=""
|
||||
elif [ $WINDFORCE2 -gt 28 ] && [ $WINDFORCE2 -le 38 ]; then
|
||||
WINDICON=""
|
||||
elif [ $WINDFORCE2 -gt 38 ] && [ $WINDFORCE2 -le 49 ]; then
|
||||
WINDICON=""
|
||||
elif [ $WINDFORCE2 -gt 49 ] && [ $WINDFORCE2 -le 61 ]; then
|
||||
WINDICON=""
|
||||
elif [ $WINDFORCE2 -gt 61 ] && [ $WINDFORCE2 -le 74 ]; then
|
||||
WINDICON=""
|
||||
elif [ $WINDFORCE2 -gt 74 ] && [ $WINDFORCE2 -le 88 ]; then
|
||||
WINDICON=""
|
||||
elif [ $WINDFORCE2 -gt 88 ] && [ $WINDFORCE2 -le 102 ]; then
|
||||
WINDICON=""
|
||||
elif [ $WINDFORCE2 -gt 102 ] && [ $WINDFORCE2 -le 117 ]; then
|
||||
WINDICON=""
|
||||
elif [ $WINDFORCE2 -gt 117 ]; then
|
||||
WINDICON=""
|
||||
fi
|
||||
fi
|
||||
if [ $KNOTS = "yes" ]; then
|
||||
case $UNITS in
|
||||
"imperial")
|
||||
# The division by one is necessary because scale works only for divisions. bc is stupid.
|
||||
WINDFORCE=`echo "scale=$DECIMALS;$WINDFORCE * 0.8689762419 / 1" | bc`
|
||||
;;
|
||||
*)
|
||||
WINDFORCE=`echo "scale=$DECIMALS;$WINDFORCE * 1.943844 / 1" | bc`
|
||||
;;
|
||||
esac
|
||||
else
|
||||
if [ $UNITS != "imperial" ]; then
|
||||
# Conversion from m/s to km/h
|
||||
WINDFORCE=`echo "scale=$DECIMALS;$WINDFORCE * 3.6 / 1" | bc`
|
||||
else
|
||||
WINDFORCE=`echo "scale=$DECIMALS;$WINDFORCE / 1" | bc`
|
||||
fi
|
||||
fi
|
||||
if [ "$DISPLAY_WIND" = "yes" ] && [ `echo "$WINDFORCE >= $MIN_WIND" |bc -l` -eq 1 ]; then
|
||||
WIND="%{T$WEATHER_FONT_CODE}%{F$COLOR_WIND}$WINDICON%{F-}%{T-}"
|
||||
if [ $DISPLAY_FORCE = "yes" ]; then
|
||||
WIND="$WIND $COLOR_TEXT_BEGIN$WINDFORCE$COLOR_TEXT_END"
|
||||
if [ $DISPLAY_WIND_UNIT = "yes" ]; then
|
||||
if [ $KNOTS = "yes" ]; then
|
||||
WIND="$WIND${COLOR_TEXT_BEGIN}kn$COLOR_TEXT_END"
|
||||
elif [ $UNITS = "imperial" ]; then
|
||||
WIND="$WIND${COLOR_TEXT_BEGIN}mph$COLOR_TEXT_END"
|
||||
else
|
||||
WIND="$WIND${COLOR_TEXT_BEGIN}km/h$COLOR_TEXT_END"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
WIND="$WIND |"
|
||||
fi
|
||||
if [ "$UNITS" = "metric" ]; then
|
||||
TEMP_ICON="糖"
|
||||
elif [ "$UNITS" = "imperial" ]; then
|
||||
TEMP_ICON="宅"
|
||||
else
|
||||
TEMP_ICON="洞"
|
||||
fi
|
||||
|
||||
TEMP=`echo "$TEMP" | cut -d "." -f 1`
|
||||
|
||||
if [ "$TEMP" -le $COLD_TEMP ]; then
|
||||
TEMP="%{F$COLOR_COLD}%{T$TEMP_FONT_CODE}%{T-}%{F-}$COLOR_TEXT_BEGIN%{T$TEMP_FONT_CODE}$TEMP%{T$TEMP_FONT_CODE}$TEMP_ICON%{T-}$COLOR_TEXT_END"
|
||||
elif [ `echo "$TEMP >= $HOT_TEMP" | bc` -eq 1 ]; then
|
||||
TEMP="%{F$COLOR_HOT}%{T$TEMP_FONT_CODE}%{T-}%{F-}$COLOR_TEXT_BEGIN%{T$TEMP_FONT_CODE}$TEMP%{T$TEMP_FONT_CODE}$TEMP_ICON%{T-}$COLOR_TEXT_END"
|
||||
else
|
||||
TEMP="%{F$COLOR_NORMAL_TEMP}%{T$TEMP_FONT_CODE}%{T-}%{F-}$COLOR_TEXT_BEGIN%{T$TEMP_FONT_CODE}$TEMP%{T$TEMP_FONT_CODE}$TEMP_ICON%{T-}$COLOR_TEXT_END"
|
||||
fi
|
||||
}
|
||||
|
||||
function outputCompact {
|
||||
OUTPUT="$WIND%{T$WEATHER_FONT_CODE}%{F$ICON_COLOR}$ICON%{F-}%{T-} $ERR_MSG$COLOR_TEXT_BEGIN$DESCRIPTION$COLOR_TEXT_END$TEMP"
|
||||
# OUTPUT="$WIND %{T$WEATHER_FONT_CODE}%{F$ICON_COLOR}$ICON%{F-}%{T-} $ERR_MSG$COLOR_TEXT_BEGIN$DESCRIPTION$COLOR_TEXT_END| $TEMP"
|
||||
# echo "Output: $OUTPUT" >> "$HOME/.weather.log"
|
||||
echo "$OUTPUT"
|
||||
}
|
||||
|
||||
getData $1
|
||||
if [ $ERROR -eq 0 ]; then
|
||||
MAIN=`echo $RESPONSE | jq .weather[0].main`
|
||||
WID=`echo $RESPONSE | jq .weather[0].id`
|
||||
DESC=`echo $RESPONSE | jq .weather[0].description`
|
||||
SUNRISE=`echo $RESPONSE | jq .sys.sunrise`
|
||||
SUNSET=`echo $RESPONSE | jq .sys.sunset`
|
||||
DATE=`date +%s`
|
||||
WIND=""
|
||||
TEMP=`echo $RESPONSE | jq .main.temp`
|
||||
if [ $DISPLAY_LABEL = "yes" ]; then
|
||||
DESCRIPTION=`echo "$RESPONSE" | jq .weather[0].description | tr -d '"' | sed 's/.*/\L&/; s/[a-z]*/\u&/g'`" "
|
||||
else
|
||||
DESCRIPTION=""
|
||||
fi
|
||||
PRESSURE=`echo $RESPONSE | jq .main.pressure`
|
||||
HUMIDITY=`echo $RESPONSE | jq .main.humidity`
|
||||
setIcons
|
||||
outputCompact
|
||||
else
|
||||
echo " "
|
||||
fi
|
||||
63
polybar/scripts/wlan_format.sh
Executable file
63
polybar/scripts/wlan_format.sh
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Toggle file for switching between SSID and signal strength
|
||||
TOGGLE_FILE="$HOME/.toggle_wlan_label"
|
||||
|
||||
# Function to check Ethernet connection
|
||||
check_ethernet() {
|
||||
if ip a show enp8s0 | grep -q "state UP"; then
|
||||
echo "E"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to get WiFi signal strength as a percentage
|
||||
get_signal_strength() {
|
||||
local strength=$(iwconfig wlan0 2>/dev/null | grep 'Link Quality' | awk -F'=' '{print $2}' | awk '{print $1}')
|
||||
if [ -z "$strength" ]; then
|
||||
echo 0
|
||||
return
|
||||
fi
|
||||
local level=$(echo "$strength" | cut -d'/' -f1)
|
||||
local max=$(echo "$strength" | cut -d'/' -f2)
|
||||
local percent=$(( ($level * 100) / $max ))
|
||||
echo $percent
|
||||
}
|
||||
|
||||
# Check Ethernet connection first
|
||||
if check_ethernet; then
|
||||
echo "E"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if the toggle file exists
|
||||
if [ -f "$TOGGLE_FILE" ]; then
|
||||
# Display SSID if connected
|
||||
essid=$(iwgetid -r)
|
||||
if [ -z "$essid" ]; then
|
||||
# Display disconnected icon if not connected
|
||||
echo "%{A1:~/.config/polybar/scripts/toggle_module_label.sh wlan:}%{A}"
|
||||
elif [ "$essid" == "Hacker" ]; then
|
||||
# Display "H" if connected to "Hacker"
|
||||
echo "H"
|
||||
else
|
||||
# Display SSID
|
||||
echo "%{A1:~/.config/polybar/scripts/toggle_module_label.sh wlan:} $essid %{A}"
|
||||
fi
|
||||
else
|
||||
# Display signal strength icon
|
||||
strength=$(get_signal_strength)
|
||||
icon="" # Default icon for no signal
|
||||
if [ "$strength" -ge 80 ]; then
|
||||
icon="" # Signal 4
|
||||
elif [ "$strength" -ge 60 ]; then
|
||||
icon="" # Signal 3
|
||||
elif [ "$strength" -ge 40 ]; then
|
||||
icon="" # Signal 2
|
||||
elif [ "$strength" -ge 20 ]; then
|
||||
icon="" # Signal 1
|
||||
fi
|
||||
echo "%{A1:~/.config/polybar/scripts/toggle_module_label.sh wlan:} $icon %{A}"
|
||||
fi
|
||||
Reference in New Issue
Block a user