Compare commits

...

5 Commits

Author SHA1 Message Date
Hilton Chain
c190e8a468
utils: hidden-desktop-entry: Fix substitution pattern.
* modules/rosenthal/utils/file.scm (hidden-desktop-entry): Fix pattern.
2025-06-28 01:04:02 +08:00
Hilton Chain
a47d340a20
services: Add %rosenthal-set-keymap.
* modules/rosenthal/services/desktop.scm (%rosenthal-set-keymap): New variable.
(%rosenthal-set-keymap-script): Unexport.
2025-06-27 23:10:30 +08:00
Hilton Chain
8c1b2e9c61
utils: Add ‘hidden-desktop-entry’.
* modules/rosenthal/utils/file.scm (hidden-desktop-entry): New procedure.
2025-06-27 21:48:47 +08:00
Hilton Chain
dc6ed8b930
services: Add %rosenthal-set-keymap-script.
* modules/rosenthal/services/desktop.scm (%rosenthal-set-keymap-script): New
variable.
* modules/rosenthal/examples/niri.kdl: Adjust configuration.
2025-06-27 21:48:45 +08:00
Hilton Chain
dd9bebf8b2
examples: niri.kdl: Use existing path for screenshots.
* modules/rosenthal/examples/niri.kdl: Store screenshots under the home
directory.
2025-06-27 21:22:36 +08:00
3 changed files with 133 additions and 10 deletions

View File

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2023-2025 Ivan Molodetskikh <yalterz@gmail.com>
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This config is in the KDL format: https://kdl.dev
// "/-" comments out the following node.
// Check the wiki for a full description of the configuration:
@ -12,8 +12,6 @@
// https://github.com/YaLTeR/niri/wiki/Configuration:-Input
input {
keyboard {
repeat-delay 300
repeat-rate 30
xkb {
// You can set rules, model, layout, variant and options.
// For more information, see xkeyboard-config(7).
@ -22,6 +20,8 @@ input {
// layout "us,ru"
// options "grp:win_space_toggle,compose:ralt,ctrl:nocaps"
}
repeat-delay 300
repeat-rate 30
}
// Next sections include libinput settings.
@ -252,7 +252,7 @@ layout {
// Note that running niri as a session supports xdg-desktop-autostart,
// which may be more convenient to use.
// See the binds section below for more spawn examples.
// spawn-at-startup "alacritty" "-e" "fish"
// spawn-at-startup "foot" "fish"
// Uncomment this line to ask the clients to omit their client-side decorations if possible.
// If the client will specifically ask for CSD, the request will be honored.
@ -264,7 +264,7 @@ layout {
// You can change the path where screenshots are saved.
// A ~ at the front will be expanded to the home directory.
// The path is formatted with strftime(3) to give you the screenshot date and time.
screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png"
screenshot-path "~/Screenshot from %Y-%m-%d %H-%M-%S.png"
// You can also set this to null to disable saving screenshots to disk.
// screenshot-path null
@ -317,7 +317,7 @@ window-rule {
// Example: enable rounded corners for all windows.
// (This example rule is commented out with a "/-" in front.)
window-rule {
/-window-rule {
geometry-corner-radius 12
clip-to-geometry true
}
@ -344,7 +344,7 @@ binds {
// You can also use a shell. Do this if you need pipes, multiple commands, etc.
// Note: the entire command goes as a single argument in the end.
// Mod+T { spawn "bash" "-c" "notify-send hello && exec alacritty"; }
// Mod+T { spawn "bash" "-c" "notify-send hello && exec foot"; }
// Example volume keys mappings for PipeWire & WirePlumber.
// The allow-when-locked=true property makes them work even when the session is locked.
@ -576,9 +576,11 @@ binds {
Mod+Shift+P { power-off-monitors; }
}
prefer-no-csd
spawn-at-startup "sh" "-c" "pgrep --uid $USER shepherd > /dev/null || shepherd"
// Rootless Xwayland support
spawn-at-startup "xwayland-satellite" ":233"
environment {
DISPLAY ":233"
}
// Start user Shepherd
spawn-at-startup "sh" "-c" "pgrep --uid $USER shepherd > /dev/null || shepherd"

View File

@ -4,11 +4,15 @@
(define-module (rosenthal services desktop)
#:use-module (guix gexp)
#:use-module (guix modules)
#:use-module (guix packages)
#:use-module (guix records)
#:use-module (guix utils)
#:use-module (rosenthal utils file)
#:use-module (rosenthal utils packages)
#:use-module (guix build-system copy)
#:use-module (gnu system)
#:use-module (gnu system shadow)
@ -55,6 +59,7 @@
home-waybar-configuration
home-waybar-service-type
%rosenthal-set-keymap
%rosenthal-skeletons
%rosenthal-desktop-services
%rosenthal-desktop-home-services))
@ -467,6 +472,108 @@ gtk-key-theme-name = ~a~%"
;;; Configuration file presets.
;;;
(define %rosenthal-set-keymap-script
(program-file "set-keymap"
(with-imported-modules (source-module-closure '((guix build utils)))
#~(begin
(use-modules (srfi srfi-1)
(srfi srfi-26)
(srfi srfi-37)
(ice-9 match)
(ice-9 popen)
(guix build utils))
(define* (build-keyboard-layout file layout #:optional variant #:key model options)
(define pipe
(apply open-pipe* OPEN_READ
#$(file-append (spec->pkg "console-setup") "/bin/ckbcomp")
(string-append "-I" #$(spec->pkg "xkeyboard-config") "/share/X11/xkb")
"-rules" "base"
`(,@(if model
'("-model" ,model)
'())
,layout
,(or variant "")
,(string-join options ","))))
(mkdir-p (dirname file))
(call-with-output-file file
(lambda (output)
(dump-port pipe output))))
(define* (set-keyboard-layout layout #:optional variant #:key model options)
(define file-name "/tmp/keymaps/console-keymap")
(build-keyboard-layout file-name layout variant #:model model #:options options)
(invoke "sudo" #$(file-append (spec->pkg "kbd") "/bin/loadkeys") file-name)
(when (getenv "WAYLAND_DISPLAY")
(substitute* (in-vicinity (getenv "XDG_CONFIG_HOME") "niri/config.kdl")
(("^ (layout|variant|model|options) .*") "")
(("^ xkb \\{.*" line)
(string-append
line
(format #f " layout ~s~%" layout)
(if variant (format #f " variant ~s~%" variant) "")
(if model (format #f " model ~s~%" model) "")
(format #f " options ~s~%" (string-join options ",")))))))
(define (show-help-and-exit)
(display "\
Usage: set-keymap LAYOUT [VARIANT] [-m MODEL] [-o OPTIONS]
OPTIONS are comma-separated e.g. \"ctrl:nocaps,grp:alt_shift_toggle\"
Examples:
set-keymap us
set-keymap us dvorak
set-keymap us dvorak -o ctrl:nocaps\n")
(quit))
(define (parse-options)
(args-fold (cdr (program-arguments))
(list (option '(#\m "model") #t #f
(lambda (opt name arg result)
(alist-cons 'model arg result)))
(option '(#\o "options") #t #f
(lambda (opt name arg result)
(alist-cons 'options (string-split arg #\,)
result)))
(option '("help") #f #f
(lambda _
(show-help-and-exit))))
(lambda (opt name arg loads)
(error "Unrecognized option `~A'" name))
(lambda (opt loads) (cons opt loads))
'()))
(let* ((opts (parse-options))
(model (assoc-ref opts 'model))
(options (or (assoc-ref opts 'options) '()))
(args (remove pair? (reverse opts))))
(match args
((layout)
(set-keyboard-layout layout #:model model #:options options))
((layout variant)
(set-keyboard-layout layout variant #:model model #:options options))
(_
(show-help-and-exit))))))))
(define %rosenthal-set-keymap
(hidden-package
(package
(name "rosenthal-set-keymap")
(version "0.0.0")
(source %rosenthal-set-keymap-script)
(build-system copy-build-system)
(arguments
(list
#:phases
#~(modify-phases %standard-phases
(replace 'install
(lambda _
(install-file "set-keymap" (in-vicinity #$output "bin")))))))
(home-page "")
(synopsis "")
(description "")
(license #f))))
(define %rosenthal-skeletons
`((".config/emacs/fonts.el"

View File

@ -5,7 +5,11 @@
#:use-module (ice-9 textual-ports)
#:use-module (guix gexp)
#:export (computed-substitution-with-inputs
file-content))
file-content
hidden-desktop-entry))
;; XXX: substitute* doesn't fully support Unicode:
;; https://codeberg.org/guix/guix/src/commit/a88d6a45e422cede96d57d7a953439dc27c6a50c/guix/build/utils.scm#L964
(define (computed-substitution-with-inputs name file inputs)
(with-imported-modules '((guix build utils))
@ -20,3 +24,13 @@
(define (file-content file)
(call-with-input-file (canonicalize-path file) get-string-all))
(define (hidden-desktop-entry name file)
(computed-file name
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
(copy-file #$file #$output)
(substitute* #$output
(("^\\[Desktop Entry\\].*" all)
(string-append all "NoDisplay=true\n")))))))