Skip to content
Snippets Groups Projects
README.md 11.2 KiB
Newer Older
![alt tag](https://gitlab.version.fz-juelich.de/vis/xdg_profiles/raw/master/screenshot_xdg_profile_vis.png)
# XDG Desktop Profiles
The support of VNC remote graphical desktops on JURECA enables us to presents the JSC to the HPC-Users in a fresh and modern way.
But a graphical desktop is of course not limited to eye-candy design alone.
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed

A graphical desktop can increase productivity of each HPC-user as the workflows become more complex and change more often.
It also helps new users to shorten the time to debug, run and post-process their codes (e.g. debugging, performance and visualization tools are more easy to start use).
But different user groups and various research topics make sense for multiple desktop configurations.
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed

Jens Henrik  Goebbert's avatar
Jens Henrik Goebbert committed
The solution are XDG Desktop Profiles (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html).
They are located in *${XDG_PROFILES_DIR}* with each profile located in one subdirectory.
The current profile name is *${XDG_PROFILE}*.
## What is an XDG Desktop Profile?
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed

A XDG desktop profile is a set of desktop configurations, most notable:
- background image
- desktop icons
- applications menu ("Start Menu")
- desktop widgets (information embedded into the background image)
- autostart
- application configurations
Jens Henrik  Goebbert's avatar
Jens Henrik Goebbert committed
- bookmarks
#### ${XDG_CONFIG_*}
All of these settings are stored in files located in *${XDG_CONFIG_HOME}* for each user.
Global settings are stored in *${XDG_CONFIG_DIRS}*.
Jens Henrik  Goebbert's avatar
Jens Henrik Goebbert committed
*${XDG_CONFIG_HOME}* is set to *${HOME}/.config/xdg_profiles/${XDG_PROFILE}*.
*${XDG_CONFIG_DIRS}* includes multiple directories starting with *${XDG_PROFILES_DIR}/${XDG_PROFILE}/config/*
(in general *${XDG_CONFIG_HOME}* is set to *${HOME}/.config* and *${XDG_CONFIG_DIRS}* to */etc/xdg/*)
New configurations and modifications made by the user are stored in *${XDG_CONFIG_HOME}*.
These configurations overwrite all settings located in *${XDG_CONFIG_DIRS}*.
#### ${XDG_DATA_*}
All XDG data, which is independent of a certain configuration, is stored in *${XDG_DATA_HOME}* for each user or in *${XDG_DATA_DIRS}* system-wide.
Jens Henrik  Goebbert's avatar
Jens Henrik Goebbert committed
This can be
- background images
- .desktop-files for desktop icons, menus or autostart files
- icons
- submenus for the application menu
- mime type settings
- infoterm directories
*${XDG_DATA_HOME}* is set to *${HOME}/.local/xdg_profiles/${XDG_PROFILE}*.
*${XDG_DATA_DIRS}* includes multiple directories starting with *${XDG_PROFILES_DIR}/${XDG_PROFILE}/data/*
(in general *${XDG_DATA_HOME}* is set to *${HOME}/.local* and *${XDG_DATA_DIRS}* to */usr/local/share:/usr/share*)

#### ${XDG_PROFILES_DIR}/${XDG_PROFILE}
Each XDG desktop profile is stored in its own XDG_CONFIG-directory (e.g. */etc/xdg/xdg_profiles/\<profile\>/*) and inherit configurations from the desktop profiles 'default' and the linux-distribution-defaults in */etc/xdg*.
Hence, a new XDG desktop profile might consist only of some additional desktop icons, a different background image or an new sub-menu for the application menus added on top of the default profile.
## How are XDG Desktop Profiles chosen?
The XDG Desktop Profile is chosen by setting *${XDG_PROFILE}* just before the VNC server is started.
export XDG_PROFILE=vis
vncserver
On JURECA the command *vncserver* has the additional option *'profile'*
```shell
vncserver -profile vis
``

Jens Henrik  Goebbert's avatar
Jens Henrik Goebbert committed
The VNC server calls *${HOME}/.vnc/xstartup[.turbovnc]* (use *dot.vnc/xstartup[.turbovnc]* from this repository),
which must call **xdg_profile_set.sh** currently located in *etc/xdg/* of this repository.
If the directory *etc/xdg/xdg_profiles/${XDG_PROFILE}* exists, xdg_profile_set.sh sets the *${XDG_CONFIG_\*}* and *${XDG_DATA_\*}* variables and some more.
Jens Henrik  Goebbert's avatar
Jens Henrik Goebbert committed
Additionally this script clears cache, creates desktop links and copies other files.
Example: starting a VNC-server-job with an the visualization XDG desktop profile on a visualization the visualization partition of JURECA:
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed
```shell
salloc -N 1 -p vis --gres=mem512,gpu:1 --start-xserver --time=1:00:00
srun -n 1 --cpu_bind=none --gres=gpu:1 bash -c 'vncserver -profile vis'
## XFCE4 XDG configurations
XDG Base Directory Specification are supported by most of the popular desktop systems found on Linux (GNOME, KDE, XFCE etc.). On JURECA we use XFCE4 as a light weighted desktop system.
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed
XFCE4 specific configurations are stored in *${XDF_CONFIG_\*}/xfce4/* and
XFCE4 specific data is stored in *${XDF_DATA_\*}/xfce4/*. Examples are:
- desktop settings
  - desktop settings file (including background image)
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed
    - ${XDF_CONFIG_\*}/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml
  - desktop menu description file:
    - ${XDG_CONFIG_\*}/xfce4/desktop/menu.xml
  - default location of all desktop backgrounds:
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed
    - ${XDF_DATA_\*}/xfce4/backdrops/*
- panel settings
  - panel settings file
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed
    - ${XDG_CONFIG_\*}/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml
  - panel widget description files:
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed
    - ${XDG_CONFIG_\*}/xfce4/panel/
#### Background Image
The background image is set in *${XDF_CONFIG_\*}/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml*.
The first XDF_CONFIG-directory, which includes this file sets the background image.
The path must be an absolute path.
It is not processed by bash and must not include any system variables.
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed
Background images of desktop profiles should be located in *${XDF_DATA_\*}/xfce4/backdrops/* to be found by XFCE4 on default.
XFCE4 can loop through background images.
Therefore multiple images must be listed in */etc/xdg/xdg_profiles/\<profile\>/xfce4/desktop/backdrop.list*.
backdrop-cycle-enable and backdrop-cycle-timer must be set in */etc/xdg/xdg_profiles/\<profile\>/xfce4/xfconf/xfce-perchannel.xml/xfce4-desktop.xml*.
#### Desktop Icons
##### .desktop files
Any .desktop file found in the XDG_DESKTOP directory is shown on the desktop.
XDG_DESKTOP_DIR can be set in ${XDG_CONFIG_HOME}/user-dirs.dirs and is ${HOME}/Desktop by default.
XDG Desktop Profiles must include a user-dirs.dir in *etc/xdg/xdg_profiles/\<profile\>/config/*,
which sets XDG_DESKTOP_DIR to ${HOME}/.local/xdg_profiles/\<profile\>/Desktop (== ${XDG_DATA_HOME}/Desktop).

The .desktop files of an XDG desktop profile must be located in *etc/xdg/xdg_profiles/\<profile\>/data/Desktop/*.
On each login links will be created in ${XDG_DATA_HOME}/Desktop/ to all files in this directory.

##### positions
In XFCE4 icons are positioned with row/column coordinates.
The position is stored in *${XDF_CONFIG_\*}/xfce4/desktop/icons.screen?-<resolution-identifier>.rc*.
If the size of each cell is changed, the coordinates remain the same but the grid gets enlarged.
XFCE4 will rearrange all icons on the desktop, if the screen resolution is smaller than the required resolution needed to fit the max. row or max. column.
Hence, icons be placed in the top left area of the desktop and must fit on a min. resolution of 1024x768 in each desktop profile.

#### Application Menu

##### Customize Menu Structure
The applications menu is generated from the file *etc/xdg/xdg_profiles/default/config/menus/xfce-applications.menu*.
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed
It merges additional menus from *${XDG_CONFIG_\*}/menus/application-merged/*.
Sub-menu of XDG desktop profiles are located in *etc/xdg/xdg_profiles/\<profile\>/config/menus/application-merged/.
Profile-specific .directory-files must be placed in *etc/xdg/xdg_profiles/\<profile\>/data/desktop-directories/*.
Additional information can be found here *https://wiki.xfce.org/howto/customize-menu*.

Sub-menus of general profiles (like 'Visualization', 'Performance Analysis', etc.) can be placed in the profile 'default', too, to be visible in any profile.

##### Customize Menu Entries
Any menu entry belongs to a corresponding .desktop-file in *${XDG_DATA_DIRS}/applications*.

The category name (defined by xfce-applications.menu and its .directory-files) describes in which sub-menu it will be placed.
Example: vis.directory defines the category "Visualization".
Adding "Category=Visualization" to a .desktop-file will place it in the sub-menu "Visualization".

##### Change Application Menu Icon
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed
The application menu icon is set in *${XDF_CONFIG_\*}/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml*.
By default it is set in the default profile in *etc/xdg/xdg_profiles/default/config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml*
to the FZJ logo located in *etc/xdg/xdg_profiles/default/data/pixmaps/fzj-logo_64x64.png*.
Jens Henrik  Goebbert's avatar
Jens Henrik Goebbert committed
##### MIME Types
MIME types are defined in ${XDG_DATA_DIRS}/mime/packages.
Add new mime types to Override.xml in this directory

##### Places
The file manager thunar reads ${HOME}/.gtk-bookmarks (and in new versions ${XDG_CONFIG_HOME}/gtk-3.0/bookmarks to add shortcuts to certain places.
Here we can add ${WORK} and ${ARCH} for example.

file://PATH_TO_YOUR_FOLDER PLACE_NAME

#### Info-Terminal
An info terminal can be part of a profile to present text information to the user.
Jens Henrik  Goebbert's avatar
Jens Henrik Goebbert committed
It is located in *${XDG_DATA_DIR}/infoterm-\<cmd\>-\<profile\>*.
It is located in *etc/xdg/xdg_profiles/\<profile\>/config/infoterm-\<profile\>*.
It is started via the desktop-file *etc/xdg/xdg_profiles/\<profile\>/config/autostart/infoterm-\<profile\>.desktop* on every start of XFCE4 with the desktop profile \<profile\>.
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed
In all directories of XDG_CONFIG_DIRS the script infoterm-\<profile\>.sh is searched and (if found) executed:
```shell
IFS=:
for p in ${XDG_CONFIG_DIRS}; do
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed
  if [ -e ${p}/infoterm-\<profile\>/infoterm-\<profile\>.sh ]; then
    ${p}/infoterm-\<profile\>/infoterm-\<profile\>.sh
    break
  fi
done
```
Jens Henrik Goebbert's avatar
Jens Henrik Goebbert committed
infoterm-\<profile\>.sh must be unique and only part of a single desktop profiles - do not use the same name in multiple desktop profiles.
>>>>>>> 9561c64f238d0d8ee272bb4c99c8121c96fa1761
Jens Henrik  Goebbert's avatar
Jens Henrik Goebbert committed
It is started via the desktop-file *etc/xdg/xdg_profiles/\<profile\>/config/autostart/infoterm-\<cmd\>-\<profile\>.desktop* on every start of XFCE4 with the desktop profile \<profile\>.
The configuration of the info terminal is done partly in *infoterm-\<cmd\>-\<profile\>.sh* and partly by setting the application specific XDG_CONFIG_HOME to *etc/xdg/xdg_profiles/\<profile\>/data/infoterm-\<cmd\>-\<profile\>*.
This is for settings, which cannot be done via command line parameters like transparency and are only stored in configuration files.
##### window settings

An info terminal is supposed to stay in the background and should not be present in the tasklist or on the pagers.
This is achived via devilspie2 (https://savannah.nongnu.org/projects/devilspie2).

Devil's Pie can be configured to detect windows as they are created, and match the window to a set of rules.
If the window matches the rules, it can perform a series of actions on that window.

These rules are stored in *etc/xdg/xdg_profiles/\<profile\>/config/devilspie2/\*.lua*
and copied to *${XDG_CONFIG_HOME}/devilspie2/* on each VNC-server-start.
You can find an example in *etc/xdg/xdg_profiles/vis/config/devilspie2/infoterm-vis.lua*

Devil's Pie runs in the background and is called from *etc/xdg/xdg_profiles/default/autostart/devilspie2.desktop*

## How to generate a new profile

Jens Henrik  Goebbert's avatar
Jens Henrik Goebbert committed
- use xdg_profile_clone.sh to clone an XDG profile and store it in ${HOME}/.local/xdg/xdg_profiles/\<profile\>
- login to your cloned profile and modify as you like
- use xdg_profile_publish.sh to make your new profile
## IMPORTANT NOTICE:
1. Absolute paths are present in the configuration files of this repository. They have to be changed before use:
  - **call ./setup.sh to change the paths**
Jens Henrik  Goebbert's avatar
Jens Henrik Goebbert committed
2. copy or link dot.vnc/xstartup[.turbovnc] to your ~/.vnc directory