Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain the path of Desktop in gnome

I am using gnome/Ubuntu-10.10 in Chinese language and the desktop path is not "~/Desktop" but "~/XXXX" where XXXX stands for the Chinese translation of "Desktop". So, how to write code to obtain the proper path of desktop regardless of the system language? I noticed Qt SDK properly added a shortcut on the desktop so I guess there is a way. Thanks a lot!

like image 491
FlareCat Avatar asked Dec 05 '10 09:12

FlareCat


People also ask

Where are GNOME desktop stored?

desktop files, which are located in /usr/share/applications (or sometimes /usr/local/share/applications ). Some applications may place these files in ~/. local/share/applications instead.

How do I find the desktop folder in Ubuntu?

To navigate into the root directory, use "cd /" To navigate to your home directory, use "cd" or "cd ~" To navigate up one directory level, use "cd .." To navigate to the previous directory (or back), use "cd -"

Where do you locate the GNOME application places?

Application menu, located beside the Activities button, shows the name of the active application alongside with its icon and provides quick access to windows and details of the application, as well as a quit item.


4 Answers

One more way to do it:

dir=$(xdg-user-dir DESKTOP)
like image 81
Tobu Avatar answered Oct 14 '22 01:10

Tobu


The locations of the user directories are described in the xdg-user-dirs specification. They provide some code here that you can copy, to look up the name of the desktop directory from within your code.

like image 23
ptomato Avatar answered Oct 14 '22 03:10

ptomato


If you are using Glib, you can do

const char *desktop_dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);

This properly pays attention to the XDG environment variables and all that.

like image 20
Federico Mena-Quintero Avatar answered Oct 14 '22 01:10

Federico Mena-Quintero


echo ${XDG_DESKTOP_DIR:-$HOME/Desktop}

works fine on a local linux drive and also when the /home/<user> is mapped to an nfs drive.

like image 29
syam Avatar answered Oct 14 '22 02:10

syam