cancel
Showing results for 
Search instead for 
Did you mean: 

Writing a script.

gleneagles
Aspiring Legend
Posts: 11,105
Thanks: 2,552
Fixes: 17
Registered: ‎02-08-2007

Writing a script.

I would like to put an icon on my desktop that would link to the following instruction, sudo poweroff followed by my password.
As I have no idea about scripts has anyone any idea how I might do this ?
Problem with the shutdown button in Mint 15 is that it sometimes does not shut down correctly ie: the Mint Logo remains on the screen. By typing the above in the terminal it shuts down correctly and whilst it's not a major task to shut down this way I keep forgetting hence my reason for wanting too placing a Icon on the desktop that would do this.
We are born into history and history is born into us.
10 REPLIES 10
HairyMcbiker
All Star
Posts: 6,792
Thanks: 266
Fixes: 21
Registered: ‎16-02-2009

Re: Writing a script.

Right click on desktop, create text file.
Put in it

#!/bin/bash
gksudo shutdown 0

Save it as shutdown.sh.
Right click on it and choose properties, change to the permissions tab, click the executable flag.

VileReynard
Hero
Posts: 12,613
Thanks: 630
Fixes: 20
Registered: ‎01-09-2007

Re: Writing a script.

You will still have to enter your password, though.
BTW I get no problems - if I don't press enter on the shutdown prompt, I get a 60 second countdown until it activates.

"In The Beginning Was The Word, And The Word Was Aardvark."

Nibiru
Community Veteran
Posts: 5,797
Thanks: 426
Fixes: 12
Registered: ‎11-08-2007

Re: Writing a script.

Rather than doing this script thing, have you considered setting the system reporting to verbose, and then read through the shutdown log file to see what is causing the hang up,  and then actually solve the problem rather than attempting a work around.
I had this issue years ago, and it turned out to be the reading of an acpi setting wasn't quite right, but that was easily overridden by adding a flag to one of the commands in the shutdown script, then the machine worked perfectly.
Plusnet FTTC 80/20 IPv4/30, Hurricane Electric 6in4 IPv6/48, Pulse8 landline & calls, SamKnows 600N
Vigor 130 modem, pfSense 2.6.0 router, DrayTek WAPs, Devolo dLAN 500, Gigaset N300A-IP VoIP DECT
gleneagles
Aspiring Legend
Posts: 11,105
Thanks: 2,552
Fixes: 17
Registered: ‎02-08-2007

Re: Writing a script.

Stuck already !
On Rt Click desktop I get the following menu,
Create new folder
Create Launcher
Create New Document
Open in Terminal
Organize Desktop
Keep aligned
Show Hidden files
Paste
Add Desklets
Change Desktop Background.
Purleigh,
Thanks but that's way beyond me as I am fairly new to Linux.
We are born into history and history is born into us.
HairyMcbiker
All Star
Posts: 6,792
Thanks: 266
Fixes: 21
Registered: ‎16-02-2009

Re: Writing a script.

The Third option/ Create New Document
Then Create text file
gleneagles
Aspiring Legend
Posts: 11,105
Thanks: 2,552
Fixes: 17
Registered: ‎02-08-2007

Re: Writing a script.

Solved, realised it was New Document that I needed .
First time I have ever used the Text editor !  Smiley
We are born into history and history is born into us.
VileReynard
Hero
Posts: 12,613
Thanks: 630
Fixes: 20
Registered: ‎01-09-2007

Re: Writing a script.

How do you change the logging level for shutdown?

"In The Beginning Was The Word, And The Word Was Aardvark."

Nibiru
Community Veteran
Posts: 5,797
Thanks: 426
Fixes: 12
Registered: ‎11-08-2007

Re: Writing a script.

These are the instructions for Ubuntu -
How do I diagnose Hang on Shutdown?
How to see what's going on during shutdown
Plusnet FTTC 80/20 IPv4/30, Hurricane Electric 6in4 IPv6/48, Pulse8 landline & calls, SamKnows 600N
Vigor 130 modem, pfSense 2.6.0 router, DrayTek WAPs, Devolo dLAN 500, Gigaset N300A-IP VoIP DECT
VileReynard
Hero
Posts: 12,613
Thanks: 630
Fixes: 20
Registered: ‎01-09-2007

Re: Writing a script.

Hmmmm
I was hoping for a parameter I could change somewhere.
Then have a look in syslog or similar.
Since I'm using Mint (Cinnamon) I'm going to do
Quote
sudo service mdm stop
sudo halt

"In The Beginning Was The Word, And The Word Was Aardvark."

gleneagles
Aspiring Legend
Posts: 11,105
Thanks: 2,552
Fixes: 17
Registered: ‎02-08-2007

Re: Writing a script.

Thanks to all for the help on this issue, some good links there !
We are born into history and history is born into us.