Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 19/12/2018, à 16:49

Toulibre

[Résolu]Script au démarrage du pc dans la fenêtre du terminal

Bonjour ,

J'aimerai ouvrir ce script dans la fenêtre du terminal au démarrage du pc tout simplement ,

Sans créer de raccourci ou de lanceur dans le menu .


C'est un programme nommé Ansiweather qui fonctionne avec le terminal donc pour avoir la météo je dois ouvrir ce terminal et taper ansiweather pour obtenir les infos de la météo locale , est-ce possible d'automatiser ceci au démarrage ?


il est situé dans          /usr/bin/ansiweather

il y a aussi d'autres fichiers installés dans le dossier  /usr/share/doc/ansiweather


Ce qu'il y a dans le script :

#!/bin/sh

###############################################################################
#                                                                             #
# AnsiWeather 1.11                                                            #
# Copyright (c) 2013-2017, Frederic Cambus                                    #
# https://github.com/fcambus/ansiweather                                      #
#                                                                             #
# Created: 2013-08-29                                                         #
# Last Updated: 2017-06-21                                                    #
#                                                                             #
# AnsiWeather is released under the BSD 2-Clause license.                     #
# See LICENSE file for details.                                               #
#                                                                             #
###############################################################################



###[ Configuration options ]###################################################

LC_ALL=C; export LC_ALL

config_file=${ANSIWEATHERRC:-~/.ansiweatherrc}

get_config() {
	ret=""
	if [ -f "$config_file" ]
	then
		ret=$(grep "^$1:" "$config_file" | awk -F: '{print $2}')
	fi

	if [ "X$ret" = "X" ]
	then
		return 1
	else
		echo "$ret"
	fi
}

fetch_cmd=$(get_config "fetch_cmd" || echo "curl -sf")



###[ Parse the command line ]##################################################

# Get config options from command line flags
while getopts l:u:f:Fa:s:k:w:h:p:d:v option
do
	case "${option}"
	in
		l) location=${OPTARG};;
		u) units=${OPTARG};;
		f) forecast=${OPTARG};;
		F) forecast="5";;
		a) ansi=${OPTARG};;
		s) symbols=${OPTARG};;
		k) api_key=${OPTARG};;
		w) show_wind=${OPTARG};;
		h) show_humidity=${OPTARG};;
		p) show_pressure=${OPTARG};;
		d) show_daylight=${OPTARG};;
		v) echo "AnsiWeather 1.11" && exit 0;;
		\?) exit 64;; # EX_USAGE
	esac
done



###[ Check if bc and jq are installed ]########################################

jqpath=$(which jq)
if [ "$jqpath" = "" ]
then
	echo "ERROR: Cannot find jq binary"
	exit 69 # EX_UNAVAILABLE
fi

bcpath=$(which bc)
if [ "$bcpath" = "" ]
then
	echo "ERROR: Cannot find bc binary"
	exit 69 # EX_UNAVAILABLE
fi



###[ Set options that are not set from command line ]##########################

# OpenWeatherMap API key
[ -z "$api_key" ] && api_key=$(get_config "api_key" || echo "85a4e3c55b73909f42c6a23ec35b7147")

# Location: example "Mars,Univers"
[ -z "$location" ] && location=$(get_config "location" || echo "Mars,Univers")

# System of Units: "metric" or "imperial"
[ -z "$units" ] && units=$(get_config "units" || echo "metric")

# Show forecast: How many days, example "5". "0" is standard output
[ -z "$forecast" ] && forecast=$(get_config "forecast" || echo 0)

# Display ANSI colors: "true" or "false"
[ -z "$ansi" ] && ansi=$(get_config "ansi" || echo true)

# Display symbols: "true" or "false" (requires a Unicode capable display)
[ -z "$symbols" ] && symbols=$(get_config "symbols" || echo false)

# Show wind: "true" or "false"
[ -z "$show_wind" ] && show_wind=$(get_config "show_wind" || echo true)

# Show humidity: "true" or "false"
[ -z "$show_humidity" ] && show_humidity=$(get_config "show_humidity" || echo true)

# Show pressure: "true" or "false"
[ -z "$show_pressure" ] && show_pressure=$(get_config "show_pressure" || echo true)

# Show daylight: "true" or "false"
[ -z "$show_daylight" ] && show_daylight=$(get_config "show_daylight" || echo false)

dateformat=$(get_config "dateformat" || echo "%a %b %d")
timeformat=$(get_config "timeformat" || echo "%b %d %r")



###[ Colors and characters ]###################################################

background=$(get_config "background" || echo "\033[44m")
text=$(get_config "text" || echo "\033[36;1m")
data=$(get_config "data" || echo "\033[33;1m")
delimiter=$(get_config "delimiter" || echo "\033[35m=>")
dashes=$(get_config "dashes" || echo "\033[34m-")



###[ Text Labels ]#############################################################

greeting_text=$(get_config "greeting_text" || echo "Weather in")
wind_text=$(get_config "wind_text" || echo "Wind")
humidity_text=$(get_config "humidity_text" || echo "Humidity")
pressure_text=$(get_config "pressure_text" || echo "Pressure")
sunrise_text=$(get_config "sunrise_text" || echo "Sunrise")
sunset_text=$(get_config "sunset_text" || echo "Sunset")
forecast_text=$(get_config "forecast_text" || echo "forecast")



###[ Unicode Symbols for icons ]###############################################

sun=$(get_config "sun" || echo "\033[33;1m\xe2\x98\x80")
moon=$(get_config "moon" || echo "\033[36m\xe2\x98\xbd")
clouds=$(get_config "clouds" || echo "\033[37;1m\xe2\x98\x81")
rain=$(get_config "rain" || echo "\033[37;1m\xe2\x98\x94")
fog=$(get_config "fog" || echo "\033[37;1m\xe2\x96\x92")
mist=$(get_config "mist" || echo "\033[34m\xe2\x96\x91")
haze=$(get_config "haze" || echo "\033[33m\xe2\x96\x91")
snow=$(get_config "snow" || echo "\033[37;1m\xe2\x9d\x84")
thunderstorm=$(get_config "thunderstorm" || echo "\033[33;1m\xe2\x9a\xa1")



###[ Fetch Weather data ]######################################################

api_cmd=$([ "$forecast" != 0 ] && echo "forecast/daily" || echo "weather")

if [ "$location" -gt 0 ] 2> /dev/null
then
	# Location is all numeric
	weather=$($fetch_cmd "http://api.openweathermap.org/data/2.5/$api_cmd?id=$location&units=$units&appid=$api_key")
else
	# Location is a string
	location=$(echo "$location" | sed "s/ /_/g")
	weather=$($fetch_cmd "http://api.openweathermap.org/data/2.5/$api_cmd?q=$location&units=$units&appid=$api_key")
fi

if [ -z "$weather" ]
then
	echo "ERROR: Cannot fetch weather data"
	exit 75 # EX_TEMPFAIL
fi

status_code=$(echo "$weather" | jq -r '.cod' 2>/dev/null)

if [ "$status_code" != 200 ]
then
	echo "ERROR: Cannot fetch weather data for the given location"
	exit 69 # EX_UNAVAILABLE
fi



###[ Process Weather data ]####################################################

epoch_to_date() {
	if date -j -r "$1" +"%a %b %d" > /dev/null 2>&1; then
		# BSD
		ret=$(date -j -r "$1" +"$dateformat")
	else
		# GNU
		ret=$(date -d "@$1" +"$dateformat")
	fi
	echo "$ret"
}

if [ "$forecast" != 0 ]
then
	city=$(echo "$weather" | jq -r '.city.name')
	flength=$(echo "$weather" | jq '.list | length')
	forecast=$([ "$forecast" -gt "$flength" ] && echo "$flength" || echo "$forecast")
else
	city=$(echo "$weather" | jq -r '.name')
	temperature=$(echo "$weather" | jq '.main.temp' | xargs printf "%.0f")
	humidity=$(echo "$weather" | jq '.main.humidity')
	pressure=$(echo "$weather" | jq '.main.pressure')
	sky=$(echo "$weather" | jq -r '.weather[0].main')
	sunrise=$(echo "$weather" | jq '.sys.sunrise')
	sunset=$(echo "$weather" | jq '.sys.sunset')
	wind=$(echo "$weather" | jq '.wind.speed')
	azimuth=$(echo "$weather" | jq '.wind.deg')
fi



###[ Process Wind data ]#######################################################

set -- $(get_config "wind_directions" || echo "N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW")

if [ "$forecast" = 0 ]
then
	shift "$(echo "scale=0; ($azimuth + 11.25)/22.5 % 16" | bc)"
	direction=$1
fi



###[ Process Sunrise and Sunset data ]#########################################

epoch_to_time() {
	if date -j -r "$1" +"%r" > /dev/null 2>&1; then
		# BSD
		ret=$(date -j -r "$1" +"$timeformat")
	else
		# GNU
		ret=$(date -d "@$1" +"$timeformat")
	fi
	echo "$ret"
}

if [ "$forecast" = 0 ]
then
	if [ -n "$sunrise" ]
	then
		sunrise_time=$(epoch_to_time "$sunrise")
	fi

	if [ -n "$sunset" ]
	then
		sunset_time=$(epoch_to_time "$sunset")
	fi
fi



###[ Set the period ]##########################################################

now=$(date +%s)

if [ "$forecast" != 0 ]
then
	period="none"
else
	if [ -z "$sunset" ] || [ -z "$sunrise" ]
	then
		period="day"
	elif [ "$now" -ge "$sunset" ] || [ "$now" -le "$sunrise" ]
	then
		period="night"
	else
		period="day"
	fi
fi



###[ Set the scale ]###########################################################

case $units in
	metric)
		scale="°C"
		speed_unit="m/s"
		pressure_unit="hPa"
		pressure=$(echo "$pressure" | xargs printf "%.0f")
		;;
	imperial)
		scale="°F"
		speed_unit="mph"
		pressure_unit="inHg"
		if [ "$forecast" = 0 ]
		then
			pressure=$(echo "$pressure*0.0295" | bc | xargs printf "%.2f")
		fi
		;;
esac



###[ Set icons ]###############################################################

get_icon() {
	case $1 in
		Clear)
			if [ $period = "night" ]
			then
				echo "$moon "
			else
				echo "$sun "
			fi
			;;
		Clouds)
			echo "$clouds "
			;;
		Rain)
			echo "$rain "
			;;
		Fog)
			echo "$fog "
			;;
		Mist)
			echo "$mist "
			;;
		Haze)
			echo "$haze "
			;;
		Snow)
			echo "$snow "
			;;
		Thunderstorm)
			echo "$thunderstorm "
			;;
	esac
}



###[ Display current Weather ]#################################################

if [ "$forecast" != 0 ]
then
	output="$background$text $city $forecast_text $text$delimiter "

	i=0
	while [ $i -lt "$forecast" ]
	do
		day=$(echo "$weather" | jq ".list[$i]")
		date=$(epoch_to_date "$(echo "$day" | jq -r '.dt')")
		low=$(echo "$day" | jq -r '.temp.min' | xargs printf "%.0f")
		high=$(echo "$day" | jq -r '.temp.max' | xargs printf "%.0f")

		icon=""
		if [ "$symbols" = true ]
		then
			sky=$(echo "$day" | jq -r '.weather[0].main')
			icon=$(get_icon "$sky")
		fi

		output="$output$text$date: $data$high$text/$data$low $scale $icon"
		if [ $i -lt $((forecast-1)) ]
		then
			output="$output$dashes "
		fi

		i=$((i + 1))
	done
else
	if [ "$symbols" = true ]
	then
		icon="$(get_icon "$sky")"
	fi
	output="$background$text $greeting_text $city $delimiter$data $temperature $scale $icon"

	if [ "$show_wind" = true ]
	then
		output="$output$dashes$text $wind_text $delimiter$data $wind $speed_unit $direction "
	fi

	if [ "$show_humidity" = true ]
	then
		output="$output$dashes$text $humidity_text $delimiter$data $humidity %% "
	fi

	if [ "$show_pressure" = true ]
	then
		output="$output$dashes$text $pressure_text $delimiter$data $pressure $pressure_unit "
	fi

	if [ "$show_daylight" = true ]
	then
		output="$output$dashes$text $sunrise_text $delimiter$data $sunrise_time $dashes$text $sunset_text $delimiter$data $sunset_time "
	fi
fi

if [ "$ansi" = true ]
then
	env printf "$output\033[0m\n"
else
	env printf "$output\n" | sed "s/$(printf '\033')\[[0-9;]*m//g"
fi


Je suis débutant dans ce genre de manoeuvres , ce serait gentil de m'éclairer

Quelqu'un peut-il m'aider ?

Dernière modification par Toulibre (Le 22/12/2018, à 21:07)

#2 Le 19/12/2018, à 16:59

Watael

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

salut,

au démarrage du pc

tu veux dire au démarrage du Gestionnaire de fenêtres !?
lequel ? Gnome ?


Connected \o/
Welcome to sHell. · eval is evil.

En ligne

#3 Le 19/12/2018, à 17:04

Toulibre

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

Oui , j'ai bien voulu dire au démarrage du pc , le terminal qui s'ouvre en indiquant la météo

Je suis sous Lubuntu LXDE 18.04 LTS

#4 Le 19/12/2018, à 17:13

Watael

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

la météo de ... Mars ? tu projettes d'y partir en vacances bientôt ?

au démarrage du PC, il y a
le BIOS
GrUB
un splash screen, et/ou quelques indications du processus de démarrage
puis l'écran de connexion

où veux-tu afficher ton script ?


Connected \o/
Welcome to sHell. · eval is evil.

En ligne

#5 Le 19/12/2018, à 17:17

Toulibre

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

Hé hé , doit faire chaud là haut comparé ici en ce moment

Je souhaite que ce programme s'exécute via le terminal au démarrage du pc sur le bureau

En fait pas vraiment , je viens de vérifier , ça caille pas mal sur Mars !

Dernière modification par Toulibre (Le 19/12/2018, à 17:32)

#6 Le 19/12/2018, à 17:40

Watael

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

au démarrage du pc sur le bureau

donc,

au démarrage du Gestionnaire de fenêtres

!!!
=> LXDE
que je n'utilise pas. sad
il y a probablement un menu "Programme au démarrage", où il faudra indiquer, probablement : lxde-terminal -e /chemin/nomDuScript


Connected \o/
Welcome to sHell. · eval is evil.

En ligne

#7 Le 19/12/2018, à 18:32

Toulibre

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

Effectivement il y a un gestionnaire d'applications par défaut LXSession avec un onglet applications au démarrage

J'en ai ajouté donc un de plus avec la commande suivante :

lxterminal -e /usr/bin/ansiweather

Un redémarrage et j'ai pu en un éclair voir le terminal s'ouvrir et se refermer !

Bon ... ça fait un peu juste pour lire la météo mais c'est un début

#8 Le 19/12/2018, à 19:07

Toulibre

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

En ajoutant seulement lxterminal au démarrage la fenêtre s'ouvre impeccable et reste ouverte

il me reste à comprendre comment ce programme pourrait être executé

Ceci dit merci , grâce à tes indications je peux ouvrir automatiquement Gkrellm au démarrage (un autre programme)

#9 Le 19/12/2018, à 19:14

Watael

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

lxterminal --command='/usr/bin/ansiweather; read -n 1'

?
ou

lxterminal -e bash -c '/usr/bin/ansiweather; read -n 1'

le concept est le même : bloquer le terminal sur un read, qui attend la lecture d'un seul caractère.


Connected \o/
Welcome to sHell. · eval is evil.

En ligne

#10 Le 19/12/2018, à 19:28

Toulibre

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

Merci , j'ai tenté les 2 lignes une à une , aucunes n'ont fonctionné malheureusement

Dernière modification par Toulibre (Le 19/12/2018, à 19:45)

#11 Le 19/12/2018, à 20:08

Watael

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

« ça marche pas », mais "ça marche pas" comment ?
il ne se lance rien ?
le terminal se ferme aussi vite ?
... ?


Connected \o/
Welcome to sHell. · eval is evil.

En ligne

#12 Le 19/12/2018, à 20:16

Toulibre

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

En mettant le terminal au démarrage d'office + en ajoutant une seconde fois  lxterminal avec une de tes lignes inclues , le terminal s'ouvre mais sans exécuter ansiweather

En mettant uniquement une des deux lignes que tu as proposé ci-dessus le terminal s'ouvre et se ferme de suite

Dernière modification par Toulibre (Le 19/12/2018, à 20:16)

#13 Le 19/12/2018, à 20:20

inbox

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

Salut,

Je ne vais pas répondre directement à ta question, mais as-tu testé Conkyforecast ?

Je te propose cela, car Ansiweather, une fois qu'il a donné la météo s'arrête, ce qui explique pourquoi ton terminal se ferme immédiatement.

A+


Un problème résolu ? Indiquez le en modifiant le titre du sujet.

Hors ligne

#14 Le 19/12/2018, à 20:34

Toulibre

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

Merci , j'ai vu ça déjà ,

Si je tape ansiweather manuellement dans lxterminal ça reste ouvert alors je me disais , pourquoi ne pas l'avoir d'entrée à l'allumage du pc !

Je vais potasser cette possibilité , d'après ce que j'ai lu sur les scripts cela doit être jouable

Encore merci de t'être impliqué

Dernière modification par Toulibre (Le 19/12/2018, à 20:37)

#15 Le 19/12/2018, à 21:01

Watael

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

hmmm. hmm

lxterminal -e '/usr/bin/ansiweather; read -n1'

depuis un autre terminal, chez moi, ceci ouvre lxterminal, exécute ansiweather, et "bloque" sur le read; et quand j'appuie sur une touche lxterminal se ferme.


Connected \o/
Welcome to sHell. · eval is evil.

En ligne

#16 Le 19/12/2018, à 22:15

Sciensous

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

@Wateal: j'ai aussi ce comportement de fermerture immédiate;

une solution bateau:
ouvrir le script en question et y rajouter à la fin du fichier ansiweather:

while :;do sleep 1m;done

en attendant mieux

EDIT: mieux (càd sans modifier le script):

lxterminal -e 'sh -c "/usr/bin/ansiweather.sh; sh"'

Dernière modification par Sciensous (Le 19/12/2018, à 22:30)


antiX 19 et 21 et Ubuntu 20.04 et 22.04
( sous LXDE et gnome-shell )

Hors ligne

#17 Le 20/12/2018, à 11:03

Toulibre

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

Salut ,

    Pfffiiioooouuu !!!!

Ca a mit un de ces foutoirs !

lxterminal -e 'sh -c "/usr/bin/ansiweather.sh; sh"'

ajouté au script ne donnait rien de plus ,

à part le terminal qui s'ouvre en disant

impossible de trouver le fichier ansiweather.sh; sh

J'ai donc mit cette ligne à la place dans le script puisque c'est son nom

lxterminal -e 'sh -c "/usr/bin/ansiweather


Et rajouté ce script au démarrage dans mon gestionnaire de démarrage en indiquant le chemin

 /usr/bin/ansiweather 

Oh My Gosh !

Le terminal s'ouvre à l'infini !

Idem si je crée un fichier autostart contenant ces lignes !

#!/bin/bash
xterm -e '/usr/bin/ansiweather.sh'

Bref , j'ai réussi a stopper la Bête , retour à la normale  !

D'autres suggestions ?

#18 Le 20/12/2018, à 11:25

Sciensous

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

1/ bien lire ce que j'ai écris avant de faire n'importe quoi:
(càd sans modifier le script)

2/ je dois aussi bien lire mea culpa: il n'y a pas de .sh après le nom de script

DONC:
la commande

lxterminal -e 'sh -c "/usr/bin/ansiweather; sh"'

est à mettre dans les préférences démarrage de la session
(ce que tu as fait au début avec le gestionnaire d'applications par défaut LXSession)

et bien sûr l'enlever du script ansiweather lui-même

[ la modification de ansiweather ne concernait QUE le while :;do sleep 1m;done  ]
[ cest donc l'une ou l'autre mais pas les 2 solutions proposées ]

Dernière modification par Sciensous (Le 20/12/2018, à 11:29)


antiX 19 et 21 et Ubuntu 20.04 et 22.04
( sous LXDE et gnome-shell )

Hors ligne

#19 Le 20/12/2018, à 13:08

Toulibre

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

Ok ,

Fait exactement comme tu l'as indiqué puis redémarré
Le terminal s'ouvre avec une fenêtre vide dont le titre est

'sh

Pour l'autre soluce j'ai ajouté à la fin du script la ligne

while :;do sleep 1m;done

Et ajouté au gestionnaire de démarrage

lxterminal -e '/usr/bin/ansiweather; read -n1'

Le terminal s'ouvre vide avec le titre

ansiweather;

Dernière précision
Le gestionnaire d'applications au démarrage influe et inscrit directement sur ce fichier dès qu'il y a un ajout

/home/lubuntu/.config/lxsession/Lubuntu/autostart

Dernière modification par Toulibre (Le 20/12/2018, à 13:58)

#20 Le 20/12/2018, à 14:15

Toulibre

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

Après démarrage , si j'ouvre le terminal et que je tape simplement ansiweather

lubuntu@lubuntu-HP-Pavilion-dv7-Notebook-PC:~$ ansiweather
 Weather in Ganges => 13 °C - Wind => 4.1 m/s SW - Humidity => 58 % - Pressure => 1023 hPa 
lubuntu@lubuntu-HP-Pavilion-dv7-Notebook-PC:~$

Et bien ... il doit y avoir une bonne formule pour que ça fonctionne ...

Je suis un peu largué pour le moment

#21 Le 20/12/2018, à 15:24

uboops

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

Il y a d'autres possibilités aussi:

$ curl wttr.in/~Paris?lang=fr
Prévisions météo pour: Paris

    \  /       Partiellement nuageux
  _ /"".-.     6-9 °C         
    \_(   ).   ↗ 26 km/h      
    /(___(__)  10 km          
               0.0 mm         
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤ jeu. 20 déc.├───────────────────────┬──────────────────────────────┐
│             Matin            │          Après-midi   └──────┬──────┘       Soir            │             Nuit             │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│  _`/"".-.     Pluie éparse à │               Nuageux        │    \  /       Partiellement …│               Nuageux        │
│   ,\_(   ).   4-7 °C         │      .--.     6-9 °C         │  _ /"".-.     7-9 °C         │      .--.     4-5 °C         │
│    /(___(__)  ↗ 19-30 km/h   │   .-(    ).   ↗ 20-29 km/h   │    \_(   ).   ↗ 18-28 km/h   │   .-(    ).   ↗ 19-31 km/h   │
│      ‘ ‘ ‘ ‘  18 km          │  (___.__)__)  19 km          │    /(___(__)  19 km          │  (___.__)__)  19 km          │
│     ‘ ‘ ‘ ‘   0.0 mm | 26%   │               0.0 mm | 0%    │               0.0 mm | 0%    │               0.3 mm | 41%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤ ven. 21 déc.├───────────────────────┬──────────────────────────────┐
│             Matin            │          Après-midi   └──────┬──────┘       Soir            │             Nuit             │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│      .-.      Pluie forte    │      .-.      Pluie légère   │      .-.      Pluie modérée  │      .-.      Pluie modérée  │
│     (   ).    11-14 °C       │     (   ).    12-14 °C       │     (   ).    12-14 °C       │     (   ).    12-13 °C       │
│    (___(__)   ↗ 32-51 km/h   │    (___(__)   ↗ 28-45 km/h   │    (___(__)   ↗ 19-29 km/h   │    (___(__)   ↗ 15-24 km/h   │
│   ‚‘‚‘‚‘‚‘    14 km          │     ‘ ‘ ‘ ‘   14 km          │   ‚‘‚‘‚‘‚‘    14 km          │   ‚‘‚‘‚‘‚‘    15 km          │
│   ‚’‚’‚’‚’    4.1 mm | 74%   │    ‘ ‘ ‘ ‘    1.4 mm | 80%   │   ‚’‚’‚’‚’    4.3 mm | 82%   │   ‚’‚’‚’‚’    1.9 mm | 72%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
                                                       ┌─────────────┐                                                       
┌──────────────────────────────┬───────────────────────┤ sam. 22 déc.├───────────────────────┬──────────────────────────────┐
│             Matin            │          Après-midi   └──────┬──────┘       Soir            │             Nuit             │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│               Nuageux        │               Nuageux        │  _`/"".-.     Averse de plui…│  _`/"".-.     Averse de plui…│
│      .--.     8-11 °C        │      .--.     9-11 °C        │   ,\_(   ).   9-11 °C        │   ,\_(   ).   8-10 °C        │
│   .-(    ).   ↗ 17-26 km/h   │   .-(    ).   ↗ 19-27 km/h   │    /(___(__)  ↗ 15-23 km/h   │    /(___(__)  ↗ 14-21 km/h   │
│  (___.__)__)  19 km          │  (___.__)__)  19 km          │      ‘ ‘ ‘ ‘  17 km          │      ‘ ‘ ‘ ‘  19 km          │
│               0.0 mm | 0%    │               0.0 mm | 0%    │     ‘ ‘ ‘ ‘   0.3 mm | 72%   │     ‘ ‘ ‘ ‘   0.1 mm | 26%   │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
Emplacement: Paris, Île-de-France, France métropolitaine, 75000;75001;75002;75003;75004;75005;75006;75007;75008;75009;75010;75011;75012;75013;75014;75015;75016;75017;75018;75019;75020;75116, France [48.8566101,2.3514992]

Suivez @igor_Chubin pour rester informé sur wttr.in
$ 

Ou

$ inxi -xxx -W paris,france
Weather:   Temperature: 11 C (52 F) Conditions: Mostly Cloudy Wind: from SW at 5.4 m/s (19 km/h, 12 mph) 
           Humidity: 67% Pressure: 1014 mb (29.95 in) Dew Point: 5 C (41 F) Location: Paris, France 
           altitude: 86 m (282 ft) Current Time: jeu. 20 dc. 2018 14:22:34 CET 
           Observation Time: December 20, 2:00 PM CET 

On peut même demander la Lune: ;-)

curl fr.wttr.in/moon
                  ------------.	 
              --'  o     . .   `--.	 
            '   .    O   .       . `-.	 
          @   @@@@@@@   .  @@@@@      `-.	 
        @@  @@@@@@@@@@@   @@@@@@@   .    \	 
          o @@@@@@@@@@@   @@@@@@@       . \.	 
        o   @@@@@@@@@@@.   @@@@@@@   O      \	 
     @@   .   @@@@@@@o    @@@@@@@@@@     @@@ \	 
     @@@               . @@@@@@@@@@@@@ o @@@@|	 
    @@@  O  `.-./  .      @@@@@@@@@@@@    @@  \	 Premier quartier +
    @@@    --`-'       o     @@@@@@@@ @@@@    |	 5  1:37:12
    @@@        `    o      .  @@   . @@@@@@@  |	 Pleine lune -
         @@  @         .-.     @@@   @@@@@@@  |	 2  4:23:37
    . @        @@@     `-'   . @@@@   @@@@  o /	 
         @@   @@@@@ .           @@   .       |	 
        @@@@  @\@@    /  .  O    .     o   . /	 
      o  @@     \ \  /         .    .       /	 
           .    .\.-.___   .      .   .-. /'	 
                  `-'                `-' /	 
             o   / |     o    O   .   .-'	 
            .   /     .       .    .-'	 
              --.       .      .--'	 
                  ------------'	 


Suivez @igor_Chubin pour rester informé sur wttr.in

Dernière modification par uboops (Le 20/12/2018, à 15:28)


“Au lieu de faire que ce qui fût juste fût fort, on a fait que ce qui fût fort fût juste.” (Blaise Pascal).

Hors ligne

#22 Le 20/12/2018, à 16:09

Sciensous

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

oui, le gestionnaire de démarrage ne fait que modifier le fichier /home/lubuntu/.config/lxsession/Lubuntu/autostart

peux-tu mettre le contenu du fichier ?
(car ça marche très bien chez moi)

@uboops: pourquoi pas; mais le but est quand même de faire "évoluer" Toulibre pour qu'il devienne un peu plus toutlibre smile

Dernière modification par Sciensous (Le 20/12/2018, à 16:10)


antiX 19 et 21 et Ubuntu 20.04 et 22.04
( sous LXDE et gnome-shell )

Hors ligne

#23 Le 20/12/2018, à 18:09

Toulibre

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

Hello ,

Oui@Uboops j'ai bien vu les possibilités de ce programme , c'est pourquoi j'aimerai l'avoir d'entrée au démarrage ,
Une fois que c'est ok je le paramètrerais


@Sciensous J'ai également essayé d'éditer un fichier autostart dans

/.config/autostart/

puis en l'ajoutant au démarrage sans succès

Le contenu du fichier :


#!/bin/sh

###############################################################################
#                                                                             #
# AnsiWeather 1.11                                                            #
# Copyright (c) 2013-2017, Frederic Cambus                                    #
# https://github.com/fcambus/ansiweather                                      #
#                                                                             #
# Created: 2013-08-29                                                         #
# Last Updated: 2017-06-21                                                    #
#                                                                             #
# AnsiWeather is released under the BSD 2-Clause license.                     #
# See LICENSE file for details.                                               #
#                                                                             #
###############################################################################



###[ Configuration options ]###################################################

LC_ALL=C; export LC_ALL

config_file=${ANSIWEATHERRC:-~/.ansiweatherrc}

get_config() {
	ret=""
	if [ -f "$config_file" ]
	then
		ret=$(grep "^$1:" "$config_file" | awk -F: '{print $2}')
	fi

	if [ "X$ret" = "X" ]
	then
		return 1
	else
		echo "$ret"
	fi
}

fetch_cmd=$(get_config "fetch_cmd" || echo "curl -sf")



###[ Parse the command line ]##################################################

# Get config options from command line flags
while getopts l:u:f:Fa:s:k:w:h:p:d:v option
do
	case "${option}"
	in
		l) location=${OPTARG};;
		u) units=${OPTARG};;
		f) forecast=${OPTARG};;
		F) forecast="5";;
		a) ansi=${OPTARG};;
		s) symbols=${OPTARG};;
		k) api_key=${OPTARG};;
		w) show_wind=${OPTARG};;
		h) show_humidity=${OPTARG};;
		p) show_pressure=${OPTARG};;
		d) show_daylight=${OPTARG};;
		v) echo "AnsiWeather 1.11" && exit 0;;
		\?) exit 64;; # EX_USAGE
	esac
done



###[ Check if bc and jq are installed ]########################################

jqpath=$(which jq)
if [ "$jqpath" = "" ]
then
	echo "ERROR: Cannot find jq binary"
	exit 69 # EX_UNAVAILABLE
fi

bcpath=$(which bc)
if [ "$bcpath" = "" ]
then
	echo "ERROR: Cannot find bc binary"
	exit 69 # EX_UNAVAILABLE
fi



###[ Set options that are not set from command line ]##########################

# OpenWeatherMap API key
[ -z "$api_key" ] && api_key=$(get_config "api_key" || echo "85a4e3c55b73909f42c6a23ec35b7147")

# Location: example "Ganges,FR"
[ -z "$location" ] && location=$(get_config "location" || echo "Ganges,FR")

# System of Units: "metric" or "imperial"
[ -z "$units" ] && units=$(get_config "units" || echo "metric")

# Show forecast: How many days, example "5". "0" is standard output
[ -z "$forecast" ] && forecast=$(get_config "forecast" || echo 0)

# Display ANSI colors: "true" or "false"
[ -z "$ansi" ] && ansi=$(get_config "ansi" || echo true)

# Display symbols: "true" or "false" (requires a Unicode capable display)
[ -z "$symbols" ] && symbols=$(get_config "symbols" || echo false)

# Show wind: "true" or "false"
[ -z "$show_wind" ] && show_wind=$(get_config "show_wind" || echo true)

# Show humidity: "true" or "false"
[ -z "$show_humidity" ] && show_humidity=$(get_config "show_humidity" || echo true)

# Show pressure: "true" or "false"
[ -z "$show_pressure" ] && show_pressure=$(get_config "show_pressure" || echo true)

# Show daylight: "true" or "false"
[ -z "$show_daylight" ] && show_daylight=$(get_config "show_daylight" || echo false)

dateformat=$(get_config "dateformat" || echo "%a %b %d")
timeformat=$(get_config "timeformat" || echo "%b %d %r")



###[ Colors and characters ]###################################################

background=$(get_config "background" || echo "\033[44m")
text=$(get_config "text" || echo "\033[36;1m")
data=$(get_config "data" || echo "\033[33;1m")
delimiter=$(get_config "delimiter" || echo "\033[35m=>")
dashes=$(get_config "dashes" || echo "\033[34m-")



###[ Text Labels ]#############################################################

greeting_text=$(get_config "greeting_text" || echo "Weather in")
wind_text=$(get_config "wind_text" || echo "Wind")
humidity_text=$(get_config "humidity_text" || echo "Humidity")
pressure_text=$(get_config "pressure_text" || echo "Pressure")
sunrise_text=$(get_config "sunrise_text" || echo "Sunrise")
sunset_text=$(get_config "sunset_text" || echo "Sunset")
forecast_text=$(get_config "forecast_text" || echo "forecast")



###[ Unicode Symbols for icons ]###############################################

sun=$(get_config "sun" || echo "\033[33;1m\xe2\x98\x80")
moon=$(get_config "moon" || echo "\033[36m\xe2\x98\xbd")
clouds=$(get_config "clouds" || echo "\033[37;1m\xe2\x98\x81")
rain=$(get_config "rain" || echo "\033[37;1m\xe2\x98\x94")
fog=$(get_config "fog" || echo "\033[37;1m\xe2\x96\x92")
mist=$(get_config "mist" || echo "\033[34m\xe2\x96\x91")
haze=$(get_config "haze" || echo "\033[33m\xe2\x96\x91")
snow=$(get_config "snow" || echo "\033[37;1m\xe2\x9d\x84")
thunderstorm=$(get_config "thunderstorm" || echo "\033[33;1m\xe2\x9a\xa1")



###[ Fetch Weather data ]######################################################

api_cmd=$([ "$forecast" != 0 ] && echo "forecast/daily" || echo "weather")

if [ "$location" -gt 0 ] 2> /dev/null
then
	# Location is all numeric
	weather=$($fetch_cmd "http://api.openweathermap.org/data/2.5/$api_cmd?id=$location&units=$units&appid=$api_key")
else
	# Location is a string
	location=$(echo "$location" | sed "s/ /_/g")
	weather=$($fetch_cmd "http://api.openweathermap.org/data/2.5/$api_cmd?q=$location&units=$units&appid=$api_key")
fi

if [ -z "$weather" ]
then
	echo "ERROR: Cannot fetch weather data"
	exit 75 # EX_TEMPFAIL
fi

status_code=$(echo "$weather" | jq -r '.cod' 2>/dev/null)

if [ "$status_code" != 200 ]
then
	echo "ERROR: Cannot fetch weather data for the given location"
	exit 69 # EX_UNAVAILABLE
fi



###[ Process Weather data ]####################################################

epoch_to_date() {
	if date -j -r "$1" +"%a %b %d" > /dev/null 2>&1; then
		# BSD
		ret=$(date -j -r "$1" +"$dateformat")
	else
		# GNU
		ret=$(date -d "@$1" +"$dateformat")
	fi
	echo "$ret"
}

if [ "$forecast" != 0 ]
then
	city=$(echo "$weather" | jq -r '.city.name')
	flength=$(echo "$weather" | jq '.list | length')
	forecast=$([ "$forecast" -gt "$flength" ] && echo "$flength" || echo "$forecast")
else
	city=$(echo "$weather" | jq -r '.name')
	temperature=$(echo "$weather" | jq '.main.temp' | xargs printf "%.0f")
	humidity=$(echo "$weather" | jq '.main.humidity')
	pressure=$(echo "$weather" | jq '.main.pressure')
	sky=$(echo "$weather" | jq -r '.weather[0].main')
	sunrise=$(echo "$weather" | jq '.sys.sunrise')
	sunset=$(echo "$weather" | jq '.sys.sunset')
	wind=$(echo "$weather" | jq '.wind.speed')
	azimuth=$(echo "$weather" | jq '.wind.deg')
fi



###[ Process Wind data ]#######################################################

set -- $(get_config "wind_directions" || echo "N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW")

if [ "$forecast" = 0 ]
then
	shift "$(echo "scale=0; ($azimuth + 11.25)/22.5 % 16" | bc)"
	direction=$1
fi



###[ Process Sunrise and Sunset data ]#########################################

epoch_to_time() {
	if date -j -r "$1" +"%r" > /dev/null 2>&1; then
		# BSD
		ret=$(date -j -r "$1" +"$timeformat")
	else
		# GNU
		ret=$(date -d "@$1" +"$timeformat")
	fi
	echo "$ret"
}

if [ "$forecast" = 0 ]
then
	if [ -n "$sunrise" ]
	then
		sunrise_time=$(epoch_to_time "$sunrise")
	fi

	if [ -n "$sunset" ]
	then
		sunset_time=$(epoch_to_time "$sunset")
	fi
fi



###[ Set the period ]##########################################################

now=$(date +%s)

if [ "$forecast" != 0 ]
then
	period="none"
else
	if [ -z "$sunset" ] || [ -z "$sunrise" ]
	then
		period="day"
	elif [ "$now" -ge "$sunset" ] || [ "$now" -le "$sunrise" ]
	then
		period="night"
	else
		period="day"
	fi
fi



###[ Set the scale ]###########################################################

case $units in
	metric)
		scale="°C"
		speed_unit="m/s"
		pressure_unit="hPa"
		pressure=$(echo "$pressure" | xargs printf "%.0f")
		;;
	imperial)
		scale="°F"
		speed_unit="mph"
		pressure_unit="inHg"
		if [ "$forecast" = 0 ]
		then
			pressure=$(echo "$pressure*0.0295" | bc | xargs printf "%.2f")
		fi
		;;
esac



###[ Set icons ]###############################################################

get_icon() {
	case $1 in
		Clear)
			if [ $period = "night" ]
			then
				echo "$moon "
			else
				echo "$sun "
			fi
			;;
		Clouds)
			echo "$clouds "
			;;
		Rain)
			echo "$rain "
			;;
		Fog)
			echo "$fog "
			;;
		Mist)
			echo "$mist "
			;;
		Haze)
			echo "$haze "
			;;
		Snow)
			echo "$snow "
			;;
		Thunderstorm)
			echo "$thunderstorm "
			;;
	esac
}



###[ Display current Weather ]#################################################

if [ "$forecast" != 0 ]
then
	output="$background$text $city $forecast_text $text$delimiter "

	i=0
	while [ $i -lt "$forecast" ]
	do
		day=$(echo "$weather" | jq ".list[$i]")
		date=$(epoch_to_date "$(echo "$day" | jq -r '.dt')")
		low=$(echo "$day" | jq -r '.temp.min' | xargs printf "%.0f")
		high=$(echo "$day" | jq -r '.temp.max' | xargs printf "%.0f")

		icon=""
		if [ "$symbols" = true ]
		then
			sky=$(echo "$day" | jq -r '.weather[0].main')
			icon=$(get_icon "$sky")
		fi

		output="$output$text$date: $data$high$text/$data$low $scale $icon"
		if [ $i -lt $((forecast-1)) ]
		then
			output="$output$dashes "
		fi

		i=$((i + 1))
	done
else
	if [ "$symbols" = true ]
	then
		icon="$(get_icon "$sky")"
	fi
	output="$background$text $greeting_text $city $delimiter$data $temperature $scale $icon"

	if [ "$show_wind" = true ]
	then
		output="$output$dashes$text $wind_text $delimiter$data $wind $speed_unit $direction "
	fi

	if [ "$show_humidity" = true ]
	then
		output="$output$dashes$text $humidity_text $delimiter$data $humidity %% "
	fi

	if [ "$show_pressure" = true ]
	then
		output="$output$dashes$text $pressure_text $delimiter$data $pressure $pressure_unit "
	fi

	if [ "$show_daylight" = true ]
	then
		output="$output$dashes$text $sunrise_text $delimiter$data $sunrise_time $dashes$text $sunset_text $delimiter$data $sunset_time "
	fi
fi

if [ "$ansi" = true ]
then
	env printf "$output\033[0m\n"
else
	env printf "$output\n" | sed "s/$(printf '\033')\[[0-9;]*m//g"
fi

#24 Le 20/12/2018, à 18:11

Sciensous

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

non! c'est le cntenu de  /home/lubuntu/.config/lxsession/Lubuntu/autostart qui m'intéresse !


antiX 19 et 21 et Ubuntu 20.04 et 22.04
( sous LXDE et gnome-shell )

Hors ligne

#25 Le 20/12/2018, à 18:28

Toulibre

Re : [Résolu]Script au démarrage du pc dans la fenêtre du terminal

Oups smile

seulement ceci , j'ai enlevé le reste pour le moment vu que cela ne fonctionne pas

gkrellm
lxterminal

Tu veux également celui de desktop config ? le fichier juste à côté dans le même dossier

Dernière modification par Toulibre (Le 20/12/2018, à 18:31)