Edit Xubuntu preferences via Command Line

I would like to edit some preferences of xubuntu-desktop (xfce4), but 100% via Terminal.

In ubuntu-desktop (gnome) I use, for example:

   # Prevent suspend and lock the sreen
   gsettings set org.gnome.desktop.screensaver lock-enabled false
   gsettings set org.gnome.desktop.screensaver ubuntu-lock-on-suspend false

   # Set performance settings
   gsettings set org.gnome.desktop.interface enable-animations false
   gsettings set org.gnome.shell.extensions.dash-to-dock animate-show-apps false

   # Set personal configs
   gnome-extensions enable ubuntu-dock@ubuntu.com
   gnome-extensions enable desktop-icons@csoriano
   gnome-extensions enable dash-to-panel@jderose9.github.com
   gnome-extensions enable pixel-saver@deadalnix.me
   gsettings set org.gnome.desktop.privacy remember-recent-files false
   gsettings set org.gnome.SessionManager logout-prompt false

In xubuntu-desktop (xfce4), I can accomplish all these preferences via GUI, but I couldn’t find a way to do the same tasks via Command Line.


Just adding infos for more details:

  • OS: Ubuntu 20.04
  • Types of Access: Remote Desktop via xrdp and SSH
  • Which preferences to change?
    • Prevent system suspension due to inactivity
    • Disable screensaver
    • Disable animations
    • Disable logout confirmation
    • Disable "dock"
    • Change panel position
    • References I: similar commands to gsettings set ... and gnome-extensions enable ... from ubuntu-desktop (gnome) to perform changes
    • References II: similar commands to gsettings list-schemas and gsettings list-keys ... — also from ubuntu-desktop (gnome) — to list the available preference settings
Asked By: Weslley Araújo

||

Solution:

The command to perform the changes: xfconf-query.


Listing Available Channels for Change

   xfconf-query -l

Listing the Properties per Channel

   xfconf-query -c $PROPERTY -l -v

   # For example, the property "xfce4-desktop":
   xfconf-query -c xfce4-desktop -l -v
  • -v: displays the value of the properties.
  • Each / is a subproperty.

Monitoring Changes in Real Time

   xfconf-query -c $PROPERTY -m

   # For example, the property "xfce4-desktop":
   xfconf-query -c xfce4-desktop -m
  • For example, if the workspace0 wallpaper is changed, it will display the full path of the updated property: /backdrop/screen0/monitorrdp0/workspace0/last-image.
  • You can start monitoring and making changes via the GUI, where all the properties that have been changed will be displayed in the terminal for later use via the command line.

Creating or Updating a Property

   xfconf-query -c $CHANNEL -np $PROPERTY -t 'bool' -s 'true';

   # For example, the channel "xfce4-panel" and the property "/panels/dark-mode":
   xfconf-query -c xfce4-panel -np '/panels/dark-mode' -t 'bool' -s 'true';
  • -n: ensures that if the property doesn’t exist, it will be created.
  • You must enter the type of the property value:
       [ 'string', 'int', 'bool', 'double' ]
    
  • -s: sets the value of the property.
  • To insert an array with multiple elements, just insert the type and value in sequence:
       -t int -s 0 -t int -s 1 -t int -s 2 #...
    
  • To force a single item as an array:
       -t int -s 0 -a
    

Removing a Property

   xfconf-query -c $CHANNEL -p $PROPERTY -r -R;

   # For example, removing "Panel 2" completely:
   xfconf-query -c xfce4-panel -p '/panels/panel-2' -r -R;
  • -r: indicates the removal.
  • -R: ensures that all subproperties are deleted along with the property.

Xfce Terminal

  • You can edit the Xfce Terminal preferences into ~/.config/xfce4/terminal/terminalrc.
  • You can edit via GUI and copy the file for later use.
    • Just close and reopen terminal to see the changes.

Whisker Menu

  • If you use the Whisker Menu, you can edit preferences into ~/.config/xfce4/panel/whiskermenu-**.rc.
    • Replace ** with the order of plugin:

      Look for the plugin whistermenu in the xfce4-panel/plugins property to see the plugin number.

      For example, if Whister Menu is plugin-19, then: ~/.config/xfce4/panel/whiskermenu-19.rc.

  • You can edit via GUI and copy the file for later use.

Considerations:

  • Most changes that affect the front end require logging out and logging in again to view the changes, especially in the panels.
  • The xfconf-query command only works with the display active.

Below is the script with the complete solution to the problem at hand:

   #!/bin/sh

   # Check the display's availability
   if [ -z $DISPLAY ]; then exit 1; fi;

   # Prevent suspend and lock the sreen
   xfconf-query -c xfce4-screensaver -np '/lock/enabled' -t 'bool' -s 'false';
   xfconf-query -c xfce4-screensaver -np '/lock/saver-activation/enabled' -t 'bool' -s 'false';
   xfconf-query -c xfce4-screensaver -np '/saver/enabled' -t 'bool' -s 'false';
   xfconf-query -c xfce4-power-manager -np '/xfce4-power-manager/inactivity-on-ac' -t int -s 0;
   xfconf-query -c xfce4-power-manager -np '/xfce4-power-manager/blank-on-ac' -t int -s 0;
   xfconf-query -c xfce4-power-manager -np '/xfce4-power-manager/dpms-on-ac-sleep' -t int -s 0;
   xfconf-query -c xfce4-power-manager -np '/xfce4-power-manager/dpms-on-ac-off' -t int -s 0;
   xfconf-query -c xfce4-power-manager -np '/xfce4-power-manager/lock-screen-suspend-hibernate' -t 'bool' -s 'false';
   xfconf-query -c xfce4-power-manager -np '/xfce4-power-manager/dpms-enabled' -t 'bool' -s 'false';

   # Remove dock
   xfconf-query -c xfce4-panel -p '/panels/panel-2' -r -R;
   xfconf-query -c xfce4-panel -np '/panels' -t int -s 1 -a;

   # Removing wallpaper
   xfconf-query -c xfce4-desktop -np '/backdrop/screen0/monitorrdp0/workspace0/color-style' -t int -s 0;
   xfconf-query -c xfce4-desktop -np '/backdrop/screen0/monitorrdp0/workspace0/image-style' -t int -s 0;
   xfconf-query -c xfce4-desktop -np '/backdrop/screen0/monitorrdp0/workspace0/rgba1' -t double -s 0.184314 -t double -s 0.207843 -t double -s 0.258824  -t double -s 1.000000;

   # Personal settings
   xfconf-query -c xfce4-desktop -np '/desktop-icons/tooltip-size' -t 'double' -s 48.000000;
   xfconf-query -c xfce4-desktop -np '/desktop-icons/gravity' -t int -s 0;
   xfconf-query -c xfwm4 -np '/general/workspace_count' -t int -s 1;

   # Put menu in bottom
   xfconf-query -c xfce4-panel -np '/panels/dark-mode' -t 'bool' -s 'true';
   xfconf-query -c xfce4-panel -np '/panels/panel-1/position' -t 'string' -s 'p=10;x=0;y=0';
   xfconf-query -c xfce4-panel -np '/plugins/plugin-1/show-tooltips' -t 'bool' -s 'true';

   # Grouping tasklist
   xfconf-query -c xfce4-panel -np '/plugins/plugin-2/grouping' -t int -s 1;

   # Logout settings
   xfconf-query -c xfce4-session -np '/shutdown/ShowSuspend' -t 'bool' -s 'false';
   xfconf-query -c xfce4-session -np '/shutdown/LockScreen' -t 'bool' -s 'false';
   xfconf-query -c xfce4-session -np '/shutdown/ShowHibernate' -t 'bool' -s 'false';
   xfconf-query -c xfce4-session -np '/general/PromptOnLogout' -t 'bool' -s 'false';

   # Logout to save changes
   xfce4-session-logout --logout;

Sources:

Answered By: Weslley Araújo