How to find out it is Wayland or X system? #3560
Replies: 5 comments 5 replies
-
This is not really a chezmoi question, as this is well-answered on Stack Overflow. However, there are some complicating factors to how you would run such a complex command-line from within a chezmoi template. NOTE: I don't use Linux as my daily driver, so I don't know whether the commands here will actually work, as I have nothing to test them on. Here's the command-line we should use from the SO post in question: loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type First, you will need to use the
This will probably work, but the levels of quoting required are particularly difficult to read, so the following (more complex) template should also work:
There are other ways to break this down using Your other option is to make a shell script that runs |
Beta Was this translation helpful? Give feedback.
-
Hey, I finally found sometime to mess with this config. I put it in a script and it work when I use Thanks |
Beta Was this translation helpful? Give feedback.
-
Hey, and thanks for your help again I don't think the path is the issue. I have tried
It is the template I tested on it:
|
Beta Was this translation helpful? Give feedback.
-
Excellent, you were right. The issue was finding path and now it is works like a charm. Thank you very much for your help |
Beta Was this translation helpful? Give feedback.
-
Another way is to check for the existence of In {{- $xdg_session_type := "" -}}
{{- if hasKey . "xdg_session_type" -}}
{{- $xdg_session_type = .xdg_session_type -}}
{{- else if (env "XDG_SESSION_TYPE") -}}
{{- $xdg_session_type = env "XDG_SESSION_TYPE" -}}
{{- end -}}
# ... other stuff ...
data:
xdg_session_type: "{{ $xdg_session_type }}" Then, in a template: {{ if (eq .chezmoi.os "linux") | and ((lookPath "wayland-scanner") | or (eq .xdg_session_type "wayland")) -}}
# ... wayland specific stuff ...
{{ else -}}
# ... other non-Wayland stuff ...
{{ end -}} Note that only For passively installing configs on a system that might run Wayland sessions, using the above check is usually fine in practice. For things that depend on the current session being Wayland actively, (warning: non-hermetic / tied to current session at runtime) the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to get which one is running on the system?
Beta Was this translation helpful? Give feedback.
All reactions