Tutorials/Using Other Window Managers with Plasma: Difference between revisions

    From KDE UserBase Wiki
    m (Added warning about failing to be able to start window manager.)
    (Marked this version for translation)
    (28 intermediate revisions by 9 users not shown)
    Line 1: Line 1:
    <languages />
    <languages />
    <translate>
    <translate>
    <!--T:1-->
    {{Construction}}


    ==Introduction== <!--T:2-->
    ==Introduction== <!--T:2-->
    Line 8: Line 6:
    <!--T:3-->
    <!--T:3-->
    KWin is the default window manager (WM) in Plasma and has lot of features, but it only supports floating windows. Plasma lets you use another window manager, such as i3, bspwm or [https://wiki.archlinux.org/index.php/Window_managers any other tilling window manager].
    KWin is the default window manager (WM) in Plasma and has lot of features, but it only supports floating windows. Plasma lets you use another window manager, such as i3, bspwm or [https://wiki.archlinux.org/index.php/Window_managers any other tilling window manager].
    <!--T:54-->
    [[File:Plasma_i3.png|500px|thumb|center|Plasma using i3 as window manager]]


    <!--T:4-->
    <!--T:4-->
    {{Warning|Other window managers are only available when using X.org. These changes cannot be made for Wayland sessions.}}
    {{Warning|Other window managers are only available when using X.org. These changes cannot be made for Wayland sessions yet. With Wayland maturing and Wayland extensions being standardized, this feature could be implemented in Wayland<ref>https://drewdevault.com/2018/04/28/KDE-Sprint-retrospective.html</ref> }}


    <!--T:5-->
    <!--T:5-->
    Line 22: Line 23:


    <!--T:8-->
    <!--T:8-->
    * Most window managers do not have their own compositors, and therefore lack features like animations and transparency. If such effects are desired, a compositor such as '''compton''' is required
    * Most window managers do not have their own compositors, and therefore lack features like animations and transparency. If such effects are desired, a compositor is required - refer to [https://wiki.archlinux.org/index.php/Xorg#Composite Arch Wiki] for options.</translate>
    <translate>
    <!--T:58-->
    ** Compositors can also help with screen tearing, however check first if you can resolve it with your video drivers, as this will be a more performant solution in most cases.


    ==Using Another Window Manager with Plasma == <!--T:9-->
    ==Using Another Window Manager with Plasma == <!--T:9-->
    Line 61: Line 65:
    <!--T:19-->
    <!--T:19-->
    * The chosen window manager will be used the next time you log in
    * The chosen window manager will be used the next time you log in
    <!--T:76-->
    {{Note|In recent versions of Plasma the '''Run On''' and '''Before Session Startup''' options may not be available. You can obtain the same behavior by manually copying or symlinking the shell script above in <code>$HOME/.config/plasma-workspace/env</code>. }}


    === System Wide: Adding an XSession=== <!--T:20-->
    === System Wide: Adding an XSession=== <!--T:20-->
    Line 69: Line 76:
    <!--T:22-->
    <!--T:22-->
    This has several advantages: the alternate session is available to all users of the system, and changing back to '''KWin''' is as simple as logging out and back in.
    This has several advantages: the alternate session is available to all users of the system, and changing back to '''KWin''' is as simple as logging out and back in.
    <!--T:42-->
    {{Note|The XSession file location varies between distributions, but is most of the time found in {{Path|/usr/share/xsessions}}. }}


    <!--T:23-->
    <!--T:23-->
    Line 79: Line 89:
    * Using a text editor, open the file and change the Exec line, and optionally the Description{{Input|1=<nowiki>[Desktop Entry]
    * Using a text editor, open the file and change the Exec line, and optionally the Description{{Input|1=<nowiki>[Desktop Entry]
    Type=XSession
    Type=XSession
    Exec=env KDEWM=/usr/bin/i3
    Exec=env KDEWM=/usr/bin/i3 /usr/bin/startplasma-x11
    DesktopNames=KDE
    DesktopNames=KDE
    Name=Plasma (i3)
    Name=Plasma (i3)
    Comment=Plasma by KDE w/i3
    Comment=Plasma by KDE w/i3
    X-KDE-PluginInfo-Version=5.14.4
    </nowiki>}}
    </nowiki>}}
    {{Warning|In versions prior to Plasma 5.17, use '''startkde''' in place of '''startplasma-x11''' in the Exec directive above.}}


    <!--T:26-->
    <!--T:26-->
    * The display manager must be restarted, most easily by rebooting
    * The display manager must be restarted, most easily by rebooting


    <!--T:41-->
    {{Warning|Ensure the correct path and name of the window manager application are used when modifying the Exec directive. If KDE is unable to start the window manager, the session will fail and the user will be returned to the login screen.}}
    {{Warning|Ensure the correct path and name of the window manager application are used when modifying the Exec directive. If KDE is unable to start the window manager, the session will fail and the user will be returned to the login screen.}}
    <!--T:73-->
    {{Warning|In some recent versions, SDDM checks for blank spaces in the <code>Exec</code> command. If blank spaces are found the Desktop Entry is not shown in the session menu.
    To workaround this, create a script named <code>plasma-i3.sh</code> containing the following:{{Input|1=<nowiki>
    #!/bin/sh
    export KDEWM=/usr/bin/i3
    /usr/bin/startplasma-x11
    </nowiki>}}
    Set execution permissions for the script and reference it in '''plasma-i3.desktop''', for example:{{Input|1=<nowiki>
    Exec=/usr/local/bin/plasma-i3.sh
    </nowiki>}}}}


    ==I3 configuration== <!--T:27-->
    ==I3 configuration== <!--T:27-->
    Line 96: Line 118:


    <!--T:29-->
    <!--T:29-->
    Before starting the configuration, you should make sure i3 or i3-gaps are installed on your system. If they are not, use your package manager or [[Special:myLanguage/Discover|Discover]] to install one of these two packages. You should also install a compositor such as "compton", since unlike KWin, i3 doesn't ship with an integrated compositor.
    Before starting the configuration, you should make sure i3 or i3-gaps are installed on your system. If they are not, use your package manager or [[Special:myLanguage/Discover|Discover]] to install one of these two packages.


    ===Create a default i3 configuration=== <!--T:30-->
    ===Configure i3=== <!--T:30-->


    <!--T:31-->
    <!--T:35-->
    {{Note|If you already have an i3 configuration file (usually at <code>.i3/config</code> or <code>.config/i3/config</code>), you can skip this step.}}
    When you first start i3, its default global configuration (at <code>/etc/i3/config</code>) will start i3-config-wizard, which will provide a dialog for Mod key selection and generate the user local configuration at <code>~/.i3/config</code>.


    <!--T:32-->
    <!--T:59-->
    [[Special:myLanguage/Tutorials/Open a console|Open a console]] and type <code>i3-config-wizard</code>. This command opens a small window that will help you create a configuration file.  
    If you wish to maintain the same configuration across users (they can still override it with their own local config), remove the wizard invocation from the global configuration file and use it directly.


    <!--T:33-->
    [[File:i3-wizard.png|500px]]


    <!--T:34-->
    <!--T:60-->
    Some i3 keybindings can be used to provide better integration with Plasma.
    The following i3 window rules will help you with notifications and some other plasma windows:
    {{Input|1=<nowiki># Open logout confirmation screen with $mod+e
    bindsym $mod+Shift+e exec qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1
    # Open krunner with $mod+d
    bindsym $mod+d exec qdbus org.kde.kglobalaccel /component/krunner org.kde.kglobalaccel.Component.invokeShortcut 'run command'
    </nowiki>}}
     
    <!--T:35-->
    Some i3 window rules help you to have notifications and some other plasma windows as floating windows:
    {{Input|1=<nowiki>for_window [title="Desktop — Plasma"] kill; floating enable; border none
    {{Input|1=<nowiki>for_window [title="Desktop — Plasma"] kill; floating enable; border none
    for_window [class="plasmashell"] floating enable;
    for_window [class="plasmashell"] floating enable;
    Line 129: Line 141:
    for_window [class="Plasmoidviewer"] floating enable; border none
    for_window [class="Plasmoidviewer"] floating enable; border none
    for_window [class="(?i)*nextcloud*"] floating disable
    for_window [class="(?i)*nextcloud*"] floating disable
    for_window [class="plasmashell" window_type="notification"] floating enable, border none, move right 700px, move down 450px
    no_focus [class="plasmashell" window_type="notification"]
    </nowiki>}}
    <!--T:55-->
    If you are using a non-English installation of Plasma, you need to find out what the exact window title of the Desktop is. One way is to do this is with <code>wmctrl -l</code>.
    <!--T:56-->
    Instead of adding
    {{Input|1=<nowiki>for_window [title="Desktop — Plasma"] kill; floating enable; border none
    </nowiki>}}
    </nowiki>}}


    ==bspwm== <!--T:36-->
    <!--T:57-->
    add the name of the window to the i3 config. This example uses the German Plasma installation.
    {{Input|1=<nowiki>for_window [title="Arbeitsfläche — Plasma"] kill; floating enable; border none
    </nowiki>}}
     
    <!--T:74-->
    Notification positioning can be tricky, since not all notifications have the same size depending on their content. You can also use coordinates positioning, knowing your screen resolution. For example, for a 1920x1080 screen and notifications in the top-right corner we can use:{{Input|1=<nowiki>
    for_window [class="plasmashell" window_type="notification"] floating enable, border none, move position 1450px 20px
    </nowiki>}}
     
    ===Configure Plasma=== <!--T:61-->
     
    <!--T:62-->
    You may get into issues related with the "Activities" feature - activating it via keyboard shortcuts (some of which are also used by i3, like "Meta + Q") seems to make i3 unresponsive. Removing Activity related global shortcuts seems to resolve this.
     
    <!--T:63-->
    To get the Plasma provided pager display desktops as i3bar, set '''Pager Settings''' > '''General''' > '''Text display''' to "Desktop name"
     
     
    ==Bspwm configuration== <!--T:36-->


    <!--T:37-->
    <!--T:37-->
    Line 138: Line 179:
    <!--T:38-->
    <!--T:38-->
    * A single Plasma panel, in most cases, is detected properly and bspwm will not place windows in its space. If the panel ends up presenting a problem, or when using multiple panels, the following may be added to '''.bspwmrc'''{{Input|1=<nowiki>bspc config top_padding size</nowiki>}}where '''size''' is the size of the panel in pixels. Also valid are bottom_padding, left_padding, and right_padding. As many of these directives may be used as necessary for multiple panels.
    * A single Plasma panel, in most cases, is detected properly and bspwm will not place windows in its space. If the panel ends up presenting a problem, or when using multiple panels, the following may be added to '''.bspwmrc'''{{Input|1=<nowiki>bspc config top_padding size</nowiki>}}where '''size''' is the size of the panel in pixels. Also valid are bottom_padding, left_padding, and right_padding. As many of these directives may be used as necessary for multiple panels.
    ==Hints and Tips== <!--T:43-->
    ===DBus=== <!--T:64-->
    <!--T:45-->
    Since Meta key handling is in part performed by KWin, you will have to handle these shortcuts manually when you switch to a different window manager.
    <!--T:65-->
    You can open some Plasma components with DBus commands. You can use this to map corresponding keybindings to DBus commands. To find a specific DBus command, you can look at <code>dbus-monitor</code> or <code>qdbusviewer</code> while you invoke the component in a standard Plasma set-up.
    <!--T:66-->
    More info on meta key handling:
    <!--T:67-->
    * [https://www.reddit.com/r/kde/comments/6wn5lk/bind_meta_key_alone_to_do_something/ Reddit post describing the ''Meta key - KWin'' relation]
    <!--T:68-->
    * [https://zren.github.io/2019/03/04/activate-any-widget-with-meta-key Blog post describing the ''DBus - Component'' relation]
    <!--T:46-->
    Some examples:
    <!--T:47-->
    * Open Application Launcher {{Input|1=<nowiki>qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.activateLauncherMenu</nowiki>}}
    <!--T:69-->
    * Open Krunner {{Input|1=<nowiki>qdbus org.kde.kglobalaccel /component/krunner org.kde.kglobalaccel.Component.invokeShortcut 'run command'</nowiki>}}
    <!--T:70-->
    * Open logout confirmation screen {{Input|1=<nowiki>qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1</nowiki>}}
    <!--T:48-->
    For i3, you can map a keybinding with the '''bindsym''' command. Use <code>--no-startup-id</code> to prevent the command from generating "i3" entries in the task manager.
    <!--T:49-->
    Example:
    {{Input|1=<nowiki>bindsym $mod+Shift+e exec --no-startup-id <command></nowiki>}}
    <!--T:71-->
    If you want to map the modifier key itself, use the '''bindcode''' command - you have to specify the keycode generated by the key, which you can get via the <code>xev</code> utility.
    <!--T:72-->
    Example for the Meta key:
    {{Input|1=<nowiki>bindcode 133 --release exec --no-startup-id <command></nowiki>}}
    <!--T:50-->
    For Bspwn, you need to use the <code>bspc</code> program. See [https://wiki.archlinux.org/index.php/Bspwm#Keyboard Arch Linux wiki] for more information.
    ==More Information== <!--T:51-->
    <!--T:52-->
    * [https://en.wikipedia.org/wiki/X_window_manager Window managers] (Wikipedia)
    * [https://wiki.archlinux.org/index.php/Window_managers Window managers] (Arch Linux wiki)
    * [https://en.wikipedia.org/wiki/Desktop_environment Desktop environment] (Wikipedia)
    * [https://wiki.archlinux.org/index.php/Desktop_environment Desktop environment] (Arch Linux wiki)
    ==References== <!--T:53-->


    <!--T:39-->
    <!--T:39-->

    Revision as of 08:14, 18 January 2021

    Introduction

    KWin is the default window manager (WM) in Plasma and has lot of features, but it only supports floating windows. Plasma lets you use another window manager, such as i3, bspwm or any other tilling window manager.

    Plasma using i3 as window manager

    Warning

    Other window managers are only available when using X.org. These changes cannot be made for Wayland sessions yet. With Wayland maturing and Wayland extensions being standardized, this feature could be implemented in Wayland[1]


    Most window managers require few, if any, changes to their configuration files.

    Some considerations to be aware of when using another window manager:

    • Tiling window managers may have problems with components like panels. For some configurations, certain options will help alleviate issues
    • Most window managers do not have their own compositors, and therefore lack features like animations and transparency. If such effects are desired, a compositor is required - refer to Arch Wiki for options.
      • Compositors can also help with screen tearing, however check first if you can resolve it with your video drivers, as this will be a more performant solution in most cases.

    Using Another Window Manager with Plasma

    Single User: Using System Settings

    This is the simplest method, but only affects the user for which it is added.

    • Create a shell script (kde-i3.sh as an example), containing the following
      #!/bin/sh
      export KDEWM=/usr/bin/i3
      

    Replace /usr/bin/i3 with the path to the window manager desired.

    • Start System Settings
    • Select Startup and Shutdown
    • Select Autostart
    • Click the Add script button below the list
    • Enter the location of the script created earlier, or use the folder icon to use a dialog to find it. Click OK, the script will be added to the list
    • In the Run On column, select Before Session Startup from the drop down list
    • The chosen window manager will be used the next time you log in

    Note

    In recent versions of Plasma the Run On and Before Session Startup options may not be available. You can obtain the same behavior by manually copying or symlinking the shell script above in $HOME/.config/plasma-workspace/env.


    System Wide: Adding an XSession

    If superuser (root) access is available, a new session file for X.org can be created.

    This has several advantages: the alternate session is available to all users of the system, and changing back to KWin is as simple as logging out and back in.

    Note

    The XSession file location varies between distributions, but is most of the time found in /usr/share/xsessions.


    To add a session for an alternate window manager as superuser:

    • Copy the existing Plasma session file
      cp plasma.desktop plasma-i3.desktop
    • Using a text editor, open the file and change the Exec line, and optionally the Description
      [Desktop Entry]
      Type=XSession
      Exec=env KDEWM=/usr/bin/i3 /usr/bin/startplasma-x11
      DesktopNames=KDE
      Name=Plasma (i3)
      Comment=Plasma by KDE w/i3
      

    Warning

    In versions prior to Plasma 5.17, use startkde in place of startplasma-x11 in the Exec directive above.


    • The display manager must be restarted, most easily by rebooting

    Warning

    Ensure the correct path and name of the window manager application are used when modifying the Exec directive. If KDE is unable to start the window manager, the session will fail and the user will be returned to the login screen.


    Warning

    In some recent versions, SDDM checks for blank spaces in the Exec command. If blank spaces are found the Desktop Entry is not shown in the session menu. To workaround this, create a script named plasma-i3.sh containing the following:
    #!/bin/sh
    export KDEWM=/usr/bin/i3
    /usr/bin/startplasma-x11
    
    Set execution permissions for the script and reference it in plasma-i3.desktop, for example:
    Exec=/usr/local/bin/plasma-i3.sh
    


    I3 configuration

    Installation

    Before starting the configuration, you should make sure i3 or i3-gaps are installed on your system. If they are not, use your package manager or Discover to install one of these two packages.

    Configure i3

    When you first start i3, its default global configuration (at /etc/i3/config) will start i3-config-wizard, which will provide a dialog for Mod key selection and generate the user local configuration at ~/.i3/config.

    If you wish to maintain the same configuration across users (they can still override it with their own local config), remove the wizard invocation from the global configuration file and use it directly.


    The following i3 window rules will help you with notifications and some other plasma windows:

    for_window [title="Desktop — Plasma"] kill; floating enable; border none
    for_window [class="plasmashell"] floating enable;
    for_window [class="Plasma"] floating enable; border none
    for_window [title="plasma-desktop"] floating enable; border none
    for_window [title="win7"] floating enable; border none
    for_window [class="krunner"] floating enable; border none
    for_window [class="Kmix"] floating enable; border none
    for_window [class="Klipper"] floating enable; border none
    for_window [class="Plasmoidviewer"] floating enable; border none
    for_window [class="(?i)*nextcloud*"] floating disable
    for_window [class="plasmashell" window_type="notification"] floating enable, border none, move right 700px, move down 450px
    no_focus [class="plasmashell" window_type="notification"] 
    

    If you are using a non-English installation of Plasma, you need to find out what the exact window title of the Desktop is. One way is to do this is with wmctrl -l.

    Instead of adding

    for_window [title="Desktop — Plasma"] kill; floating enable; border none
    

    add the name of the window to the i3 config. This example uses the German Plasma installation.

    for_window [title="Arbeitsfläche — Plasma"] kill; floating enable; border none
    

    Notification positioning can be tricky, since not all notifications have the same size depending on their content. You can also use coordinates positioning, knowing your screen resolution. For example, for a 1920x1080 screen and notifications in the top-right corner we can use:

    for_window [class="plasmashell" window_type="notification"] floating enable, border none, move position 1450px 20px
    

    Configure Plasma

    You may get into issues related with the "Activities" feature - activating it via keyboard shortcuts (some of which are also used by i3, like "Meta + Q") seems to make i3 unresponsive. Removing Activity related global shortcuts seems to resolve this.

    To get the Plasma provided pager display desktops as i3bar, set Pager Settings > General > Text display to "Desktop name"


    Bspwm configuration

    For the most part, bspwm requires little additional configuration.

    • A single Plasma panel, in most cases, is detected properly and bspwm will not place windows in its space. If the panel ends up presenting a problem, or when using multiple panels, the following may be added to .bspwmrc
      bspc config top_padding size
      where size is the size of the panel in pixels. Also valid are bottom_padding, left_padding, and right_padding. As many of these directives may be used as necessary for multiple panels.

    Hints and Tips

    DBus

    Since Meta key handling is in part performed by KWin, you will have to handle these shortcuts manually when you switch to a different window manager.

    You can open some Plasma components with DBus commands. You can use this to map corresponding keybindings to DBus commands. To find a specific DBus command, you can look at dbus-monitor or qdbusviewer while you invoke the component in a standard Plasma set-up.

    More info on meta key handling:


    Some examples:

    • Open Application Launcher
      qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.activateLauncherMenu
    • Open Krunner
      qdbus org.kde.kglobalaccel /component/krunner org.kde.kglobalaccel.Component.invokeShortcut 'run command'
    • Open logout confirmation screen
      qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1

    For i3, you can map a keybinding with the bindsym command. Use --no-startup-id to prevent the command from generating "i3" entries in the task manager.

    Example:

    bindsym $mod+Shift+e exec --no-startup-id <command>

    If you want to map the modifier key itself, use the bindcode command - you have to specify the keycode generated by the key, which you can get via the xev utility.

    Example for the Meta key:

    bindcode 133 --release exec --no-startup-id <command>

    For Bspwn, you need to use the bspc program. See Arch Linux wiki for more information.

    More Information

    References