Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 508  / 1 Year ago, fri, may 19, 2023, 4:06:05

I wanted to run this at start-up because I like to play around with multiple DEs. When I run this script from a file it won't run Docky.



I have already changed the file permissions so that it is allowed to run as a program.



When I type exactly this into gnome-terminal it will run Docky if I am logged into gnome-classic. I wanted to run this script at startup so that Docky wouldn't start in Unity:



if [ $DESKTOP_SESSION == "gnome-classic" ] ; then docky ; fi


Any suggestions?
I tried writing something like Firefox in the same file and it will start Firefox.
So when I run the following script from a file...



cd /home/user/Desktop
mkdir ITRAN
if [ $DESKTOP_SESSION == "gnome-classic" ] ; then docky ; fi


It makes a new file on my desktop but won't run Docky even though if I simply copy the same code into a terminal window it runs...



With geirha's help, I changed the script. However, now docky launches no matter what DE I run, Unity or gnome-classic.



#!/bin/sh
if [ $DESKTOP_SESSION = "gnome-classic" ]; then
docky
fi


I've also tried



$DESKTOP_SESSION = "gnome-classic"
$DESKTOP_SESSION = gnome-classic
"$DESKTOP_SESSION" = gnome-classic
"$DESKTOP_SESSION" = "gnome-classic"


to rule out the possibility that I had that part wrong.


More From » scripts

 Answers
4

The [ command does not have a == operator. Bash allows it, but dash will cringe. The correct operator to use is =. The script you posted in your question does not have a shebang, so it likely gets run by sh. So:



#!/bin/sh
mkdir -p "$HOME/Desktop/ITRAN"
if [ "$DESKTOP_SESSION" = gnome-classic ]; then
docky
fi


Anyway, if it fails, you'll likely find the error messages in ~/.xsession-errors, so look in there for clues.


[#37231] Friday, May 19, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ongdiligenc

Total Points: 452
Total Questions: 111
Total Answers: 107

Location: Ukraine
Member since Sun, Dec 13, 2020
3 Years ago
ongdiligenc questions
Wed, Apr 13, 22, 10:34, 2 Years ago
Tue, Jun 7, 22, 00:54, 2 Years ago
Sat, Aug 7, 21, 00:37, 3 Years ago
Sat, May 22, 21, 03:06, 3 Years ago
Tue, Mar 1, 22, 10:05, 2 Years ago
;