Xfce Forum

Sub domains
 

You are not logged in.

#1 2020-03-23 13:29:42

jogl
Member
From: Ontario, Canada
Registered: 2016-02-27
Posts: 21

Shut Down Icon

How can I add a shutdown icon to the desktop?

This thread at Questions has a method, but the thread is old, there must be an easier way now:

https://www.linuxquestions.org/question … op-868910/

I am setting up a machine for my 87 year old father (his old pentium with 256 MB just isn't cutting it anymore) and everything needs to be very simple.

Thanks,
JP.

Offline

#2 2020-03-23 16:41:51

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,678

Re: Shut Down Icon

Right-click on the desktop and select the "Create Launcher" option. Add the following:
- Name = Shutdown
- Comment = Shutdown the computer
- Command = xfce4-session-logout -h
- Icon = <select one that suits>


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2020-03-23 17:59:31

jogl
Member
From: Ontario, Canada
Registered: 2016-02-27
Posts: 21

Re: Shut Down Icon

Very nice.

Thank you ToZ!

Offline

#4 2025-01-13 03:15:09

randyman
Member
Registered: 2025-01-13
Posts: 1
LinuxChrome 131.0

Re: Shut Down Icon

You can issue the command:

shutdown now

You can also suspend with

systemctl suspend

I've put these into scripts, and the added them to the panel so that I can click on them to shutdown or suspend the computer. I've even modified the shutdown icon to make it similar but distinctive for suspend. I can also call the scripts from other scripts, such as backup or moving files or other tasks that take time.

In the suspend script, I've added a preceding line printing out the current date and time, and a superseding line prompting to press a key to exit. That way it leaves a terminal window open so that when the computer wakes from the sleep state I see what the date and time was I suspended it.

I've also written another script where I prompt for a delay in suspending.  It then posts a notification window every so often as the suspend time is approaching, and plays a sound. That full code is:

#! /bin/bash
#strict BASH protocal
#set -euo pipefail
set -u
IFS=$'\n\t'

######################################################

# expand aliases to work when a prompt is not sent to the terminal
# e.g. sounds

if [ -f $HOME/.bashrc_aliases ]; then
	shopt -s expand_aliases
	source "${HOME}/.bashrc_aliases";
fi

######################################################

declare tempvar;

declare index;
declare end_min=60; 		# minutes until suspend
declare gap_min=5; 		# minutes gap between each notify message
declare gap_sec;
declare inner_gap_min=1;	# inner gap between window message
declare inner_gap_sec;
declare inner_gap_count=5;	# ***** Don't know that I need this *****
declare remaining_min;		# minutes remaining until suspend

declare gap_sec=$(( ${gap_min}*60 ));
declare local_message;

# prompt for minutes to suspend

paplay /usr/share/sounds/KDE-Im-Contact-Out.ogg &
read -p "Enter minutes delay to suspend:" end_min;

date;

# gap minutes can't be longer than total minutes to end

if [[ ${gap_min} -gt ${end_min} ]]; then
	gap_min=${end_min};
	gap_sec=$(( ${gap_min}*60 ));
fi

# outer loop to print to notify window until we reach total minutes to end

index=${end_min};

while [[ index -gt 0 ]]; do

	# send message to shell window and to notify window
	
	if [[ ${index} -eq 1 ]]; then
		local_message="Computer will suspend in ${index} minute. ";
	else
		local_message="Computer will suspend in ${index} minutes. ";
	fi
	
	echo -en "${local_message} Press <ctrl>c to cancel.\r";
	notify-send "${local_message}" &
	paplay "/usr/share/sounds/KDE-Im-Message-Out.ogg" &

	# adjust first gap, if necessary, to get on modulo gap (5) minutes

	remainder=$(( ${index} % ${gap_min} ));
	
	# adjust gap, if necessary, to minimum remaining time
	
	if [[ ${gap_min} -gt ${index} ]]; then
		current_gap=${index};
	elif [[ ${remainder} != 0 ]]; then
		current_gap=${remainder};
	else
		current_gap=${gap_min};
	fi
	
#	echo "remainder=${remainder} current_gap=${current_gap} index=${index}";

	# set sleep seconds

	gap_sec=$(( ${current_gap}*60 ));
		
	# Inner loop to print to bash shell window display

	inner_index=${current_gap};
	if [[ ${inner_gap_min} -gt ${current_gap} ]]; then
		inner_step=${current_gap};
	else
		inner_step=${inner_gap_min};
	fi
	
	for (( inner_index=${current_gap}; inner_index >0; inner_index-=${inner_step} )); do

		min_to_go=$(( "${index}-${current_gap}+${inner_index}" ));

		if [[ ${min_to_go} -eq 1 ]]; then
			local_message="Computer will suspend in ${min_to_go} minute. ";
		else
			local_message="Computer will suspend in ${min_to_go} minutes. ";
		fi
		
		echo -en "${local_message} Press <ctrl>c to cancel.\r";
		
		inner_gap_sec=$(( ${inner_step}*60 ));

#		echo ""
#		echo "end_min:${end_min} gap_min:${gap_min} gap_sec:${gap_sec}";
#		echo "inner_index:${inner_index} inner_step:${inner_step} inner_gap_sec:${inner_gap_sec}";

		sleep ${inner_gap_sec};
		
	done

	let index-=${current_gap};

done

# final mesaage
paplay /usr/share/sounds/KDE-Im-Contact-Out.ogg &
local_message="Computer suspending now."
echo -e "\n${local_message}\n" &
notify-send "${local_message}" &

date;

paplay /usr/share/sounds/KDE-Im-Contact-Out.ogg &

systemctl suspend

read -n 1 -s -p "press any key to end." tempvar;

You may have different sound files and/or preferences, so modify it accordingly.

Last edited by randyman (2025-01-13 03:17:06)

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.008 seconds, 7 queries executed - Memory usage: 541.04 KiB (Peak: 547.27 KiB) ]