更新(2015 年 11 月 16 日)

更新(2015 年 11 月 16 日)

升級到14.10後,gnome-settings-daemon無法正確載入/usr/share/gnome-session/sessions/xmonad.session。有人有同樣的問題嗎?

答案1

這是基於Jianingy答案的更詳細的解決方案。它修復了我升級到 Ubuntu 14.10 後遇到的一些問題。它正在解決的問題包括:

  • 多媒體鍵不起作用
  • Gnome 控制中心中的顯示設定不起作用

您需要添加DesktopName=Unity/usr/share/gnome-session/sessions/xmonad.session.

[GNOME Session]
Name=Xmonad/GNOME
RequiredComponents=gnome-settings-daemon;gnome-panel;xmonad
DesktopName=Unity

另外,關於dbus-sendUbuntu 14.10 中的更改,您必須使用--print-reply=literal而不是--print-reply=string.我已將其新增至我的xmonad.hs並將 main 定義為main = xmonad $ gnomeConfig2

import XMonad.Config.Desktop
import XMonad.Util.Run (safeSpawn)

import qualified Data.Map as M

import System.Environment (getEnvironment)

data RescreenToggleState = RescreenToggleState Bool deriving Typeable
instance ExtensionClass RescreenToggleState where
  initialValue = RescreenToggleState True

gnomeConfig2 = desktopConfig
    { terminal = "gnome-terminal"
    , keys     = gnomeKeys <+> keys desktopConfig
    , startupHook = gnomeRegister2 >> startupHook desktopConfig }

gnomeKeys (XConfig {modMask = modm}) = M.fromList $
    [ ((modm, xK_p), gnomeRun)
    , ((modm .|. shiftMask, xK_q), spawn "gnome-session-save --kill") ]

-- | Register xmonad with gnome. 'dbus-send' must be in the $PATH with which
-- xmonad is started.
--
-- This action reduces a delay on startup only only if you have configured
-- gnome-session>=2.26: to start xmonad with a command as such:
--
-- > gconftool-2 -s /desktop/gnome/session/required_components/windowmanager xmonad --type string
gnomeRegister2 :: MonadIO m => m ()
gnomeRegister2 = io $ do
    x <- lookup "DESKTOP_AUTOSTART_ID" `fmap` getEnvironment
    whenJust x $ \sessionId -> safeSpawn "dbus-send"
            ["--session"
            ,"--print-reply=literal"
            ,"--dest=org.gnome.SessionManager"
            ,"/org/gnome/SessionManager"
            ,"org.gnome.SessionManager.RegisterClient"
            ,"string:xmonad"
            ,"string:"++sessionId]

答案2

好的,我找到了解決方案。

首先,從14.10開始。許多 unity 和 gnome 應用程式配置( /usr/share/applications 和 /etc/xdg/autostart 中的 *.desktop )開始包含「OnlyShowIn=Unity」。因此,我們必須在 /usr/share/gnome-session/sessions/xmonad.session 中加入 Desktopname=unity 才能讓這些應用程式運作。

其次,cmd 'dbus-send --print-reply=string' 現在必須是 'dbus-send --print-reply=literal'。因此,舊的 xmonad gnomeConfig 無法將 xmonad 註冊為 wm。我們必須將 dbus-send 指令從 =string 改為 =literal。

答案3

語法--print-reply=string會導致錯誤。需要“註冊”的應用程式名稱不是xmonad,而是xmonad.desktop。我最終創建了一個~/.xmonad/hooks文件,其中包含以下命令:

dbus-send --session --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.RegisterClient string:xmonad.desktop string:$DESKTOP_AUTO_START_ID

我還發現了先前的修復,設定DesktopName=Unity導致gnome-control-center可以正確使用。

答案4

這是解決“xmonad 無法註冊”問題的一種非常簡單的方法(通過使用 xmonad 掛鉤或寫入在其他答案中解決gnomeRegister2):在xmonad.desktop文件中,替換Exec=xmonadExec=sh -c "xmonad &".這會導致啟動速度非常快——我明白了這裡——但它可能會破壞其他東西。

DesktopName=Unity部分還是不可或缺的。

更新(2015 年 11 月 16 日)

當我升級 Ubuntu 時,我經常與 XMonad + Gnome 發生衝突。我的設定檔是可以在 GitHub 上找到,以防有人想了解我最近如何讓 XMonad 和 Gnome 很好地協同工作。

截至2015年11月16日,重要文件如下:

對於 Ubuntu 15.04 和 15.10,最重要且最難發現的更改是添加export XDG_CURRENT_DESKTOP=Unity到我的~/.xsession

# Without setting this explicitly, it gets te value "Gnome", which
# makes `unity-settings-daemon` fail to start and we get
# `gnome-settings-daemon` instead. Not sure what this variable does,
# but I got the hint here:
# https://bugzilla.gnome.org/show_bug.cgi?id=729575.
#
# Setting to values other than "Unity" -- e.g. "default", which `env`
# tells me is the value of related variables, or "GNOME-Flashback",
# which is the `DesktopName` I might suspect here -- I get weird
# behavior, e.g. none of the dock items appear in the Gnome panel.
export XDG_CURRENT_DESKTOP=Unity

此外,為了獲得有關音量鍵按下和螢幕亮度調整等的圖形通知,我需要安裝該notify-osd軟體包。

相關內容