CDE: Difference between revisions

From NixOS Wiki
imported>User
No edit summary
Klinger (talk | contribs)
 
(30 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[File:CDE.png]]
{{low quality|This page contains pseudo-code which will not work out of the box.}}
{{warning|This article makes use of precarious stateful system manipulations (imperatively writing to <code>/etc</code>).}}
 
[[File:CDE.png|frameless|right]]


Aka '''cdesktopenv''' or '''Common Desktop Environment''' is a vintage desktop environment.
Aka '''cdesktopenv''' or '''Common Desktop Environment''' is a vintage desktop environment.


== Enabling ==
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
  services.xserver.desktopManager.cde.enable = true;
</nowiki>}}


== Changing fonts ==
== Changing fonts ==
   sudo mkdir -p /etc/dt/config/xfonts
   sudo mkdir -p /etc/dt/config/xfonts
   sudo cp -r ${pkgs.cdesktopenv}/opt/dt/appconfig/types/C /etc/dt/config/xfonts
   sudo cp -r ${pkgs.cdesktopenv}/opt/dt/config/xfonts/$LANG /etc/dt/config/xfonts
   sudo cp -r ${pkgs.cdesktopenv}/opt/dt/appconfig/types/en_US.UTF-8 /etc/dt/config/xfonts
   sudo sed -i '/dt-interface/d' /etc/dt/config/xfonts/$LANG/fonts.alias


Now edit /etc/dt/config/xfonts/*/fonts.alias and remove all '''-dt-interface''' references. Add these instead. In this example Helvetica and Courier are used instead of fixed fonts.
Now add the following to /etc/dt/config/xfonts/$LANG/fonts.alias file. In this example Helvetica and Courier are used instead of fixed fonts.


   "-dt-interface system-medium-r-normal-xxs sans-10-100-72-72-p-61-iso8859-1"  "-adobe-helvetica-medium-r-normal--10-*-75-75-p-56-iso8859-1"
   "-dt-interface system-medium-r-normal-xxs sans-10-100-72-72-p-61-iso8859-1"  "-adobe-helvetica-medium-r-normal--10-*-75-75-p-56-iso8859-1"
Line 47: Line 45:
xosview2 &
xosview2 &
</nowiki>}}
</nowiki>}}
   chmod +x ~/.dt/sessions/sessionetc
   chmod +x ~/.dt/sessions/sessionetc


Line 67: Line 64:
== Creating an own program icon ==
== Creating an own program icon ==


Use Desktop_Apps/Create Action tool. Save actions under ~/.dt/appmanager
Icons should be in XPM or XBM format. Use the following configuration to convert from png icons
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
let
  cde-icons = pkgs.writeShellScriptBin "cde-icons" ''
    file=`basename ''${1%.*}`
 
    ${pkgs.imagemagick}/bin/convert $1 -resize 48x48 ~/.dt/icons/$file.l.pm
    ${pkgs.imagemagick}/bin/convert $1 -resize 32x32 ~/.dt/icons/$file.m.pm
    ${pkgs.imagemagick}/bin/convert $1 -resize 24x24 ~/.dt/icons/$file.s.pm
    ${pkgs.imagemagick}/bin/convert $1 -resize 16x16 ~/.dt/icons/$file.t.pm
  '';
in {
  services.xserver.desktopManager.cde.extraPackages = with pkgs;
    options.services.xserver.desktopManager.cde.extraPackages.default ++ [
      cde-icons
    ];
}
</nowiki>}}
For example


Icons should be in XPM or XBM format. Use the following script to convert from png icons
  cde-icons /run/current-system/sw/share/icons/hicolor/512x512/apps/qutebrowser.png
{{file|~/.dt/convert.sh|bash|<nowiki>
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p imagemagick


file=`basename ${1%.*}`
Then select it in Desktop_Apps/Create Action tool. Save actions under ~/.dt/appmanager


convert $1 -resize 48x48 ~/.dt/icons/$file.l.pm
== Setting icons on minimized programs ==
convert $1 -resize 32x32 ~/.dt/icons/$file.m.pm
Please note that not all programs support this
convert $1 -resize 24x24 ~/.dt/icons/$file.s.pm
{{file|~/.Xdefaults|bash|<nowiki>
convert $1 -resize 16x16 ~/.dt/icons/$file.t.pm
Dtwm*qutebrowser*iconImage:  qutebrowser
</nowiki>}}
</nowiki>}}
== Setting wallpaper ==


  chmod +x ~/.dt/convert.sh
Put .jpg or .png under ~/.dt/backdrops then select it in Style Manager / Backdrop


For example
== Gtk and Qt theme ==


   ~/.dt/convert.sh /run/current-system/sw/share/icons/hicolor/512x512/apps/qutebrowser.png
Add to your configuration
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
   services.xserver.desktopManager.cde.extraPackages = with pkgs;
    options.services.xserver.desktopManager.cde.extraPackages.default ++ [
      cde-gtk-theme
    ];
  environment.etc."xdg/gtk-2.0/gtkrc".text = ''
    gtk-theme-name="cdetheme"
  '';
  environment.etc."xdg/gtk-3.0/settings.ini".text = ''
    [Settings]
    gtk-theme-name=cdetheme
  '';
  qt5 = {
    enable = true;
    platformTheme = "gtk2";
    style = "gtk2";
  };
</nowiki>}}
Now copy the theme to home directory. Instead of Arizona.dp pick the palette you currently use in CDE for the match
  mkdir -p ~/.themes
  cp -Lr --no-preserve=mode /run/current-system/sw/share/themes/cdetheme ~/.themes/
  chmod +x ~/.themes/cdetheme/scripts/switchtheme
  cd ~/.themes/cdetheme/scripts/
  ./switchtheme ../palettes/Arizona.dp 8 3 22 false true false


== Setting icons on minimized programs ==
== Changing volume and brightness with media keys ==
 
Add the following to ~/.dt/dtwmrc
{{file|~/.Xdefaults|bash|<nowiki>
  Keys DtKeyBindings
Dtwm*chrome*iconImage:  chrome
  {
    <Key>XF86AudioLowerVolume  root|icon|window|ifkey  f.exec "amixer set Master -q 5%-"
    <Key>XF86AudioRaiseVolume  root|icon|window|ifkey  f.exec "amixer set Master -q 5%+"
    <Key>XF86AudioMute          root|icon|window|ifkey  f.exec "amixer set Master -q toggle"
    <Key>XF86MonBrightnessUp    root|icon|window|ifkey  f.exec "xbacklight -inc 1"
    <Key>XF86MonBrightnessDown  root|icon|window|ifkey  f.exec "xbacklight -dec 1"
  }
== Battery widget ==
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
let
  cde-battery = pkgs.writeScriptBin "cde-battery" ''
    #!${pkgs.cdesktopenv}/opt/dt/bin/dtksh
    ${pkgs.lib.readFile (pkgs.fetchurl {
      url = "https://raw.githubusercontent.com/edorig/dtksh/5f49e402b391c81ebea9609bdec9c7716e70a8c0/battery";
      sha256 = "0zjn9zl1as9xbk2845bbdy2xfj29b4hvvalcz8kf2llkndbfswvl";
    })}
  '';
in {
  services.xserver.desktopManager.cde.extraPackages = with pkgs;
    options.services.xserver.desktopManager.cde.extraPackages.default ++ [
      cde-battery
    ];
}
</nowiki>}}
Please read [[#Adding programs to autolaunch|Adding programs to autolaunch section]]
{{file|~/.dt/sessions/sessionetc|bash|<nowiki>
#!/bin/sh
cde-battery &
</nowiki>}}
Please read [[#Editing panel|Editing panel section]]
{{file|~/.dt/types/dtwm.fp||<nowiki>
CONTROL Battery
{
POSITION_HINTS  14
TYPE client
CONTAINER_NAME Top
CONTAINER_TYPE BOX
CLIENT_NAME cde-battery
CLIENT_GEOMETRY 97x58 
HELP_STRING "Battery indicator"
}
</nowiki>}}
</nowiki>}}
== Example configuration ==


== Own wallpapers ==
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{ pkgs, options, ... }


Put .jpg or .png under ~/.dt/backdrops then select it in Style Manager / Backdrop
let
  cde-icons = pkgs.writeShellScriptBin "cde-icons" ''
    file=`basename ''${1%.*}`


== Useful sources ==
    ${pkgs.imagemagick}/bin/convert $1 -resize 48x48 ~/.dt/icons/$file.l.pm
    ${pkgs.imagemagick}/bin/convert $1 -resize 32x32 ~/.dt/icons/$file.m.pm
    ${pkgs.imagemagick}/bin/convert $1 -resize 24x24 ~/.dt/icons/$file.s.pm
    ${pkgs.imagemagick}/bin/convert $1 -resize 16x16 ~/.dt/icons/$file.t.pm
  '';
  cde-battery = pkgs.writeScriptBin "cde-battery" ''
    #!${pkgs.cdesktopenv}/opt/dt/bin/dtksh
    ${pkgs.lib.readFile (pkgs.fetchurl {
      url = "https://raw.githubusercontent.com/edorig/dtksh/5f49e402b391c81ebea9609bdec9c7716e70a8c0/battery";
      sha256 = "0zjn9zl1as9xbk2845bbdy2xfj29b4hvvalcz8kf2llkndbfswvl";
    })}
  '';
in {
  # CDE has a limited number of locales
  i18n.defaultLocale = "en_US.UTF-8";
  # CDE has no keyboard layout configuration
  services.xserver.layout = "us,ru";
  services.xserver.xkbOptions = "grp:alt_shift_toggle,grp_led:caps";
  services.xserver.desktopManager.cde.enable = true;
  services.xserver.desktopManager.cde.extraPackages = with pkgs;
    options.services.xserver.desktopManager.cde.extraPackages.default ++ [
      fsv cde-icons cde-gtk-theme cde-battery
    ];
  environment.etc."xdg/gtk-2.0/gtkrc".text = ''
    gtk-theme-name="cdetheme"
  '';
  environment.etc."xdg/gtk-3.0/settings.ini".text = ''
    [Settings]
    gtk-theme-name=cdetheme
  '';
  qt5 = {
    enable = true;
    platformTheme = "gtk2";
    style = "gtk2";
  };
}


</nowiki>}}
== Useful links ==
* https://sourceforge.net/p/cdesktopenv/wiki/CustomisingCDE/
* https://sourceforge.net/p/cdesktopenv/wiki/CustomisingCDE/


[[Category:Configuration]]
[[Category:Cookbook]]
[[Category:Guide]]
[[Category:Desktop environment]]
[[Category:Tutorial]]
[[Category:Desktop]]

Latest revision as of 20:02, 19 April 2024

Warning: This article makes use of precarious stateful system manipulations (imperatively writing to /etc).

Aka cdesktopenv or Common Desktop Environment is a vintage desktop environment.


Changing fonts

 sudo mkdir -p /etc/dt/config/xfonts
 sudo cp -r ${pkgs.cdesktopenv}/opt/dt/config/xfonts/$LANG /etc/dt/config/xfonts
 sudo sed -i '/dt-interface/d' /etc/dt/config/xfonts/$LANG/fonts.alias

Now add the following to /etc/dt/config/xfonts/$LANG/fonts.alias file. In this example Helvetica and Courier are used instead of fixed fonts.

 "-dt-interface system-medium-r-normal-xxs sans-10-100-72-72-p-61-iso8859-1"  "-adobe-helvetica-medium-r-normal--10-*-75-75-p-56-iso8859-1"
 "-dt-interface system-medium-r-normal-xs sans-11-110-72-72-p-64-iso8859-1"   "-adobe-helvetica-medium-r-normal--11-80-100-100-p-56-iso8859-1"
 "-dt-interface system-medium-r-normal-s sans-12-120-72-72-p-73-iso8859-1"    "-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1"
 "-dt-interface system-medium-r-normal-m sans-13-130-72-72-p-87-iso8859-1"    "-adobe-helvetica-medium-r-normal--14-140-75-75-p-77-iso8859-1"
 "-dt-interface system-medium-r-normal-l sans-15-150-72-72-p-100-iso8859-1"   "-adobe-helvetica-medium-r-normal--14-140-75-75-p-77-iso8859-1"
 "-dt-interface system-medium-r-normal-xl sans-18-180-72-72-p-114-iso8859-1"  "-adobe-helvetica-medium-r-normal--18-180-75-75-p-98-iso8859-1"
 "-dt-interface system-medium-r-normal-xxl sans-21-210-72-72-p-123-iso8859-1" "-adobe-helvetica-medium-r-normal--20-140-100-100-p-100-iso8859-1"
 "-dt-interface user-medium-r-normal-xxs serif-10-100-72-72-m-60-iso8859-1"   "-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1"
 "-dt-interface user-medium-r-normal-xs serif-11-110-72-72-m-60-iso8859-1"    "-adobe-courier-medium-r-normal--11-80-100-100-m-60-iso8859-1"
 "-dt-interface user-medium-r-normal-s serif-12-120-72-72-m-80-iso8859-1"     "-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1"
 "-dt-interface user-medium-r-normal-m serif-13-130-72-72-m-90-iso8859-1"     "-adobe-courier-medium-r-normal--14-140-75-75-m-90-iso8859-1"
 "-dt-interface user-medium-r-normal-l serif-15-150-72-72-m-110-iso8859-1"    "-adobe-courier-medium-r-normal--14-140-75-75-m-90-iso8859-1"
 "-dt-interface user-medium-r-normal-xl serif-18-180-72-72-m-120-iso8859-1"   "-adobe-courier-medium-r-normal--18-180-75-75-m-110-iso8859-1"
 "-dt-interface user-medium-r-normal-xxl serif-21-210-72-72-m-140-iso8859-1"  "-adobe-courier-medium-r-normal-*-20-140-100-100-m-110-iso8859-1"
 "-dt-interface user-bold-r-normal-xxs serif-10-100-72-72-m-60-iso8859-1"     "-adobe-courier-bold-r-normal--10-100-75-75-m-60-iso8859-1"
 "-dt-interface user-bold-r-normal-xs serif-11-110-72-72-m-60-iso8859-1"      "-adobe-courier-bold-r-normal--11-80-100-100-m-60-iso8859-1"
 "-dt-interface user-bold-r-normal-s serif-12-120-72-72-m-80-iso8859-1"       "-adobe-courier-bold-r-normal--12-120-75-75-m-70-iso8859-1"
 "-dt-interface user-bold-r-normal-m serif-13-130-72-72-m-90-iso8859-1"       "-adobe-courier-bold-r-normal--14-140-75-75-m-90-iso8859-1"
 "-dt-interface user-bold-r-normal-l serif-15-150-72-72-m-110-iso8859-1"      "-adobe-courier-bold-r-normal--14-140-75-75-m-90-iso8859-1"
 "-dt-interface user-bold-r-normal-xl serif-18-180-72-72-m-120-iso8859-1"     "-adobe-courier-bold-r-normal--18-180-75-75-m-110-iso8859-1"
 "-dt-interface user-bold-r-normal-xxl serif-21-210-72-72-m-140-iso8859-1"    "-adobe-courier-bold-r-normal--20-140-100-100-m-110-iso8859-1"

Adding programs to autolaunch

~/.dt/sessions/sessionetc
#!/usr/bin/env nix-shell
#!nix-shell -i sh -p xcompmgr xosview2

xcompmgr -c &
xosview2 &
 chmod +x ~/.dt/sessions/sessionetc

Editing panel

 cp ${pkgs.cdesktopenv}/opt/dt/appconfig/types/C/dtwm.fp ~/.dt/types
 chmod +w ~/.dt/types/dtwm.fp

Now edit ~/.dt/types/dtwm.fp

To disable system control, add a delete property like this

 CONTROL Trash
{
 CONTAINER_NAME  Top
 CONTAINER_TYPE  BOX
 DELETE          True
}

Creating an own program icon

Icons should be in XPM or XBM format. Use the following configuration to convert from png icons

/etc/nixos/configuration.nix
let
  cde-icons = pkgs.writeShellScriptBin "cde-icons" ''
    file=`basename ''${1%.*}`

    ${pkgs.imagemagick}/bin/convert $1 -resize 48x48 ~/.dt/icons/$file.l.pm
    ${pkgs.imagemagick}/bin/convert $1 -resize 32x32 ~/.dt/icons/$file.m.pm
    ${pkgs.imagemagick}/bin/convert $1 -resize 24x24 ~/.dt/icons/$file.s.pm
    ${pkgs.imagemagick}/bin/convert $1 -resize 16x16 ~/.dt/icons/$file.t.pm
  '';
in {
  services.xserver.desktopManager.cde.extraPackages = with pkgs;
    options.services.xserver.desktopManager.cde.extraPackages.default ++ [
      cde-icons
    ];
}

For example

 cde-icons /run/current-system/sw/share/icons/hicolor/512x512/apps/qutebrowser.png

Then select it in Desktop_Apps/Create Action tool. Save actions under ~/.dt/appmanager

Setting icons on minimized programs

Please note that not all programs support this

~/.Xdefaults
Dtwm*qutebrowser*iconImage:   qutebrowser

Setting wallpaper

Put .jpg or .png under ~/.dt/backdrops then select it in Style Manager / Backdrop

Gtk and Qt theme

Add to your configuration

/etc/nixos/configuration.nix
  services.xserver.desktopManager.cde.extraPackages = with pkgs;
    options.services.xserver.desktopManager.cde.extraPackages.default ++ [
      cde-gtk-theme
    ];
  environment.etc."xdg/gtk-2.0/gtkrc".text = ''
    gtk-theme-name="cdetheme"
  '';
  environment.etc."xdg/gtk-3.0/settings.ini".text = ''
    [Settings]
    gtk-theme-name=cdetheme
  '';
  qt5 = {
    enable = true;
    platformTheme = "gtk2";
    style = "gtk2";
  };

Now copy the theme to home directory. Instead of Arizona.dp pick the palette you currently use in CDE for the match

 mkdir -p ~/.themes
 cp -Lr --no-preserve=mode /run/current-system/sw/share/themes/cdetheme ~/.themes/
 chmod +x ~/.themes/cdetheme/scripts/switchtheme
 cd ~/.themes/cdetheme/scripts/
 ./switchtheme ../palettes/Arizona.dp 8 3 22 false true false

Changing volume and brightness with media keys

Add the following to ~/.dt/dtwmrc

 Keys DtKeyBindings
 {
   <Key>XF86AudioLowerVolume   root|icon|window|ifkey  f.exec "amixer set Master -q 5%-"
   <Key>XF86AudioRaiseVolume   root|icon|window|ifkey  f.exec "amixer set Master -q 5%+"
   <Key>XF86AudioMute          root|icon|window|ifkey  f.exec "amixer set Master -q toggle"
   <Key>XF86MonBrightnessUp    root|icon|window|ifkey  f.exec "xbacklight -inc 1"
   <Key>XF86MonBrightnessDown  root|icon|window|ifkey  f.exec "xbacklight -dec 1"
 }

Battery widget

/etc/nixos/configuration.nix
let
  cde-battery = pkgs.writeScriptBin "cde-battery" ''
    #!${pkgs.cdesktopenv}/opt/dt/bin/dtksh
    ${pkgs.lib.readFile (pkgs.fetchurl {
      url = "https://raw.githubusercontent.com/edorig/dtksh/5f49e402b391c81ebea9609bdec9c7716e70a8c0/battery";
      sha256 = "0zjn9zl1as9xbk2845bbdy2xfj29b4hvvalcz8kf2llkndbfswvl";
    })}
  '';
in {
  services.xserver.desktopManager.cde.extraPackages = with pkgs;
    options.services.xserver.desktopManager.cde.extraPackages.default ++ [
      cde-battery
    ];
}

Please read Adding programs to autolaunch section

~/.dt/sessions/sessionetc
#!/bin/sh
cde-battery &

Please read Editing panel section

~/.dt/types/dtwm.fp
CONTROL Battery 
{
POSITION_HINTS  14
TYPE client
CONTAINER_NAME Top
CONTAINER_TYPE BOX
CLIENT_NAME cde-battery
CLIENT_GEOMETRY 97x58  
HELP_STRING "Battery indicator"
}

Example configuration

/etc/nixos/configuration.nix
{ pkgs, options, ... }

let
  cde-icons = pkgs.writeShellScriptBin "cde-icons" ''
    file=`basename ''${1%.*}`

    ${pkgs.imagemagick}/bin/convert $1 -resize 48x48 ~/.dt/icons/$file.l.pm
    ${pkgs.imagemagick}/bin/convert $1 -resize 32x32 ~/.dt/icons/$file.m.pm
    ${pkgs.imagemagick}/bin/convert $1 -resize 24x24 ~/.dt/icons/$file.s.pm
    ${pkgs.imagemagick}/bin/convert $1 -resize 16x16 ~/.dt/icons/$file.t.pm
  '';
  cde-battery = pkgs.writeScriptBin "cde-battery" ''
    #!${pkgs.cdesktopenv}/opt/dt/bin/dtksh
    ${pkgs.lib.readFile (pkgs.fetchurl {
      url = "https://raw.githubusercontent.com/edorig/dtksh/5f49e402b391c81ebea9609bdec9c7716e70a8c0/battery";
      sha256 = "0zjn9zl1as9xbk2845bbdy2xfj29b4hvvalcz8kf2llkndbfswvl";
    })}
  '';
in {
  # CDE has a limited number of locales
  i18n.defaultLocale = "en_US.UTF-8";
  # CDE has no keyboard layout configuration 
  services.xserver.layout = "us,ru";
  services.xserver.xkbOptions = "grp:alt_shift_toggle,grp_led:caps";
  services.xserver.desktopManager.cde.enable = true;
  services.xserver.desktopManager.cde.extraPackages = with pkgs;
    options.services.xserver.desktopManager.cde.extraPackages.default ++ [
      fsv cde-icons cde-gtk-theme cde-battery
    ];
  environment.etc."xdg/gtk-2.0/gtkrc".text = ''
    gtk-theme-name="cdetheme"
  '';
  environment.etc."xdg/gtk-3.0/settings.ini".text = ''
    [Settings]
    gtk-theme-name=cdetheme
  '';
  qt5 = {
    enable = true;
    platformTheme = "gtk2";
    style = "gtk2";
  };
}

Useful links