This commit is contained in:
2025-12-30 22:37:13 +02:00
parent 0dabe39be9
commit bd0b49abce
11 changed files with 1270 additions and 53 deletions

View File

@@ -74,24 +74,24 @@ output * bg /home/raga/.config/sway/wallpaper.jpg fill
# Multi-monitor setup
# You can get your output names by running: swaymsg -t get_outputs
# DP-2 is the primary monitor on the left, and DP-1 is on the right.
output HDMI-A-1 {
output DP-1 {
position 0 0
# ECO
# mode 2560x1440@60Hz
# ECO
# mode 2560x1440@60Hz
# FULL
mode 2560x1440@120Hz
# FULL
mode 3840x2160@165Hz
}
output DP-1 {
position 2560 0
output DP-2 {
position 3840 0
# ECO
# mode 2560x1440@60Hz
# ECO
mode 2560x1440@60Hz
# FULL
modeline 586.59 2560 2568 2600 2640 1440 1529 1537 1543 +hsync -vsync
# FULL
# modeline 586.59 2560 2568 2600 2640 1440 1529 1537 1543 +hsync -vsync
}
###############################################################################
@@ -457,10 +457,10 @@ mode "Resize Mode" {
bindsym Up resize shrink height 6 px or 6 ppt
bindsym Right resize grow width 6 px or 6 ppt
bindsym Shift+Left resize shrink width 24 px or 24 ppt
bindsym Shift+Down resize grow height 24 px or 24 ppt
bindsym Shift+Up resize shrink height 24 px or 24 ppt
bindsym Shift+Right resize grow width 24 px or 24 ppt
bindsym Shift+Left resize shrink width 48 px or 48 ppt
bindsym Shift+Down resize grow height 48 px or 48 ppt
bindsym Shift+Up resize shrink height 48 px or 48 ppt
bindsym Shift+Right resize grow width 48 px or 48 ppt
## Resize // Resize Window // k j h l ##
bindsym $left resize shrink width 6 px or 6 ppt
@@ -468,10 +468,10 @@ mode "Resize Mode" {
bindsym $up resize shrink height 6 px or 6 ppt
bindsym $right resize grow width 6 px or 6 ppt
bindsym Shift+$left resize shrink width 24 px or 24 ppt
bindsym Shift+$down resize grow height 24 px or 24 ppt
bindsym Shift+$up resize shrink height 24 px or 24 ppt
bindsym Shift+$right resize grow width 24 px or 24 ppt
bindsym Shift+$left resize shrink width 48 px or 48 ppt
bindsym Shift+$down resize grow height 48 px or 48 ppt
bindsym Shift+$up resize shrink height 48 px or 48 ppt
bindsym Shift+$right resize grow width 48 px or 48 ppt
## Resize // Exit Resize Mode // Escape or Enter ##
bindsym Return mode "default"
@@ -546,6 +546,7 @@ exec lxqt-policykit-agent # Authentication agent (comment out if not needed)
exec --no-startup-id blueman-applet
exec --no-startup-id nm-applet
#exec --no-startup-id home_dotfiles/.config/sway/set_random_bg.sh
# Include additional config files if they exist
include /etc/sway/config.d/*

View File

@@ -10,6 +10,15 @@ click = [
{button = "left", cmd = "~/.config/sway/osrs-mode-toggle.sh", update = true}
]
[[block]]
block = "custom"
command = "echo ''"
format = " $text "
interval = 1
click = [
{button = "left", cmd = "~/.config/sway/set_random_bg.sh", update = false},
]
#[[block]]
#block = "custom"
#command = "~/.config/sway/get-focused-window.sh"

View File

@@ -0,0 +1,32 @@
#!/bin/bash
# Find a random image file
#IMAGE=$(find /run/media/raga/970/qBittorrent/nsfw/xd -type f \( -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' \) | shuf -n 1)
IMAGE=$(find /run/media/raga/970/images/cars/wallpaper -type f \( -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' \) | shuf -n 1)
if [ -n "$IMAGE" ]; then
echo "Image: $IMAGE"
# Try to get image dimensions using identify (ImageMagick)
DIMENSIONS=$(identify -format "%wx%h" "$IMAGE" 2>/dev/null)
if [ -n "$DIMENSIONS" ]; then
echo "Dimensions: $DIMENSIONS"
WIDTH=$(echo "$DIMENSIONS" | cut -d'x' -f1)
HEIGHT=$(echo "$DIMENSIONS" | cut -d'x' -f2)
# Determine if portrait (height > width) or landscape
if [ "$HEIGHT" -gt "$WIDTH" ]; then
# Portrait image - use "fit" to maintain aspect ratio
echo "Portrait image - using fit"
swaymsg "output * bg \"$IMAGE\" fit"
else
# Landscape image - use "fill" to fill the screen
echo "Landscape image - using fill"
swaymsg "output * bg \"$IMAGE\" fill"
fi
else
# Fallback to fill if we can't determine dimensions
echo "Could not determine dimensions - using fill"
swaymsg "output * bg \"$IMAGE\" fill"
fi
fi

View File

@@ -2,12 +2,12 @@
set -Eeu -o pipefail
# Simplified weather script for i3status-rust
# Based on the original weather script but adapted for Sway/i3status-rust
# Improved weather script for i3status-rust using JSON API
# Based on the original weather script but optimized for Sway/i3status-rust
# Information on the various formats: https://github.com/chubin/wttr.in
VALUE_WEATHER_FORMAT=${weather_format:-"%c%f"}
VALUE_WEATHER_FORMAT="?format=${VALUE_WEATHER_FORMAT}"
# Location (defaults to Pärnu as in your original script)
VALUE_WEATHER_LOCATION=${weather_location:-"Pärnu"}
VALUE_WEATHER_ERROR_MESSAGE=${error_message:-"⛔"}
# Determine units to use for temperature
# We don't supply a default here because wttr.in is "smart" enough to choose for us
@@ -16,40 +16,100 @@ if [ -n "${WEATHER_UNIT}" ]; then
WEATHER_UNIT="&${WEATHER_UNIT}"
fi
# Location (defaults to Pärnu as in your original script)
VALUE_WEATHER_LOCATION=${weather_location:-"Pärnu"}
VALUE_WEATHER_ERROR_MESSAGE=${error_message:-"⛔"}
VALUE_FETCH_WEATHER_URL="https://wttr.in/${VALUE_WEATHER_LOCATION}${VALUE_WEATHER_FORMAT}${WEATHER_UNIT}"
# Use JSON API to get all data in a single request
VALUE_FETCH_WEATHER_URL="https://wttr.in/${VALUE_WEATHER_LOCATION}?format=j1"
# Get weather data
WEATHER=$(curl -sS "$VALUE_FETCH_WEATHER_URL" 2>/dev/null || echo "${VALUE_WEATHER_ERROR_MESSAGE}")
# Get sunrise/sunset data
VALUE_SUNSET_SUNRISE_FORMAT="?format=%S-%s%20%m+"
SUNRISE_SUNSET=$(curl -sS "https://wttr.in/${VALUE_WEATHER_LOCATION}${VALUE_SUNSET_SUNRISE_FORMAT}${WEATHER_UNIT}" 2>/dev/null || echo "")
if [ -n "$SUNRISE_SUNSET" ]; then
SUNRISE_VALUE=$(echo ${SUNRISE_SUNSET} | cut -c 1-5)
SUNSET_VALUE=$(echo ${SUNRISE_SUNSET} | cut -c 10-14)
SUNRISE_SUNSET_TEXT=" (${SUNRISE_VALUE}-${SUNSET_VALUE})"
else
SUNRISE_SUNSET_TEXT=""
fi
# Get weather data using JSON API
WEATHER_JSON=$(curl -sS "$VALUE_FETCH_WEATHER_URL" 2>/dev/null || echo "{}")
# Check for errors
if echo "${WEATHER}" | grep -q -P "Unknown\slocation"; then
WEATHER=${VALUE_WEATHER_ERROR_MESSAGE}
if echo "$WEATHER_JSON" | grep -q "Unknown location"; then
echo "${VALUE_WEATHER_ERROR_MESSAGE}"
exit 0
fi
# Output for i3status-rust (plain text)
echo "${WEATHER}${SUNRISE_SUNSET_TEXT}"
# Extract data using jq (should be available on most systems)
if command -v jq &>/dev/null; then
# Extract current weather condition and temperature
WEATHER_CONDITION=$(echo "$WEATHER_JSON" | jq -r '.current_condition[0].weatherDesc[0].value' 2>/dev/null || echo "")
TEMP_C=$(echo "$WEATHER_JSON" | jq -r '.current_condition[0].temp_C' 2>/dev/null || echo "")
# Extract sunrise and sunset times
SUNRISE=$(echo "$WEATHER_JSON" | jq -r '.weather[0].astronomy[0].sunrise' 2>/dev/null || echo "")
SUNSET=$(echo "$WEATHER_JSON" | jq -r '.weather[0].astronomy[0].sunset' 2>/dev/null || echo "")
# Convert to simple format if we have data
if [ -n "$WEATHER_CONDITION" ] && [ -n "$TEMP_C" ]; then
# Map weather conditions to icons (simplified)
case "$WEATHER_CONDITION" in
*"Sunny"*|*"Clear"*) ICON="☀️";;
*"Partly cloudy"*|*"Cloudy"*) ICON="⛅";;
*"Overcast"*) ICON="☁️";;
*"Rain"*|*"Drizzle"*) ICON="🌧️";;
*"Snow"*) ICON="❄️";;
*"Thunder"*) ICON="⛈️";;
*"Fog"*|*"Mist"*) ICON="🌫️";;
*) ICON="🌤️";;
esac
WEATHER="${ICON} ${TEMP_C}°C"
# Format sunrise/sunset times (convert from "09:10 AM" to "09:10")
if [ -n "$SUNRISE" ] && [ -n "$SUNSET" ]; then
# Remove AM/PM and convert to 24-hour format
SUNRISE_24=$(echo "$SUNRISE" | sed 's/ AM//;s/ PM//;s/^0//' | awk -F: '{if($1==12) print "00:"$2; else if($1<12) print $1":"$2; else print $1":"$2}')
SUNSET_24=$(echo "$SUNSET" | sed 's/ AM//;s/ PM//;s/^0//' | awk -F: '{if($1==12) print "00:"$2; else if($1<12) print $1":"$2; else print $1":"$2}')
# Remove leading zeros from hours for consistency
SUNRISE_24=$(echo "$SUNRISE_24" | sed 's/^0//')
SUNSET_24=$(echo "$SUNSET_24" | sed 's/^0//')
SUNRISE_SUNSET_TEXT=" (${SUNRISE_24}-${SUNSET_24})"
else
SUNRISE_SUNSET_TEXT=""
fi
# Output for i3status-rust (plain text)
echo "${WEATHER}${SUNRISE_SUNSET_TEXT}"
else
echo "${VALUE_WEATHER_ERROR_MESSAGE}"
fi
else
# Fallback to original method if jq is not available
echo "⚠️ jq not found, using fallback method"
# Get basic weather data
VALUE_WEATHER_FORMAT=${weather_format:-"%c%f"}
VALUE_WEATHER_FORMAT="?format=${VALUE_WEATHER_FORMAT}"
WEATHER=$(curl -sS "https://wttr.in/${VALUE_WEATHER_LOCATION}${VALUE_WEATHER_FORMAT}${WEATHER_UNIT}" 2>/dev/null || echo "${VALUE_WEATHER_ERROR_MESSAGE}")
# Get sunrise/sunset data
VALUE_SUNSET_SUNRISE_FORMAT="?format=%S-%s"
SUNRISE_SUNSET=$(curl -sS "https://wttr.in/${VALUE_WEATHER_LOCATION}${VALUE_SUNSET_SUNRISE_FORMAT}${WEATHER_UNIT}" 2>/dev/null || echo "")
if [ -n "$SUNRISE_SUNSET" ]; then
SUNRISE_VALUE=$(echo ${SUNRISE_SUNSET} | cut -c 1-5)
SUNSET_VALUE=$(echo ${SUNRISE_SUNSET} | cut -c 7-11)
SUNRISE_SUNSET_TEXT=" (${SUNRISE_VALUE}-${SUNSET_VALUE})"
else
SUNRISE_SUNSET_TEXT=""
fi
# Check for errors
if echo "${WEATHER}" | grep -q -P "Unknown\slocation"; then
WEATHER=${VALUE_WEATHER_ERROR_MESSAGE}
fi
# Output for i3status-rust (plain text)
echo "${WEATHER}${SUNRISE_SUNSET_TEXT}"
fi
# Handle click events (for i3status-rust custom block)
if [ "${BLOCK_BUTTON:-}" = "1" ]; then
# Left click - show detailed weather
FULL_WEATHER=$(curl -sS "https://wttr.in/${VALUE_WEATHER_LOCATION}?format=%l:+%c+%f+%h+%p+%P+%m+%w+%S+%s" 2>/dev/null || echo "${VALUE_WEATHER_ERROR_MESSAGE}")
notify-send "Weather Details" "$FULL_WEATHER" -t 10000
# Left click - show detailed weather using JSON
DETAILED_WEATHER=$(curl -sS "https://wttr.in/${VALUE_WEATHER_LOCATION}?format=%l:+%c+%f+%h+%p+%P+%m+%w+%S-%s" 2>/dev/null || echo "${VALUE_WEATHER_ERROR_MESSAGE}")
notify-send "Weather Details" "$DETAILED_WEATHER" -t 10000
elif [ "${BLOCK_BUTTON:-}" = "3" ]; then
# Right click - open weather website
xdg-open "https://wttr.in/${VALUE_WEATHER_LOCATION}" >/dev/null 2>&1 &
fi
fi