You are not logged in.
script for the weather use your api de openweather icons icomoon
#!/bin/bash
# Establecer las variables de entorno GTK para los colores
#export GTK_THEME=Numix-BLACK-Pomegranate
export GTK_OVERLAY_SCROLLING=0
# Define tu clave de API de OpenWeatherMap
API_KEY="your api here"
# Obtener la información climática basada en la IP del usuario usando OpenWeatherMap
weather_info=$(curl -s "http://api.openweathermap.org/data/2.5/weather?q=$(curl -s https://ipinfo.io/city),$(curl -s https://ipinfo.io/country)&appid=$API_KEY&units=metric&lang=es")
# Extraer los datos relevantes del JSON obtenido
localidad=$(echo "$weather_info" | jq -r '.name')
temperatura=$(echo "$weather_info" | jq -r '.main.temp')
humedad=$(echo "$weather_info" | jq -r '.main.humidity')
viento_metros_segundo=$(echo "$weather_info" | jq -r '.wind.speed')
viento_km_h=$(echo "scale=2; $viento_metros_segundo * 3.6" | bc)
presion=$(echo "$weather_info" | jq -r '.main.pressure')
descripcion=$(echo "$weather_info" | jq -r '.weather[0].description' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2));}1')
main_clima=$(echo "$weather_info" | jq -r '.weather[0].main')
visibilidad_metros=$(echo "$weather_info" | jq -r '.visibility')
visibilidad_km=$(echo "scale=2; $visibilidad_metros / 1000" | bc)
# Función para determinar el icono del clima según el horario del día
determinar_icono_clima() {
current_hour=$(date +%H)
case $1 in
"Clear")
if [ "$current_hour" -ge 6 ] && [ "$current_hour" -lt 18 ]; then
echo "" # Ícono del sol para el día
else
echo "" # Ícono de la luna para la noche
fi
;;
"Clouds") echo "";;
"Rain") echo "";;
"Thunderstorm") echo "";;
"Snow") echo "";;
"Fog") echo "";;
*) echo "";;
esac
}
# Función principal
main() {
# Especificar la posición de la ventana en la pantalla
# posx=1050 # Posición X en píxeles # Arriba a la derecha
posx=560 # Posición X en píxeles # Centro
posy=50 # Posición Y en píxeles
# Determinar el icono del clima
icono_clima=$(determinar_icono_clima "$main_clima")
# Mostrar el calendario con solo el botón "Salir"
yad --title "Clima en mi Ciudad" \
--text " $localidad\ - $icono_clima $descripcion\nTemperatura: $temperatura °C\nHumedad: $humedad %\nViento: $viento_km_h km/h\nPresión: $presion hPa\nVisibilidad: $visibilidad_km km" \
--fixed \
--width=250 \
--height=130 \
--undecorated \
--close-on-unfocus \
--posx=$posx \
--posy=$posy \
--no-buttons \
--transient \
--alpha=0.75
}
# Llamar a la función principal
main
code for use in executor tint2 for weather, use your own api key for openweather
#!/bin/sh
# Open Weather Map API key, regístrate en http://openweathermap.org para obtener uno ;)
API_KEY="YOUR API KEY HERE"
ICON_SUNNY_DAY=""
ICON_SUNNY_NIGHT=""
ICON_CLOUDY=""
ICON_RAINY=""
ICON_STORM=""
ICON_SNOW=""
ICON_FOG=""
ICON_MISC=""
TEXT_SUNNY="Despejado"
TEXT_CLOUDY="Nublado"
TEXT_RAINY="Lluvia"
TEXT_STORM="Tormenta"
TEXT_SNOW="Nieve"
TEXT_FOG="Niebla"
SYMBOL_CELSIUS="˚C"
# Obtener la ubicación basada en la IP
location=$(curl -s ipinfo.io)
# Obtener las coordenadas de la ubicación
latitude=$(echo "$location" | jq -r '.loc' | cut -d ',' -f 1)
longitude=$(echo "$location" | jq -r '.loc' | cut -d ',' -f 2)
# Obtener la hora local en UTC
current_hour=$(date -u +%H)
# Establecer el icono del sol según la hora del día
if [ "$current_hour" -ge 6 ] && [ "$current_hour" -lt 18 ]; then
ICON_SUNNY="$ICON_SUNNY_DAY"
else
ICON_SUNNY="$ICON_SUNNY_NIGHT"
fi
# Consultar el clima utilizando las coordenadas
WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?lat=${latitude}&lon=${longitude}&appid=${API_KEY}&units=metric"
WEATHER_INFO=$(wget -qO- "${WEATHER_URL}")
# Obtener la temperatura actual
WEATHER_TEMP=$(echo "$WEATHER_INFO" | jq -r '.main.temp')
# Función para redondear la temperatura
round_temp() {
printf "%.0f\n" "$1"
}
# Función para mostrar el icono y la temperatura
show_weather() {
weather_main="$1"
weather_temp="$2"
if echo "$weather_main" | grep -qi snow; then
echo "${ICON_SNOW} $(round_temp "$weather_temp")${SYMBOL_CELSIUS}"
elif echo "$weather_main" | grep -qi rain; then
echo "${ICON_RAINY} $(round_temp "$weather_temp")${SYMBOL_CELSIUS}"
elif echo "$weather_main" | grep -qi cloud; then
echo "${ICON_CLOUDY} $(round_temp "$weather_temp")${SYMBOL_CELSIUS}"
elif echo "$weather_main" | grep -qi clear; then
echo "${ICON_SUNNY} $(round_temp "$weather_temp")${SYMBOL_CELSIUS}"
elif echo "$weather_main" | grep -qi fog || echo "$weather_main" | grep -qi mist; then
echo "${ICON_FOG} $(round_temp "$weather_temp")${SYMBOL_CELSIUS}"
else
echo "${ICON_MISC} ${weather_main} $(round_temp "$weather_temp")${SYMBOL_CELSIUS}"
fi
}
# Mostrar el clima
show_weather "$(echo "$WEATHER_INFO" | jq -r '.weather[0].main')" "$WEATHER_TEMP"
Code for tint2 executor for cpu use
#!/bin/bash
read cpu a b c previdle rest < /proc/stat
prevtotal=$((a+b+c+previdle))
sleep 0.5
read cpu a b c idle rest < /proc/stat
total=$((a+b+c+idle))
cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
# Formatear el número a dos dígitos
formatted_cpu=$(printf "%02d" "$cpu")
#echo ~/.config/tint2/executors/icons/cpu.svg
echo "$formatted_cpu%"
if [[ $1 = "-i" ]]; then
echo " ${formatted_cpu%} %"
else
echo ~/.config/tint2/executors/icons/cpu.svg
echo "${formatted_cpu%}"
fi
Code for RAM use in executor in tint2
#!/bin/bash
mem=$(free -m | awk '/Mem/ {printf "%.2f GB\n", $3 / 1024.0 }')
#echo ~/.config/tint2/executors/icons/ram.svg
echo "$mem"
if [[ $1 = "-i" ]]; then
echo " ${mem}"
else
echo ~/.config/tint2/executors/icons/ram.svg
echo "${mem}"
fi
This is a simple script to show a calendar, i use left click in clock
#!/bin/bash
# Establecer las variables de entorno GTK para los colores
#export GTK_THEME=Adwaita:dark
export GTK_OVERLAY_SCROLLING=0
# Función principal
main() {
# Especificar la posición de la ventana en la pantalla
# posx=1050 # Posición X en píxeles # Arriba a la derecha
posx=515 # Posición X en píxeles # Centro
posy=50 # Posición Y en píxeles
# Mostrar el calendario con solo el botón "Salir"
yad --calendar \
--title="Calendario" \
--fixed \
--width=300 \
--height=50 \
--undecorated \
--close-on-unfocus \
--posx=$posx \
--posy=$posy \
--font="Noto Sans 10" \
--no-buttons
# --button="Salir:0"
}
# Llamar a la función principal
main
Hello again, i found a script for show cava in status-bar
#! /bin/bash
bar="▁▂▃▄▅▆▇█"
dict="s/;//g;"
# creating "dictionary" to replace char with bar
i=0
while [ $i -lt ${#bar} ]
do
dict="${dict}s/$i/${bar:$i:1}/g;"
i=$((i=i+1))
done
# write cava config
config_file="/tmp/cava_config"
echo "
[general]
bars = 8
[output]
method = raw
raw_target = /dev/stdout
data_format = ascii
ascii_max_range = 7
" > $config_file
# read stdout from cava
cava -p $config_file | while read -r line; do
echo $line | sed $dict
done
this config in tint2 executor for cava.sh
# Executor 4
execp = new
execp_command = ~/.config/tint2/executors/cava.sh
execp_interval = 1
execp_has_icon = 0
execp_cache_icon = 1
execp_continuous = 1
execp_markup = 1
execp_monitor = all
execp_tooltip =
execp_lclick_command =
execp_rclick_command =
execp_mclick_command =
execp_uwheel_command =
execp_dwheel_command =
execp_font_color = #ffffff 40
execp_padding = 3 0
execp_background_id = 0
execp_centered = 1
execp_icon_w = 0
execp_icon_h = 0
I use with this script for moc to show the name of song in status-bar and control with left click to previus song, right click to no next song and middle click to pause
#!/bin/bash
# A simple script to control MOC (Music on Console) playback
# 'now-playing -i' = with icon, 'now-playing' = text only
# Cheers!
# Addy
exec-moc() {
mocp $* &> /dev/null
}
if [[ $1 = "-i" ]]; then
# With icon
playing=" "
paused=" "
stopped=" "
else
# Without icon
playing=""
paused=""
stopped=""
fi
status=$(mocp -Q %state)
# Crop the text by 32 characters, only pick the song name
song=$(mocp -Q %song)
case $status in
PLAY)
echo "$playing$song"
;;
PAUSE)
echo "$paused$song"
;;
*)
echo "$stopped$song"
;;
esac
and this is the config for moc player in tint2
# Executor 3
execp = new
execp_command = ~/.config/tint2/executors/now-playing -i
execp_interval = 4
execp_has_icon = 0
execp_cache_icon = 1
execp_continuous = 0
execp_markup = 1
execp_monitor = all
execp_tooltip =
execp_lclick_command = mocp --previous
execp_rclick_command = mocp --next
execp_mclick_command = mocp --toggle-pause
execp_uwheel_command =
execp_dwheel_command =
execp_font = Roboto 10
execp_font_color = #ffffff 40
execp_padding = 8 0
execp_background_id = 0
execp_centered = 0
execp_icon_w = 0
execp_icon_h = 0
Plymouth theme changer
In English
#!/bin/bash
red='\033[31m'
green='\033[32m'
blue='\033[34m'
reset='\033[0m'
# Function to list Plymouth themes
list_themes() {
echo "${green}Available Plymouth themes:"${reset}
ls /usr/share/plymouth/themes/
}
# Function to show the installed theme
show_installed_theme() {
sudo plymouthd ; sudo plymouth --show-splash ; sleep 5 ; sudo plymouth quit
}
# Function to install a theme
install_theme() {
read -p "Choose a theme from the list: " chosen_theme
sudo /usr/sbin/plymouth-set-default-theme "$chosen_theme"
sudo update-grub2
sudo update-initramfs -u
echo "${green}Theme successfully installed."${reset}
}
# Main menu loop
while true; do
# Display the menu
echo "${blue}Select an option:"${reset}
echo "${green}1. List Plymouth themes"${reset}
echo "${green}2. Install theme"${reset}
echo "${green}3. View installed theme"${reset}
echo "${green}4. Exit"${reset}
read -p "Enter the option number:" option
case $option in
1)
list_themes
;;
2)
install_theme
;;
3)
show_installed_theme
;;
4)
echo "${blue}Exiting the script."${reset}
exit 0
;;
*)
echo "${red}Invalid option. Please select a valid option."${reset}
;;
esac
done
In Spanish
#!/bin/bash
rojo='\033[31m'
verde='\033[32m'
azul='\033[34m'
reset='\033[0m'
# Función para listar temas de Plymouth
listar_temas() {
echo "${verde}Temas disponibles de Plymouth:"${reset}
ls /usr/share/plymouth/themes/
}
# Función para mostrar el tema instalado
mostrar_tema_instalado() {
sudo plymouthd ; sudo plymouth --show-splash ; sleep 5 ; sudo plymouth quit
}
# Función para instalar un tema
instalar_tema() {
read -p "Elija un tema de la lista: " tema_elegido
sudo /usr/sbin/plymouth-set-default-theme "$tema_elegido"
sudo update-grub2
sudo update-initramfs -u
echo "${verde}Tema instalado con éxito."${reset}
}
# Ciclo principal del menú
while true; do
# Mostrar el menú
echo "${azul}Seleccione una opción:"${reset}
echo "${verde}1. Listar temas de Plymouth"${reset}
echo "${verde}2. Instalar tema"${reset}
echo "${verde}3. Visualizar el tema instalado"${reset}
echo "${verde}4. Salir"${reset}
read -p "Ingrese el número de la opción:" opcion
case $opcion in
1)
listar_temas
;;
2)
instalar_tema
;;
3)
mostrar_tema_instalado
;;
4)
echo "${azul}Saliendo del script."${reset}
exit 0
;;
*)
echo "${rojo}Opción inválida. Por favor, seleccione una opción válida."${reset}
;;
esac
done
add in this file "/etc/default/grub " "splash"
example = GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
Folder for themes here" /usr/share/plymounth/themes/"
Last edited by Argantes (2024-05-21 14:10:16)
Offline
remember to give execution permissions to the scripts
Offline
Top @argantes.
Edit; Welcome to the forum by the way !
Last edited by altman (2024-05-21 15:08:54)
My Linux installs are as in my music; it s on Metal
Offline
Nice stuff.
Welcome to the forum.
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
thanks for the reception. Now I leave you a new package, system, flatpack and snap update script
#!/bin/bash
#
# Este programa es software libre: puedes redistribuirlo y/o modificar
# bajo los términos de la Licencia Pública General GNU publicada por
# la Free Software Foundation, ya sea la versión 3 de la Licencia, o
# (a su elección) cualquier versión posterior.
#
# Este programa se distribuye con la esperanza de que sea útil,
# pero SIN NINGUNA GARANTÍA; sin siquiera la garantía implícita de
# COMERCIABILIDAD o IDONEIDAD PARA UN FIN DETERMINADO. Vea la
# Licencia Pública General GNU para más detalles.
#
# Licencia Pública General GNU consulte <http://www.gnu.org/licenses/>.
#
###################################################################
# Function to display the menu
show_menu() {
echo "Select an option:"
echo "1. Check for available updates"
echo "2. Install upgradable packages"
echo "3. Remove unnecessary packages and clean files"
echo "4. Check FlatPak updates"
echo "5. Check Snap updates"
echo "6. Exit"
}
# Function to check for available updates
check_updates() {
clear
echo "Checking for available updates..."
sudo nala update || sudo apt update
echo "Press Enter to continue..."
read
}
# Function to install upgradable packages
install_updates() {
clear
echo "Installing upgradable packages..."
sudo nala upgrade || sudo apt upgrade
echo "Press Enter to continue..."
read
}
# Function to remove unnecessary packages and clean files
clean_system() {
clear
echo "Removing unnecessary packages and cleaning files..."
sudo nala autoremove || sudo apt autoremove
sudo nala autopurge || sudo apt autoclean
echo "Press Enter to continue..."
read
}
# Function to check FlatPak updates
update_flatpak() {
clear
echo "Checking FlatPak updates..."
flatpak update
echo "Press Enter to continue..."
read
}
# Function to check Snap updates
update_snap() {
clear
echo "Checking Snap updates..."
snap refresh
echo "Press Enter to continue..."
read
}
# Main loop
while true; do
clear
show_menu
read -p "Enter an option: " option
case $option in
1)
check_updates
;;
2)
install_updates
;;
3)
clean_system
;;
4)
update_flatpak
;;
5)
update_snap
;;
6)
echo "Exiting..."
break
;;
*)
echo "Invalid option, please try again."
;;
esac
done
En español para el que quiera
#!/bin/bash
#
# Este programa es software libre: puedes redistribuirlo y/o modificar
# bajo los términos de la Licencia Pública General GNU publicada por
# la Free Software Foundation, ya sea la versión 3 de la Licencia, o
# (a su elección) cualquier versión posterior.
#
# Este programa se distribuye con la esperanza de que sea útil,
# pero SIN NINGUNA GARANTÍA; sin siquiera la garantía implícita de
# COMERCIABILIDAD o IDONEIDAD PARA UN FIN DETERMINADO. Vea la
# Licencia Pública General GNU para más detalles.
#
# Licencia Pública General GNU consulte <http://www.gnu.org/licenses/>.
#
###################################################################
# Función para mostrar el menú
mostrar_menu() {
echo "Seleccione una opción:"
echo "1. Comprueba actualizaciones disponibles"
echo "2. Instala paquetes que pueden ser actualizados"
echo "3. Eliminar paquetes no necesarios y limpiar ficheros"
echo "4. Comprueba actualizaciones FlatPak"
echo "5. Comprueba actualizaciones Snap"
echo "6. Salir"
}
# Función para comprobar actualizaciones disponibles
comprobar_actualizaciones() {
clear
echo "Comprobando actualizaciones disponibles..."
sudo nala update || sudo apt update
echo "Presione Enter para continuar..."
read
}
# Función para instalar actualizaciones
instalar_actualizaciones() {
clear
echo "Instalando actualizaciones disponibles..."
sudo nala upgrade || sudo apt upgrade
echo "Presione Enter para continuar..."
read
}
# Función para eliminar paquetes no necesarios y limpiar ficheros
limpiar_sistema() {
clear
echo "Eliminando paquetes no necesarios y limpiando ficheros..."
sudo nala autoremove || sudo apt autoremove
sudo nala autopurge || sudo apt autoclean
echo "Presione Enter para continuar..."
read
}
# Función para comprobar actualizaciones FlatPak
actualizar_flatpak() {
clear
echo "Comprobando actualizaciones de FlatPak..."
flatpak update
echo "Presione Enter para continuar..."
read
}
# Función para comprobar actualizaciones Snap
actualizar_snap() {
clear
echo "Comprobando actualizaciones de Snap..."
snap refresh
echo "Presione Enter para continuar..."
read
}
# Bucle principal
while true; do
clear
mostrar_menu
read -p "Ingrese una opción: " opcion
case $opcion in
1)
comprobar_actualizaciones
;;
2)
instalar_actualizaciones
;;
3)
limpiar_sistema
;;
4)
actualizar_flatpak
;;
5)
actualizar_snap
;;
6)
echo "Saliendo..."
break
;;
*)
echo "Opción no válida, intente nuevamente."
;;
esac
done
Offline
Thx for sharing, keep it on sir !
My Linux installs are as in my music; it s on Metal
Offline