From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 4KY/B5fVUmC0FAAA0tVLHw (envelope-from ) for ; Thu, 18 Mar 2021 04:22:47 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id uEb5ApfVUmDHdgAAB5/wlQ (envelope-from ) for ; Thu, 18 Mar 2021 04:22:47 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2F9162FCD4 for ; Thu, 18 Mar 2021 05:22:46 +0100 (CET) Received: from localhost ([::1]:46824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMkBI-0005Aw-3q for larch@yhetil.org; Thu, 18 Mar 2021 00:22:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMkB0-0005An-OO for help-guix@gnu.org; Thu, 18 Mar 2021 00:22:26 -0400 Received: from mx1.dismail.de ([78.46.223.134]:19559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMkAw-0006wU-Di for help-guix@gnu.org; Thu, 18 Mar 2021 00:22:26 -0400 Received: from mx1.dismail.de (localhost [127.0.0.1]) by mx1.dismail.de (OpenSMTPD) with ESMTP id b47caa50; Thu, 18 Mar 2021 05:22:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=dismail.de; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=20190914; bh=CH0O6ES2 2AHi3mSeEaoDWOA6jz7LL5ByC9LCBKZa43A=; b=uqUQxThauHt4wtfEviDoaAnO TlFKT9P+TAZI2iSD2eanZoewWcYM48LEfWXfJRZr1CJDnb7OExBacRYVCpq2FmkW TwX5bYWronG8tCZCNdlh2hwpo4uJk2uIUBlqwuOliTxELnpxj6OpTrsF+lyI300C ze2QSK+baq2j7Y0TTDUZ6PIz8G8yTrzyVcGNlP4ynn08+bcYJgkJYOv7LLUSo1RW QI2OwV/U+Ugli0ys0c/MXs3YoEG7H2YCeRgxr28qdE0ZhpIQOKrn9t8sM8K5VYIY lyZeVWpVG4j2BXUlDcQcQPwtexeq95iFwAPeix53cXXs+bfhkpvc2Fj7Q0W9Zg== Received: from smtp2.dismail.de ( [10.240.26.12]) by mx1.dismail.de (OpenSMTPD) with ESMTP id ee84dda9; Thu, 18 Mar 2021 05:22:16 +0100 (CET) Received: from smtp2.dismail.de (localhost [127.0.0.1]) by smtp2.dismail.de (OpenSMTPD) with ESMTP id 0b5ffac6; Thu, 18 Mar 2021 05:22:16 +0100 (CET) Received: by dismail.de (OpenSMTPD) with ESMTPSA id 75340538 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Thu, 18 Mar 2021 05:22:13 +0100 (CET) From: Joshua Branson To: =?utf-8?Q?S=C3=A9bastien?= Lerique Cc: help-guix@gnu.org Subject: Re: DBus with SDDM, Sway, and optionally fish References: <87o8fhcfcf.fsf@eauchat.org> Mail-Followup-To: =?utf-8?Q?S=C3=A9bastien?= Lerique , help-guix@gnu.org Date: Thu, 18 Mar 2021 00:21:54 -0400 In-Reply-To: <87o8fhcfcf.fsf@eauchat.org> (=?utf-8?Q?=22S=C3=A9bastien?= Lerique"'s message of "Thu, 18 Mar 2021 12:26:08 +0900") Message-ID: <874kh9gkgt.fsf@dismail.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=78.46.223.134; envelope-from=jbranso@dismail.de; helo=mx1.dismail.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: "Help-Guix" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1616041366; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=RDCWA5u7eHBjI7KVk9Sr6uxFAbJ8Dzri4GHNZlSfpQ8=; b=eRRvqJb5XmVcm3Bjr8PQTBc9nTsaTYsJwIwrUOZFxGvGj8v6DUmrp9+zEw1dCA4EiGW5f9 3Y1fqlkp2vx43UiQ+C6IHZsvZW0fhornE7yV+UtwIZjxrHpHmN5qMudtyDTmJ010sYIrR5 Di9OogZChWshK/NrYFu9mJ7Jw4UgvtmKtgPa5mPocDHemPw8Yq+CvIumpvLCbUlh8gstwX BoqT4Nv12ElASiFardSBuA83A7lwI/TdrFfiykT4Gh5HoeH1vVyQ/Wk/5xGrNEWxyCAXsX XJQQr5kqdvUeovgtZjP/BGdfepwsWggv0VG1u1Z/U7TaUX9pBblDeP5ul+X67A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1616041366; a=rsa-sha256; cv=none; b=ivpRLiQtxzBw7cy1mx60VCWRvm9ksH9hqSjR8bop53dAOvqgAjiNTaX0vdpN/HIYVOt/bi xZu8f2p7KM6i++TmRhhlVpEmBjkHcBREgoTGZeKS+68CzNOjU9XfXnnStOW+qDOfjpGmnG ZO58KTjunzn5Kw22H8yoj13wSTeD1MyLRka8mohbS8KqV+MxLSIyTXscOw5UVzR0zVBLJM XBhx2tzuL6ggN5YTOvxSXK/eQE5D1eLMk5VHSLqKqgKPmElaSa08jlR221X/5SmCcCrVpZ Ufl5JCXg05XialOuiSQ5KlrPn5m9TeCc5HDbpq7x13zFMRowe/gPD6/mvCpX3Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=dismail.de header.s=20190914 header.b=uqUQxTha; dmarc=pass (policy=reject) header.from=dismail.de; spf=pass (aspmx1.migadu.com: domain of help-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=help-guix-bounces@gnu.org X-Migadu-Spam-Score: -2.10 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=dismail.de header.s=20190914 header.b=uqUQxTha; dmarc=pass (policy=reject) header.from=dismail.de; spf=pass (aspmx1.migadu.com: domain of help-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=help-guix-bounces@gnu.org X-Migadu-Queue-Id: 2F9162FCD4 X-Spam-Score: -2.10 X-Migadu-Scanner: scn0.migadu.com X-TUID: W5yer2fI6jdG S=C3=A9bastien Lerique writes: > Dear all, > > I use SDDM with (display-server "wayland"), and Sway as my main window > manager. yeah I do too! > > My current configuration files are here: > - system configuration: > https://gitlab.com/wehlutyk/guix-config/-/blob/master/config.scm > - main profile: > https://gitlab.com/wehlutyk/guix-config/-/blob/master/sl-manifest.scm > - dot files: https://gitlab.com/wehlutyk/dotfiles > > I've been struggling to get the DBUS_SESSION_BUS_ADDRESS variable to > be set by SDDM, as it does not seem to set it by default. The current > script that SDDM runs before starting Sway is > https://github.com/sddm/sddm/blob/master/data/scripts/wayland-session > , and I haven't found any other setup step which might be a source for > enviroment variables inside Sway. > > (Somehow environment variables set in `.config/environment.d/*.conf` > also get set, but I don't know how or where that happens.) > > In the default configuration, DBUS_SESSION_BUS_ADDRESS is therefore > not set inside Sway, which leads to a number of problems > (e.g. nautilus can't read the Trash system). > > One can set the value of DBUS_SESSION_BUS_ADDRESS produced by > `dbus-launch --sh-syntax` in `.profile` ( > https://gitlab.com/wehlutyk/dotfiles/-/blob/master/.profile#L9 ), > which is then sourced by `wayland-session` if the shell is bash. > In my case my shell is fish, and the way `wayland-session` calls fish > doesn't make it export the variables exported by `.profile`. For that > a small patch to `wayland-session` works, which I ended up using: > https://gitlab.com/wehlutyk/guix-config/-/commit/5105ab1bea7f8233de5dffc0= 53f794ae69822acd > > With the two changes above (setting DBUS_SESSION_BUS_ADDRESS in > .profile, and patching wayland-session), apps can connect to dbus > inside Sway. But this seems extremely hacky. Is there maybe a better > way to make sure SDDM+Sway(+fish) is set up properly as a desktop > enviroment? Is it time to make a `sway-desktop-service-type`? > I'm all game for the above. ^ I've been working on that for a while now. I've work coding on said problem on my video channel here: https://video.hardlimit.com/my-library/video-playlists/06baf279-76ea-406a-a= 24d-2fcfefecbf35 I'll tag the below code. It's the basic define-record-type* that people may find useful in generating the sway config file. I'm taking a break from writing the sway service, because I couldn't figure out how to get the darn service to start. So now I'm working on and endlessh service. (I actually posted a patch here: https://lists.gnu.org/archive/html/guix-patches/2021-03/msg00672.html) Here is my current sway-service.scm code: #+BEGIN_SRC scheme ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2016 Mathieu Lirzin ;;; Copyright =C2=A9 2016, 2017, 2018, 2019 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2017 Mathieu Othacehe ;;; Copyright =C2=A9 2017 Jan Nieuwenhuizen ;;; Copyright =C2=A9 2018, 2019 Ricardo Wurmus ;;; Copyright =C2=A9 2018 Cl=C3=A9ment Lassieur ;;; Copyright =C2=A9 2020, 2021 Joshua Branson ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation, either version 3 of the License, or ;;; (at your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (sway-service) #:use-module (guix gexp) #:use-module (guix records) #:use-module (guix packages) #:use-module (guix build-system trivial) #:use-module (gnu packages admin) ;; #:autoload (gnu packages ci) (cuirass) ;; #:autoload (gnu packages version-control) (git) #:use-module (gnu packages wm) #:use-module (gnu services) #:use-module (gnu services base) #:use-module (gnu services shepherd) #:use-module (gnu services dbus) #:use-module (gnu services admin) #:use-module (gnu system shadow) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:export ( sway-configuration sway-configuration? sway-configuration-sway sway-configuration-user sway-configuration-group sway-configuration-sway-variables sway-configuration-bindsyms sway-configuration-raw-content sway-configuration-file sway-variables-configuration sway-variables-configuration? sway-variables-configuration-background-image sway-variables-configuration-mod-key sway-variables-configuration-letter-left sway-variables-configuration-letter-down sway-variables-configuration-letter-up sway-variables-configuration-letter-right sway-variables-configuration-default-terminal sway-variables-configuration-application-launcher sway-variables-configuration-keyboard-layout sway-variables-configuration-xkb-options sway-variables-configuration-tap-to-click? sway-variables-configuration-natural-scroll? sway-variables-configuration-middle-emulation? %sway-basic-bindsyms %sway-moving-around-bindsyms %sway-layout-bindsyms %sway-scratchpad-bindsyms ;; this is (flatten (list all the above %*-bindsyms) %sway-bindsyms sway-bindsym sway-bindsym? sway-bindsym-whole-window sway-bindsym-border sway-bindsym-exclude-titlebar sway-bindsym-release sway-bindsym-locked sway-bindsym-to-code sway-bindsym-input-device sway-bindsym-no-warm sway-bindsym-no-repeat sway-bindsym-group sway-bindsym-key-combo sway-bindsym-command sway-bindsym-command-arguments sway-status-bar-configuration sway-status-bar-configuration? sway-status-bar-position-configuration sway-status-bar-status-command-configuration sway-status-bar-pango-markup-enabled? sway-status-bar-status-line-color-configuration sway-status-bar-background-color-configuration sway-status-bar-inactive-workspace-colors-configuration sway-service-type )) ;;;; Commentary: ;;; This file provides a shepherd service to run the sway window ;;; manager. ;;;; Code: (define-record-type* sway-status-bar-configuration make-sway-status-bar-configuration sway-status-bar-configuration? (position sway-status-bar-configuration-position (default 'top)) (status-command sway-status-bar-configuration-status-command ; string (default "while date +'%Y-%m-%d %l:%M:%S %p'; do sleep 1;= done")) (pango-markup-enabled? sway-status-bar-configuration-pango-markup-enabled (default #f)) (status-line-color sway-status-bar-configuration-status-line-color ;stri= ng (default "#ffffff")) (background-color sway-status-bar-configuration-background-color ;string (default "#323232")) (inactive-workspace-colors sway-status-bar-configuration-inactive-workspa= ce-colors ; list of 3 strings (default '("#32323200 #32323200 #5c5c5c")))) (define-record-type* sway-variables-configuration make-sway-variables-configuration sway-variables? ;; TODO figure out how to set dimensions for desktop background image (background-image sway-variables-configuration-background-image ;f= ile (default "Sway_Wallpaper_Blue_1920x1080.png")) (mod-key sway-variables-configuration-mod (default "Mod4")) ;; direction letters (letter-left sway-variables-configuration-left ;char (default "h")) (letter-right sway-variables-configuration-right ;char (default "l")) (letter-up sway-variables-configuration-up ;char (default "k")) (letter-down sway-variables-configuration-down ;char (default "j")) ;; TODO set this default up to be a terminal name (default-terminal sway-variables-configuration-default-terminal (default "urxvt")) ;; TODO make this a package object? ;; set this to dmenu or whatever I am using now (application-launcher sway-variables-configuration-application-launcher (default "dmenu")) ;; TODO SET to package object ;; TODO get this layout from the OS keyboard layout record ;;list of strings keyboard layouts that you want to use (keyboard-layout sway-variables-configuration-keyboard-layouts (default '())) ;;list of strings of xkb-options that you want like (list "ctrl:swapcaps") (xkb-options sway-variables-configuration-xkb-options (default '())) (tap-to-click? sway-variables-configuration-tap-to-click? (default #f)) (natural-scroll? sway-variables-configuration-natural-scroll? (default #t)) (middle-emulation? sway-variables-configuration-middle-emulation? (default #f))) (define-record-type* sway-bindsym make-sway-bindsym sway-bindsym? (whole-window sway-bindsym-whole-window (default #f)) (border sway-bindsym-border (default #f)) (exclude-titlebar sway-bindsym-exclude-titlebar (default #f)) (release sway-bindsym-release (default #f)) (locked sway-bindsym-locked (default #f)) (to-code sway-bindsym-to-code (default #f)) (input-device sway-bindsym-input-device (default #nil)) (no-warn sway-bindsym-no-warn (default #f)) (no-repeat sway-bindsym-no-repeat (default #f)) (group sway-bindsym-group (default #f)) (key-combo sway-bindsym-key-combo (default "")) (command sway-bindsym-command ;string or (default "")) (command-arguments sway-bindsym-arguments (default #f))) (define %sway-basic-bindsyms (list (sway-bindsym (key-combo "$mod+Return") (command "$term")) ;; set to launch default terminal (sway-bindsym (key-combo "$mod+Shift+q") (command "kill")) (sway-bindsym (key-combo "$mod+d") (command "$menu")) (sway-bindsym (key-combo "$mod normal") (command "normal")) (sway-bindsym (key-combo "$mod+Shift+c") (command "reload")) (sway-bindsym (key-combo "$mod+Shift+e") (command "reload")))) (define %sway-moving-around-bindsyms (list (sway-bindsym (key-combo "$mod+$left") (command "focus left")) (sway-bindsym (key-combo "$mod+$down") (command "focus down")) (sway-bindsym (key-combo "$mod+$up") (command "focus up")) (sway-bindsym (key-combo "$mod+$right") (command "focus right")) (sway-bindsym (key-combo "$mod+Left") (command "focus left")) (sway-bindsym (key-combo "$mod+Down") (command "focus down")) (sway-bindsym (key-combo "$mod+Up") (command "focus up")) (sway-bindsym (key-combo "$mod+Right") (command "focus Right")) ;; Move the focused window with the same, but add Shift (sway-bindsym (key-combo "$mod+Shift+$left") (command "move left")) (sway-bindsym (key-combo "$mod+Shift+$down") (command "move down")) (sway-bindsym (key-combo "$mod+Shift+$up") (command "move up")) (sway-bindsym (key-combo "$mod+Shift+$right") (command "move right")) (sway-bindsym (key-combo "$mod+Shift+Left") (command "move left")) (sway-bindsym (key-combo "$mod+Shift+Down") (command "move down")) (sway-bindsym (key-combo "$mod+Shift+Up") (command "move up")) (sway-bindsym (key-combo "$mod+Shift+Right") (command "move Right")))) (define %sway-workspace-bindsyms (list (sway-bindsym (key-combo "$mod+1") (command "workspace number 1")) (sway-bindsym (key-combo "$mod+1") (command "workspace number 2")) (sway-bindsym (key-combo "$mod+3") (command "workspace number 3")) (sway-bindsym (key-combo "$mod+4") (command "workspace number 4")) (sway-bindsym (key-combo "$mod+5") (command "workspace number 5")) (sway-bindsym (key-combo "$mod+6") (command "workspace number 6")) (sway-bindsym (key-combo "$mod+7") (command "workspace number 7")) (sway-bindsym (key-combo "$mod+8") (command "workspace number 8")) (sway-bindsym (key-combo "$mod+9") (command "workspace number 9")) (sway-bindsym (key-combo "$mod+10") (command "workspace number 10")) ;; Move focused container to workspace (sway-bindsym (key-combo "$mod+Shift+1") (command "move container to workspace 1")) (sway-bindsym (key-combo "$mod+Shift+2") (command "move container to workspace 2")) (sway-bindsym (key-combo "$mod+Shift+3") (command "move container to workspace 3")) (sway-bindsym (key-combo "$mod+Shift+4") (command "move container to workspace 4")) (sway-bindsym (key-combo "$mod+Shift+5") (command "move container to workspace 5")) (sway-bindsym (key-combo "$mod+Shift+6") (command "move container to workspace 6")) (sway-bindsym (key-combo "$mod+Shift+7") (command "move container to workspace 7")) (sway-bindsym (key-combo "$mod+Shift+8") (command "move container to workspace 8")) (sway-bindsym (key-combo "$mod+Shift+9") (command "move container to workspace 9")) (sway-bindsym (key-combo "$mod+Shift+10") (command "move container to workspace 10")))) (define %sway-layout-bindsyms (list (sway-bindsym (key-combo "$mod+b") (command "splith")) ;;bindsym $mod+b splith (sway-bindsym (key-combo "$mod+v") (command "splitv")) ;; Switch the current container between different layout styles (sway-bindsym (key-combo "$mod+s") (command "layout stacking")) (sway-bindsym (key-combo "$mod+w") (command "layout tabbed")) (sway-bindsym (key-combo "$mod+e") (command "layout toggle split")) ;; Make the current focus fullscreen (sway-bindsym (key-combo "$mod+f") (command "fullscreen")) ;; Toggle the current focus between tiling and floating mode (sway-bindsym (key-combo "$mod+Shift+space") (command "floating toggle")) ;; Swap focus between the tiling area and the floating area (sway-bindsym (key-combo "$mod+space") (command "focus mode_toggle")) ;; Move focus to the parent container (sway-bindsym (key-combo "$mod+a") (command "focus parent")) ;; Resizing containers: ;; TODO how am I handling resizing containers??? ;; TODO let users edit "resize" variable so that they can modify how muc= h each keypress ;; resizes containers. ;; this code is hardcoded into the service definition ;; mode "resize" { ;; # left will shrink the containers width ;; # right will grow the containers width ;; # up will shrink the containers height ;; # down will grow the containers height ;; bindsym $left resize shrink width 10px ;; bindsym $down resize grow height 10px ;; bindsym $up resize shrink height 10px ;; bindsym $right resize grow width 10px ;; # Ditto, with arrow keys ;; bindsym Left resize shrink width 10px ;; bindsym Down resize grow height 10px ;; bindsym Up resize shrink height 10px ;; bindsym Right resize grow width 10px ;; # Return to default mode ;; bindsym Return mode "default" ;; bindsym Escape mode "default" ;; } ;; bindsym $mod+r mode "resize" (sway-bindsym (key-combo "$mod+r") (command "\"resize\"")))) (define %sway-scratchpad-bindsyms (list (sway-bindsym (key-combo "$mod+Shift+minus") (command "move scratchpad")) ;; Show the next scratchpad window or hide the focused scratchpad window. ;; If there are multiple scratchpad windows, this command cycles through= them. (sway-bindsym (key-combo "$mod+minus") (command "scratchpad show")))) (define (flatten . lst) "Return a list that recursively concatenates all sub-lists of LST." (define (flatten1 head out) (if (list? head) (fold-right flatten1 out head) (cons head out))) (fold-right flatten1 '() lst)) (define %sway-bindsyms (flatten (list %sway-basic-bindsyms %sway-layout-bindsyms %sway-workspace-bindsyms %sway-moving-around-bindsyms %sway-scratchpad-bindsyms))) (define-record-type* sway-configuration make-sway-configuration sway-configuration? (sway sway-configuration-sway ;package (default sway)) (user sway-configuration-user ;string (default "sway")) (group sway-configuration-group ;string (default "users")) (variables sway-configuration-variables (default (sway-variables-configuration))) (bindsyms sway-configuration-bindsyms (default %sway-bindsyms)) (status-bar sway-configuration-status-bar (default (sway-status-bar-configuration))) (raw-content sway-configuration-raw-content (default "")) (file sway-configuration-file ;file-like object (default #f))) (define sway-variables-configuration->list (match-lambda (($ background-image mod-key letter-left= letter-down letter-up letter-right default-terminal application-launche= r keyboard-layout xkb-options tap-to-click? natural-scroll? middle= -emulation?) (list "### Variables\n" "# Logo key. Use Mod1 for Alt\n" "set $mod " mod-key "\n" "# Home row direction keys, like vim\n" "set $left " letter-left "\n" "set $down " letter-down "\n" "set $up " letter-up "\n" "set $right " letter-right "\n" "set $term " default-terminal "\n" ;;TODO potentially use a gexp to p= oint to default-terminal package ;; TODO deal with application-launcher "### Output configuration\n" "# Default Wallpaper\n" "output * bg " background-image " fill\n" ;;TODO use a gexp to copy t= he background image into the store ;; TODO deal with swayidle and sway lock "### Input configuration\n" (cond [(or tap-to-click? natural-scroll? middle-emulation? (not (null= ? keyboard-layout)) (not (null? xkb-options))) (list "input * " "{ \n" (if tap-to-click? "\t tap enabled\n" "") (if natural-scroll? "\t natural_scroll enabled\n" "") (if middle-emulation? "\t middle_emulation enabled\n" "") ;; TODO xkb-layout should be gotten from the keyboard layout, ;; which should specify it in the environment The keymap can ;; also be configured using environment variables ;; (XKB_DEFAULT_LAYOUT, XKB_DEFAULT_VARIANT, etc.) when start= ing ;; sway, with config options taking precedence over environme= nt ;; variables. ;; TODO xkb-layout the arch linux wiki page shows ;; this https://wiki.archlinux.org/index.php/Sway#Keymap inpu= t * ;; { xkb_layout "us,de,ru" xkb_variant "colemak,,typewriter" ;; xkb_options "grp:win_space_toggle" } (cond [(not (null? xkb-options)) (list "xkb_options " (substring (let loop ([list xkb-options]) (cond [(null? list) ""] [else (string-append "," (car list) (loop (cdr li= st)))])) 1))] [else ""]) "\n} \n" ;; end input )] [else ""]) )))) ;; -> string ;; consider renaming to sway-bindsym->string (define (sway-bindsym->string sway-bindsym) (let* ([command (sway-bindsym-command sway-bindsym)] [key-combo (cond [(package? command) ;;TODO gexp -> string /gnu/store/stahesunteah/bi= n/ ] [else (sway-bindsym-key-combo sway-bindsym)])]) (string-append key-combo " " command "\n"))) ;; list of -> string (define (sway-bindsyms->list list) (let loop ([list (flatten list)]) (cond [(null? list) '()] [else (cons (sway-bindsym->string (car list)) (loop (cdr list)))]))) ;; pango-markup-enabled? Todo (define sway-status-bar-configuration->list (match-lambda (($ position status-command pango-marku= p-enabled? status-line-color background-color inactive-workspace-colors) (list "#\n" "# Status Bar:\n" "#\n" "# Read man 5 sway-bar-configuration for more information about this = section." "bar {\n" "\t position " (symbol->string position) "\n" "\t # When the status_command prints a new line to stdout, swaybar up= dates.\n" "\t # The default just shows the current date and time.\n" "\t status_command " status-command "\n" "\t colors {\n" "\t\t statusline " status-line-color "\n" "\t\t background " background-color "\n" "\t\t inactive_workspace " (let loop ([list inactive-workspace-colors]) (cond [(null? list) ""] [else (string-append (car list) " " (loop (cdr list)))])) "\n" "\t }\n" "}\n" )))) ;; TODO deal with a sway config-file (define sway-configuration->list (match-lambda (($ sway user group variables bindsyms status-bar raw-content file) (flatten (list (sway-variables-configuration->list variables) (sway-bindsyms->list bindsyms) ;; Todo (sway-status-bar-configuration->list status-bar) ))))) ;; Maybe put this code in a guix test? ;; (define config (sway-configuration ;; (variables ;; (sway-variables-configuration ;; (letter-left "n") ;; (letter-right "s") ;; (letter-up "t") ;; (letter-down "h") ;; (mod-key "Mod1") ;; (default-terminal "allcritty") ;; (xkb-options (list "ctrl:swapcaps" ;; "shift:breaks_caps")))) ;; (bindsyms ;; (list ;; %sway-basic-bindsyms ;; %sway-moving-around-bindsyms ;; (sway-bindsym (key-combo "$mod+Shift+Return") ;; (command "$term -e fish")))) ;; (status-bar ;; (sway-status-bar-configuration ;; (status-command "echo 'hello world!'") ;; (status-line-color "blue") ;; (inactive-workspace-colors (list "red" "green" "yellow= ")))))) ;; ;; (display (let loop ([list (sway-configuration->list config)]) ;; (cond [(null? list) ;; ""] ;; [else (string-append (car list) ;; (loop (cdr list)))]))) ;; For now I am assuming that this is correct. (define (default-sway-config config) ;; (match-record ;; config ;; ;; (sway user group variables bindsyms status-bar raw-content file) ;; ;; (apply mixed-text-file "config.in" ;; ;; (flatten ;; ;; (sway-configuration->list config))) ;; ;; TODO this won't work if I want to use gexps involving paths to exe= cutables. ;; ) (plain-file "config.in" (apply string-append (sway-configuration->list config)))) (define (sway-activation config) (match-record config (sway file) #~(begin (use-modules (guix build utils)) ;; (format #t "creating nginx log directory '~a'~%" #$log-directory) ;; (mkdir-p #$log-directory) ;; Start-up logs. Once configuration is loaded, nginx switches to ;; log-directory. ;; do something with recording sway's logs. ;;(mkdir-p (string-append #$run-directory "/logs")) ;; Check configuration file syntax. (system* (string-append #$sway "/bin/sway") "-c" #$(or file (default-sway-config config)))))) (define (sway-shepherd-service config) "Return a for the Sway service with CONFIG." (let* ([sway (sway-configuration-sway config)] [user (sway-configuration-user config)] [group (sway-configuration-group config)] [file (sway-configuration-file config)]) (list (shepherd-service (documentation "Run Sway.") (provision '(sway)) (requirement '(user-processes dbus-system elogind udev virtual-t= erminal syslogd)) ;;(requirement '(guix-daemon networking)) (start #~(make-forkexec-constructor ;; TODO change this line to ;; exec dbus-run-session sway ;; should we un-gexp the (string-append? ;; they do it here ;; [[file:~/prog/gnu/guix/guix-src/gnu/services/base.s= cm::(system* #$(file-append guix "/bin/guix") "archive"][here]] (list (string-append #$sway "/bin/sway") ;; should this be a '("-c") ;; [[file:~/prog/gnu/guix/guix-src/gnu/services/= networking.scm::'("-g")]['("-g")]] "-c" #$(or file (default-sway-config config))) ;; #:environment-variables ;; (list "GIT_SSL_CAINFO=3D/etc/ssl/certs/ca-certifica= tes.crt" ;; (string-append "GIT_EXEC_PATH=3D" #$git ;; "/libexec/git-core")) #:user #$user ;;#:group #$group ;;#:log-file #$log-file )) (stop #~(make-kill-destructor (list (string-append #$sway "/bin/swaymsg") "exit") #:user #$user)))))) (define sway-service-type (service-type (name 'sway) (extensions (list ;; (service-extension profile-service-type ;fo= r 'info sway' ;; (compose list sway-confi= guration-sway shepherd-root-service-type)) (service-extension polkit-service-type sway-se= rvice-type) ;; all gnome, xfce, mate, use this profile-ser= vice-type, which I'm guessing means ;; to start the service after the user has log= ged in. (service-extension profile-service-type (compose list sway-configur= ation-sway)) ;; activation service type is a procedure that= returns a gexp which is a code snippet to run at ;; activation time. example at boot (service-extension activation-service-type swa= y-activation) ;;(service-extension account-service-type sway= -account) ;; if people define %desktop-services, then we= don't need it. ;; if this service goes in the services/wm.scm= , include elogind ;;(service-extension elogind-service-type) )) (default-value (sway-configuration)) (description "Run the sway window manager."))) #+END_SRC -- Joshua Branson (joshuaBPMan in #guix) Sent from Emacs and Gnus https://gnucode.me https://video.hardlimit.com/accounts/joshua_branson/video-channels https://propernaming.org "You can have whatever you want, as long as you help enough other people get what they want." - Zig Ziglar