0

I am starting Qt-Linguist in a bash script via

sudo linguist-qt4 $PathToParentDir/translate_$lang.ts

I could also use gksu instead of sudo but this would add more dependencies since most people don't have gksu installed. On the left picture you see how ugly it looks, it should look like on the right hand side when started normally. How can I start a program in a bash-script so that it looks like in the right picture?

Left: ugly; Right: correct version

user2366975
  • 717
  • 1
  • 10
  • 19
  • Because the *.ts-file is placed in /opt/my_program/translations and could not be saved, if it would not have root privileges. And if the script itself is placed in /opt, the Qt-Linguist looks ugly even without the sudo-command. – user2366975 Sep 27 '13 at 11:00
  • Then it sounds like the proper solution is to change permissions of that directory (meant /opt/my_program/translations), or is it undesirable? – volferine Sep 27 '13 at 11:03
  • Hm interesting, now i found out that the program is able to save without being run with sudoin the bash-script. That's good, but still it is looking so ugly... Can i workaround this? – user2366975 Sep 27 '13 at 11:06
  • I would recommend against running arbitrary programs as root, but your security is your choice. Anyway, about the looks of the application: the dependencies that gksu would pull in (in particular GTK+) are probably precisely those which will make the application look more, well, GTK-like. – zwets Sep 27 '13 at 11:09

1 Answers1

0

The program interface looks ugly because you start the program with sudo, but sudo is used to execute a command in text mode.

So, you need a command to start the program in graphical mode as root. This can be gksudo. See What is the difference between "gksudo nautilus" and "sudo nautilus"?. But (gksu) is no longer installed by default starting with Ubuntu 13.04. Its alternative is pkexec. So, you can use the following if:

if [ -x /usr/bin/gksu]; then     #if `gksu` exists and is executable
    gksu linguist-qt4 $PathToParentDir/translate_$lang.ts
else
    pkexec linguist-qt4 $PathToParentDir/translate_$lang.ts
fi

Or, you can try simple:

sudo -i linguist-qt4 $PathToParentDir/translate_$lang.ts

So, sudo -i command. But I'm not sure about it - check yourself.

Radu Rădeanu
  • 169,590