Ubuntu 16.04访客会话默认用Gnome Metacity的配置文件位置查询
Hey there! I’ve helped with similar configuration tweaks on Ubuntu 16.04 before, so let’s walk through how to make Metacity the default window manager for guest sessions:
Key Configuration File Locations
First, let’s cover the critical files you’ll need to modify—these are tied to LightDM (Ubuntu 16.04’s default display manager) and X session startup:
LightDM Guest Session Wrapper:
/usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.conf
This file controls how the guest session is initialized. We’ll add an environment variable here to override the default window manager.X Session Startup Scripts Directory:
/etc/X11/Xsession.d/
Scripts in this folder run automatically when any X session starts (including guest sessions). We can create a custom script here to force Metacity to launch.
Method 1: Modify the LightDM Guest Configuration
This is the most straightforward approach:
Open the guest wrapper config file with sudo privileges:
sudo nano /usr/share/lightdm/lightdm.conf.d/50-guest-wrapper.confAdd the following line to the file (it sets the window manager environment variable):
env/WM=metacitySave your changes (press
Ctrl+O, hit Enter, thenCtrl+Xto exit nano).
Method 2: Create a Custom X Session Script
If Method 1 doesn’t work for your setup, use this fallback approach:
Create a new script file in the Xsession directory (we’ll name it
99-guest-metacityto ensure it runs last):sudo nano /etc/X11/Xsession.d/99-guest-metacityPaste the following content into the script—it checks if the user is the guest and forces Metacity to start:
# Force Metacity as window manager for guest sessions if [ "$USER" = "guest" ]; then export WM=metacity exec metacity & fiMake the script executable:
sudo chmod +x /etc/X11/Xsession.d/99-guest-metacity
Apply and Test the Changes
Restart LightDM to activate your new configuration:
sudo service lightdm restart
Now, when a guest user logs in, Metacity should replace the default Ubuntu window manager (Unity’s Compiz) as the active window manager.
Quick troubleshooting tip: If you run into issues, check the LightDM logs at
/var/log/lightdm/for errors related to guest session initialization or window manager startup.
内容的提问来源于stack exchange,提问作者Philippe Gaucher

