Quel utilitaire graphique puis-je utiliser pour l’extinction automatique d’Ubuntu?

Dans Microsoft Windows, j’utilise switch off logiciel d’extinction pour l’extinction automatique, la switch off prolongée, le redémarrage, etc. Puis-je trouver quelque chose de similaire dans Ubuntu?

éteindre

Je lis le lien suivant. Comment puis-je éteindre automatiquement le système après une heure donnée?

GShutdown est un utilitaire qui vous permet de planifier l’arrêt ou le redémarrage de votre ordinateur. Avec elle, vous pouvez simplement et rapidement choisir le temps d’extinction à un moment précis ou après un compte à rebours.

Installez Gshutdown:

 sudo apt-get install gshutdown 

entrez la description de l'image ici

la source.

Pour une raison inconnue, ces types d’applications ne durent pas longtemps et sont interrompus lors des nouvelles itérations d’Ubuntu. Gshutdown n’a pas fonctionné immédiatement pour Ubuntu 15.10 et il n’est pas très pratique de télécharger quelques centaines de Mo de dépendances pour une application kwin. Du moins pas pour ce genre d’application.

Voici un petit script que j’ai écrit qui pose ce problème et que c’est sans doute un meilleur choix. Pourquoi :

  • c’est un script graphique donc il peut être exécuté comme une application classique
  • comme toute autre fonctionnalité de script peut être ajustée selon les préférences de l’utilisateur
  • le code peut être utilisé dans diverses dissortingbutions et il est peu probable que cela change de sitôt
  • diverses options incluses sont décrites dans le script.

Dialogue de fermeture en action: entrez la description de l'image ici

Comment l’utiliser

Il n’ya qu’un package à installer qui traite de la fonctionnalité d’inactivité de l’utilisateur , mais le script exécutera bien les autres options disponibles sans elle. Pour installer le type ‘xprintidle’ dans le terminal:

 sudo apt-get install xprintidle 

Ouvrez l’éditeur de texte, collez le code fourni ci-dessous et enregistrez le fichier sous Shutdown_dialog dans votre dossier personnel. Faites un clic droit sur le fichier et sélectionnez allow executing file as program ou via un terminal:

 chmod +x ~/Shutdown_dialog 

Le code:

 #!/bin/bash ###########< "$default_conf_file" rm_default_conf_file="$default_conf_file" fi } select_app () { options=$(zenity --forms --title="Reappeared shutdown dialog" --text="\n You are running WHEN SELECTED APPLICATION EXIT option! \n\n Choose additional settings, press OK and then click on application\n to select. Use Alt+Tab to cycle through open applications.\n\n" --add-list="Select an action:" --list-values='Shutdown|Restart|Suspend|Logout|Lock screen' --add-combo="Unavailable option" --combo-values= --add-combo="Unavailable option" --combo-values= --add-combo="Unavailable option" --combo-values= --add-combo="Unavailable option" --combo-values= --add-entry="Run command before action executes:" --add-combo="Unavailable option" --combo-values= --add-entry="Seconds to display confirmation dialog:" --add-combo="Play sound on confirmation dialog:" --combo-values="|default_sound_1|default_sound_2|default_sound_3") [ $? == 1 ] && exit 1 win_id=$(xdotool selectwindow) notify-send "Window selected: $(xdotool getwindowname $win_id)" win_id=$(printf 0x0%x "$win_id") while : do [[ -z $(wmctrl -l | grep "$win_id") ]] && break || sleep 5 done } user_inactivity () { which xprintidle if [ $? == 1 ];then zenity --warning --timeout=7 --ellipsize --text="\tPackage 'xprintidle' is not installed.\n\n Option ** \"ON USER INACTIVITY\" ** cannot be used!\n\n\t\t Exiting...." [ -f "$rm_default_conf_file" ] && rm "$default_conf_file" exit 1 fi while [[ "$idle_time" -lt "$var3" ]] do idle_time=$(( $(xprintidle) / 60000 )) sleep 5 done } notification () { x=1 [ -z "$time" ] && return 1 notify-send "System will $var1 in $time minutes!" while : do remaining=$(( $time - $x * $var7 )) sleep "$var7"m notify-send "System will $var1 in $remaining minutes!" x=$(( x + 1 )) [ "$remaining" -lt "$var7" ] && break done sleep "$remaining"m } #####Confirmation dialog shown before action is executed confirmation_dialog () { [ -n "$sound" ] && play "$sound" & $(sleep 0.9;wmctrl -r "Shutdown confirmation dialog" -b add,above) & #comment this line if you don't want dialog to be above other windows zenity --question --title="Shutdown confirmation dialog" --text="System will $var1 in $var8 seconds! \n\nDo you wish to execute?" --ellipsize --timeout="$var8" --cancel-label=Cancel [ $? == 1 ] && exit 1 } ###### Initial Shudown dialog window ####### options=$(zenity --forms --title="Shutdown dialog" --text="\nAvailable options are documented in the header of the script\n\n *Only one of the marked options can be used at the same time\n" --add-list="Select an action:" --list-values='Shutdown|Restart|Suspend|Logout|Lock screen' --add-entry="Time from now (min)*:" --add-entry="On user inactivity (min)*:" --add-entry="At specific time (hh:mm) and date:*" --add-calendar="Select date for previous option" --forms-date-format=%Y-%m-%d --add-entry="Run command before action executes:" --add-entry="Show desktop notifications every (min):" --add-entry="Seconds to display confirmation dialog (s):" --add-combo="Play sound on confirmation dialog:" --combo-values="|default_sound_1|default_sound_2|default_sound_3" --extra-button="When selected application exit" --extra-button="Default") #####Validate selection and call functions if [ $? != 0 ];then if [ "$options" == "When selected application exit" ];then select_app elif [ "$options" == "Default" ];then default_option else exit 1 fi fi #####Variables assignment old="$IFS" IFS="|" read -r var{1..9} <<< "$(echo "$options")" IFS="$old" #####Validate and define time variables if [ "$var2" != 0 ] && [ -z "$var3" ] && [ -z "$var4" ]; then time="$var2" elif [ "$vr3" != 0 ] && [ -z "$var2" ] && [ -z "$var4" ]; then if [ ! -z "$var7" ];then zenity --warning --timeout=7 --ellipsize --text="\nThe *** \"ON USER INACTIVITY\" *** option cannot be used with desktop notifications!\n\n\t\t Exiting...." [ -f "$rm_default_conf_file" ] && rm "$default_conf_file" exit 1 fi user_inactivity elif [ "$vr4" != 0 ] && [ -z "$var3" ] && [ -z "$var2" ]; then current=$(date +%s) target=$(date +%s -d "$var5 $var4") time=$(( ($target - $current) / 60 )) elif [ "$var2" == " " ] && [ "$var3" == " " ] && [ "$var4" == " " ]; then : else zenity --warning --timeout=5 --ellipsize --text="\t*Only one of the marked options can be used at the same time!\n\n\t\t Exiting...." [ -f "$rm_default_conf_file" ] && rm "$default_conf_file" exit 1 fi #####Validate selection and define action (replace it with commented one if it doesn't work) case $var1 in Shutdown,) action="poweroff";; #"systemctl poweroff" Restart,) action="reboot";; #"systemctl reboot" # Hibernate,) # action="systemctl hibernate";; Suspend,) action="systemctl suspend";; Logout,) action="gnome-session-quit --logout --no-prompt";; #"pkill -u $USER" Lock?screen,) action="gnome-screensaver-command -l";; #"xdotool key Ctrl+Alt+l" esac #####Validate other settings [ -n "$var7" ] && notification [ -z "$var8" ] && var8="$defaul_time_to_show_confirmation_dialog" [ "$var9" != 0 ] && case $var9 in default_sound_1) sound="$default_sound_1";; default_sound_2) sound="$default_sound_2";; default_sound_3) sound="$default_sound_3";; esac #####Execute [[ -n "$time" && -z "$var7" ]] && sleep "$time"m confirmation_dialog eval "$var6" eval "$action" exit 0 

Vous pouvez éventuellement créer une icône de bureau. Ouvrez l'éditeur de texte, collez le code fourni ci-dessous et enregistrez le fichier sous le nom Shutdown_dialog.desktop dans votre dossier de bureau. Faites un clic droit sur le fichier et sélectionnez allow executing file as program ou via un terminal:

 chmod +x ~/Desktop/Shutdown_dialog.desktop 

Le code:

 #!/usr/bin/env xdg-open [Desktop Entry] Name=Shutdown dialog Comment=Shutdown dialog script Terminal=false Icon=/usr/share/icons/oxygen/64x64/actions/system-shutdown.png Exec="/home/username/Shutdown_dialog" Type=Application Categories=Application;Utility; Name[en_US]=Shutdown dialog 

Assurez-vous simplement que la ligne Exec a un chemin absolu vers le script.

Si quelque chose n'est pas clair, commentez et je modifierai si nécessaire.

Je pense que GShutdown est le meilleur parmi ces utilitaires. Mais pour que cela fonctionne avec Ubuntu 15.10, vous devez faire quelques astuces.

  1. installer et ouvrir gshutdown
  2. Édition -> Préférences
  3. Sélectionnez “Commande personnalisée”
  4. Cliquez sur “Arrêter l’ordinateur” et collez ce sh -c “dbus-send –system –print-reply –dest = org.freedesktop.login1 / org / freedesktop / login1” org.freedesktop.login1.Manager.PowerOff “booléen: vrai”