From 68691811df208b7fd082a679e559deb8cdbdcba1 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Thu, 14 Nov 2024 16:47:53 -0600 Subject: [PATCH] fixing cosmic not working in emacs for iced apps --- README.org | 10 +++++++--- init.el | 7 ++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.org b/README.org index 504ef8e6..6800d58c 100644 --- a/README.org +++ b/README.org @@ -417,6 +417,9 @@ Let's make xref use ripgrep instead of grep for speed. #+end_src ** Fix NixOS +:PROPERTIES: +:ID: 20241114T164653.192420 +:END: I am currently using NixOS. In order for emacs to have access to certain programs, we need to set some environment variables #+begin_src emacs-lisp (add-to-list 'exec-path "/usr/bin") @@ -428,7 +431,6 @@ I am currently using NixOS. In order for emacs to have access to certain program (setenv "CLUTTER_BACKEND" "wayland") (setenv "GDK_BACKEND" "wayland,x11") (setenv "SDL_VIDEODRIVER" "wayland") -(setenv "WAYLAND_DISPLAY" "wayland-1") (setenv "XDG_SESSION_TYPE" "wayland") (defun chris/nix-reload () @@ -442,9 +444,11 @@ I am currently using NixOS. In order for emacs to have access to certain program Also due to using greetd, emacs isn't started with the environment from the system, so let's make sure it knows which wayland display we are using #+begin_src emacs-lisp -(setenv "WAYLAND_DISPLAY" (if (string= (getenv "XDG_CURRENT_DESKTOP") "Hyprland") +(let ((desktop (getenv "XDG_CURRENT_DESKTOP"))) + (setenv "WAYLAND_DISPLAY" (if (or (string= desktop "COSMIC") + (string= desktop "Hyprland")) "wayland-1" - "wayland-0")) + "wayland-0"))) #+end_src #+RESULTS: diff --git a/init.el b/init.el index f77d5ba6..f42c5f7f 100644 --- a/init.el +++ b/init.el @@ -214,7 +214,6 @@ (setenv "CLUTTER_BACKEND" "wayland") (setenv "GDK_BACKEND" "wayland,x11") (setenv "SDL_VIDEODRIVER" "wayland") -(setenv "WAYLAND_DISPLAY" "wayland-1") (setenv "XDG_SESSION_TYPE" "wayland") (defun chris/nix-reload () @@ -225,9 +224,11 @@ (when (boundp 'native-comp-eln-load-path) (add-to-list 'native-comp-eln-load-path (expand-file-name "native-lisp/" store-path))))) -(setenv "WAYLAND_DISPLAY" (if (string= (getenv "XDG_CURRENT_DESKTOP") "Hyprland") +(let ((desktop (getenv "XDG_CURRENT_DESKTOP"))) + (setenv "WAYLAND_DISPLAY" (if (or (string= desktop "COSMIC") + (string= desktop "Hyprland")) "wayland-1" - "wayland-0")) + "wayland-0"))) (executable-find "ssh") (setq ispell-program-name "hunspell"