From c9d35a06ad3689426b4270b65fad3654efb0062f Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 30 Dec 2025 16:52:00 -0500 Subject: [PATCH] Steam detection added, bound to s in rp mode. --- i38.sh | 4 ++ scripts/ai.py | 11 ++++ scripts/bind_to_scratchpad.sh | 10 ++++ scripts/i3_watchdog.sh | 10 ++++ scripts/notes.py | 11 ++++ scripts/sysinfo.sh | 9 ++++ scripts/weather.sh | 97 ++++++++++++++++++++++------------- 7 files changed, 116 insertions(+), 36 deletions(-) diff --git a/i38.sh b/i38.sh index c21e31a..8f34669 100755 --- a/i38.sh +++ b/i38.sh @@ -1052,6 +1052,10 @@ fi) bindsym \$mod+e exec $emailClient, mode "default" # Web browser bound to w bindsym w exec $webBrowser, mode "default" +$(if command -v steam &> /dev/null ; then + echo "# Steam bound to s" + echo "bindsym s exec --no-startup-id command steam -bigpicture, mode \"default\"" +fi) # Kill window bound to k bindsym k kill, mode "default" $(if command -v mumble &> /dev/null ; then diff --git a/scripts/ai.py b/scripts/ai.py index 4d0a372..72e9a4a 100755 --- a/scripts/ai.py +++ b/scripts/ai.py @@ -1,4 +1,15 @@ #!/usr/bin/env python3 + +# This file is part of I38. + +# I38 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. + +# I38 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 I38. If not, see . + """ AI Assistant Interface Provides accessibility-focused AI interaction with multiple providers diff --git a/scripts/bind_to_scratchpad.sh b/scripts/bind_to_scratchpad.sh index 1d51104..061985d 100755 --- a/scripts/bind_to_scratchpad.sh +++ b/scripts/bind_to_scratchpad.sh @@ -1,5 +1,15 @@ #!/usr/bin/env bash +# This file is part of I38. + +# I38 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. + +# I38 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 I38. If not, see . + # Find out if we're using i3 or sway if ! [[ -n "${WAYLAND_DISPLAY}" ]]; then cmd="i3-msg" diff --git a/scripts/i3_watchdog.sh b/scripts/i3_watchdog.sh index 41f7b75..face703 100755 --- a/scripts/i3_watchdog.sh +++ b/scripts/i3_watchdog.sh @@ -1,5 +1,15 @@ #!/usr/bin/env bash +# This file is part of I38. + +# I38 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. + +# I38 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 I38. If not, see . + # I38 i3 Watchdog - Monitors i3 responsiveness and auto-restarts on lockup # This script runs in the background and checks if i3 is responding to commands diff --git a/scripts/notes.py b/scripts/notes.py index ab3ac32..025bf38 100755 --- a/scripts/notes.py +++ b/scripts/notes.py @@ -1,4 +1,15 @@ #!/usr/bin/env python3 + +# This file is part of I38. + +# I38 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. + +# I38 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 I38. If not, see . + import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk, GLib, Gio, Gdk diff --git a/scripts/sysinfo.sh b/scripts/sysinfo.sh index 88980b0..d6da45d 100755 --- a/scripts/sysinfo.sh +++ b/scripts/sysinfo.sh @@ -1,5 +1,14 @@ #!/usr/bin/env bash +# This file is part of I38. + +# I38 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. + +# I38 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 I38. If not, see . # Initialize variables cpuUsage=0 diff --git a/scripts/weather.sh b/scripts/weather.sh index 6ad0821..9b5feae 100755 --- a/scripts/weather.sh +++ b/scripts/weather.sh @@ -1,5 +1,14 @@ #!/usr/bin/env bash +# This file is part of I38. + +# I38 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. + +# I38 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 I38. If not, see . # Configuration settings defaultCity="Raleigh, NC" @@ -67,18 +76,17 @@ refreshBtn=0 quitBtn=1 settingsBtn=2 -trap "pkill -P $$" EXIT INT TERM +trap 'pkill -P $$' EXIT INT TERM # Load configuration if available if [ -f "$configFile" ]; then + # shellcheck source=/dev/null source "$configFile" # Convert lastWeatherUpdate string to integer if it exists [[ -n "$lastWeatherUpdate" ]] && weatherLastUpdate=$lastWeatherUpdate || weatherLastUpdate=0 if [[ -n "$city" ]]; then cityName="$city" - latitude="$latitude" - longitude="$longitude" fi # Try to reload saved weather data @@ -94,10 +102,10 @@ if [ -f "$configFile" ]; then varMax="savedForecastMax_$i" varCond="savedForecastCond_$i" - [[ -n "${!varDate}" ]] && forecastFormattedDates[$i]="${!varDate}" - [[ -n "${!varMin}" ]] && forecastMinTemps[$i]="${!varMin}" - [[ -n "${!varMax}" ]] && forecastMaxTemps[$i]="${!varMax}" - [[ -n "${!varCond}" ]] && forecastConditions[$i]="${!varCond}" + [[ -n "${!varDate}" ]] && forecastFormattedDates[i]="${!varDate}" + [[ -n "${!varMin}" ]] && forecastMinTemps[i]="${!varMin}" + [[ -n "${!varMax}" ]] && forecastMaxTemps[i]="${!varMax}" + [[ -n "${!varCond}" ]] && forecastConditions[i]="${!varCond}" done fi fi @@ -105,8 +113,10 @@ fi # Helper functions time_diff() { local timestamp="$1" - local now=$(date +%s) - local diff=$((now - timestamp)) + local now + local diff + now=$(date +%s) + diff=$((now - timestamp)) if [ $diff -lt 60 ]; then echo "just now" @@ -216,12 +226,14 @@ get_location() { if [[ $? -eq 0 && -n "$locationData" && $(echo "$locationData" | jq -e '.city') ]]; then echo "Location data received successfully" cityName=$(echo "$locationData" | jq -r '.city // "Unknown"') - local region=$(echo "$locationData" | jq -r '.region // ""') + local region + region=$(echo "$locationData" | jq -r '.region // ""') # Add region/state to city name if available [[ -n "$region" ]] && cityName="$cityName, $region" # Extract coordinates directly from the "loc" field - local loc=$(echo "$locationData" | jq -r '.loc // "0,0"') + local loc + loc=$(echo "$locationData" | jq -r '.loc // "0,0"') latitude=$(echo "$loc" | cut -d',' -f1) longitude=$(echo "$loc" | cut -d',' -f2) save_config @@ -236,17 +248,21 @@ get_location() { # Function to fetch weather data fetch_weather_data() { - local now=$(date +%s) - local elapsedMinutes=$(( (now - weatherLastUpdate) / 60 )) + local now + local elapsedMinutes + now=$(date +%s) + elapsedMinutes=$(( (now - weatherLastUpdate) / 60 )) # Only fetch if needed if [[ $weatherLastUpdate -eq 0 || $elapsedMinutes -ge $updateInterval ]]; then local url="https://api.open-meteo.com/v1/forecast?latitude=$latitude&longitude=$longitude¤t=temperature_2m,relative_humidity_2m,weather_code,wind_speed_10m&daily=weather_code,temperature_2m_max,temperature_2m_min&timezone=auto" - local response=$(curl -s --connect-timeout 10 "$url" 2>/dev/null) + local response + response=$(curl -s --connect-timeout 10 "$url" 2>/dev/null) if [[ $? -eq 0 && -n "$response" && $(echo "$response" | jq -e '.current' 2>/dev/null) ]]; then # Update current weather data - local tempCelsius=$(echo "$response" | jq -r '.current.temperature_2m // "--"' 2>/dev/null) + local tempCelsius + tempCelsius=$(echo "$response" | jq -r '.current.temperature_2m // "--"' 2>/dev/null) [[ "$tempCelsius" != "--" && "$tempCelsius" != "null" ]] && currentTemp=$(celsius_to_fahrenheit "$tempCelsius") || currentTemp="--" currentHumidity=$(echo "$response" | jq -r '.current.relative_humidity_2m // "--"' 2>/dev/null) @@ -260,7 +276,8 @@ fetch_weather_data() { currentWindSpeedMph="--" fi - local weatherCode=$(echo "$response" | jq -r '.current.weather_code // 0' 2>/dev/null) + local weatherCode + weatherCode=$(echo "$response" | jq -r '.current.weather_code // 0' 2>/dev/null) [[ "$weatherCode" == "null" ]] && weatherCode=0 currentConditions="${weatherCodes[$weatherCode]:-Unknown}" @@ -279,21 +296,24 @@ fetch_weather_data() { if [[ $(echo "$response" | jq -e '.daily' 2>/dev/null) ]]; then for i in {0..2}; do # Process forecast data - forecastDates[$i]=$(echo "$response" | jq -r ".daily.time[$i] // \"--\"" 2>/dev/null) - [[ "${forecastDates[$i]}" != "--" && "${forecastDates[$i]}" != "null" ]] && \ - forecastFormattedDates[$i]=$(format_date "${forecastDates[$i]}") || forecastFormattedDates[$i]="--" - - local minTempC=$(echo "$response" | jq -r ".daily.temperature_2m_min[$i] // \"--\"" 2>/dev/null) + forecastDates[i]=$(echo "$response" | jq -r ".daily.time[$i] // \"--\"" 2>/dev/null) + [[ "${forecastDates[i]}" != "--" && "${forecastDates[i]}" != "null" ]] && \ + forecastFormattedDates[i]=$(format_date "${forecastDates[i]}") || forecastFormattedDates[i]="--" + + local minTempC + minTempC=$(echo "$response" | jq -r ".daily.temperature_2m_min[$i] // \"--\"" 2>/dev/null) [[ "$minTempC" != "--" && "$minTempC" != "null" ]] && \ - forecastMinTemps[$i]=$(celsius_to_fahrenheit "$minTempC") || forecastMinTemps[$i]="--" - - local maxTempC=$(echo "$response" | jq -r ".daily.temperature_2m_max[$i] // \"--\"" 2>/dev/null) + forecastMinTemps[i]=$(celsius_to_fahrenheit "$minTempC") || forecastMinTemps[i]="--" + + local maxTempC + maxTempC=$(echo "$response" | jq -r ".daily.temperature_2m_max[$i] // \"--\"" 2>/dev/null) [[ "$maxTempC" != "--" && "$maxTempC" != "null" ]] && \ - forecastMaxTemps[$i]=$(celsius_to_fahrenheit "$maxTempC") || forecastMaxTemps[$i]="--" - - local code=$(echo "$response" | jq -r ".daily.weather_code[$i] // 0" 2>/dev/null) + forecastMaxTemps[i]=$(celsius_to_fahrenheit "$maxTempC") || forecastMaxTemps[i]="--" + + local code + code=$(echo "$response" | jq -r ".daily.weather_code[$i] // 0" 2>/dev/null) [[ "$code" == "null" ]] && code=0 - forecastConditions[$i]="${weatherCodes[$code]:-Unknown}" + forecastConditions[i]="${weatherCodes[$code]:-Unknown}" done fi @@ -315,7 +335,8 @@ change_location() { if [[ -n "$newLocation" && "$newLocation" != "$cityName" ]]; then # Try to parse the location using curl to a geocoding service - local result=$(curl -s --connect-timeout 10 "https://nominatim.openstreetmap.org/search?q=$newLocation&format=json" 2>/dev/null) + local result + result=$(curl -s --connect-timeout 10 "https://nominatim.openstreetmap.org/search?q=$newLocation&format=json" 2>/dev/null) if [[ -n "$result" && $(echo "$result" | jq -e '.[0]') ]]; then cityName="$newLocation" @@ -382,7 +403,8 @@ End of text. Press Control+Home to return to the beginning." # Function to display settings dialog display_settings() { - local ret=$(yad --pname=I38WeatherSettings \ + local ret + ret=$(yad --pname=I38WeatherSettings \ --title="I38 Weather Settings" \ --form \ --width=400 \ @@ -397,9 +419,12 @@ display_settings() { local saveResult=$? if [[ $saveResult -eq 0 && -n "$ret" ]]; then - local newLocation=$(echo "$ret" | cut -d"|" -f1) - local newUnit=$(echo "$ret" | cut -d"|" -f3) - local newInterval=$(echo "$ret" | cut -d"|" -f4) + local newLocation + local newUnit + local newInterval + newLocation=$(echo "$ret" | cut -d"|" -f1) + newUnit=$(echo "$ret" | cut -d"|" -f3) + newInterval=$(echo "$ret" | cut -d"|" -f4) # Apply any changes [[ -n "$newLocation" && "$newLocation" != "$cityName" ]] && change_location "$newLocation" @@ -419,17 +444,17 @@ while : ; do # Handle button actions case $ret in - $refreshBtn) + "$refreshBtn") # Force a weather update weatherLastUpdate=0 continue ;; - $settingsBtn) + "$settingsBtn") # Display settings dialog display_settings continue ;; - $quitBtn|252) + "$quitBtn"|252) # Quit button or window closed break ;;