all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Execute startxbmap at login to map Ctrl Caps to Escape
@ 2023-03-17  2:31 Rodrigo Morales
  2023-03-17  2:46 ` Mario Forzanini
  2023-03-17 15:05 ` Gary Johnson
  0 siblings, 2 replies; 4+ messages in thread
From: Rodrigo Morales @ 2023-03-17  2:31 UTC (permalink / raw)
  To: help-guix

Table of Contents
_________________

1. The context
2. The question
3. Additional information


1 The context
=============

  I've been using Guix for around 1 month. I'd previously used Arch
  Linux. In Arch Linux, I mapped Caps Lock to Ctrl by inserting the
  following statement in my ~/.xinitrc file (see code block below)

  ,----
  | #!/bin/bash
  |
  | setxkbmap -option 'ctrl:nocaps' -layout us
  |
  | exec i3
  `----

  The `~/.xinitrc' file was read by `startx', as you can see in the last
  line of the file `~/.profile' (see code block below)

  ,----
  | (...)
  |
  | startx ~/.xinitrc
  `----

  In Guix, I'm using Emacs with EXWM and I want to map Caps Lock to
  Escape as I did in Arch in Linux. I don't necessarily want to execute
  `startx' or `xinitrc'. I'm happy with whatever solution that guarantee
  that the `setxbmap' command is executed.


2 The question
==============

  What's the Guix way to map Caps Lock to Escape?


3 Additional information
========================

  I found [this(1)] message in help-guix from 22 Mar 2021, someone
  states that it has never been simple to use `xinit' or `startx' in
  Guix.

  I also found [this(2)] thread in help-guix started in 21 Aug 2021,
  where someone reports that startx was not working.

  To me, all seems to indicate that I shouldn't try to use `startxkbmap'
  in `~/.xinitrc' (so that it can be read by `startx' or `xinitrc'), so
  I'm sure there must be a more proper way.

  I could also insert the following statement in my `init.el' file (see
  code block below), but this solution doesn't look clean to me. When I
  switch to i3, this solution wouldn't work.

  ,----
  | (start-process "*foo*" nil "setxkbmap" "-option" "ctrl:nocaps"
"-layout" "us")
  `----


[this(1)] <https://www.mail-archive.com/help-guix@gnu.org/msg11418.html>

[this(2)] <https://www.mail-archive.com/help-guix@gnu.org/msg12256.html>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Execute startxbmap at login to map Ctrl Caps to Escape
  2023-03-17  2:31 Execute startxbmap at login to map Ctrl Caps to Escape Rodrigo Morales
@ 2023-03-17  2:46 ` Mario Forzanini
       [not found]   ` <CAGxMbPZOwaw8WzOqEXkcjy8sH-94DTSLy1XVK0kZQM0Vb9H01g@mail.gmail.com>
  2023-03-17 15:05 ` Gary Johnson
  1 sibling, 1 reply; 4+ messages in thread
From: Mario Forzanini @ 2023-03-17  2:46 UTC (permalink / raw)
  To: Rodrigo Morales; +Cc: help-guix

Hi!

On 3/17/23 3:31 AM, Rodrigo Morales wrote:
>    What's the Guix way to map Caps Lock to Escape?

I actually have some similar setting mapping Caps Lock to Control in my 
operating system configuration, I think this may work:

<snip>
(operating-system
   (keyboard-layout (keyboard-layout "us" #:options '("caps:escape")))
   ; ...
<snap>

Then you can use this configuration for Xorg by adding the 
'set-xorg-configuration' service:

<snip>
(service
   (set-xorg-configuration
     (xorg-configuration (keyboard-layout keyboard-layout)))
<snap>

Note that this approach also applies this setting to TTYs, if you only 
want to modify the keyboard layout in Xorg you can modify the second 
snippet:

<snip>
(service
   (set-xorg-configuration
     (xorg-configuration
       (keyboard-layout
         (keyboard-layout "us" #:option '("ctrl:escape")))))
   ; ...
<snap>

Then rebuild the system
-- 
Mario


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Execute startxbmap at login to map Ctrl Caps to Escape
       [not found]   ` <CAGxMbPZOwaw8WzOqEXkcjy8sH-94DTSLy1XVK0kZQM0Vb9H01g@mail.gmail.com>
@ 2023-03-17 12:40     ` Mario Forzanini
  0 siblings, 0 replies; 4+ messages in thread
From: Mario Forzanini @ 2023-03-17 12:40 UTC (permalink / raw)
  To: Rodrigo Morales; +Cc: help-guix

On 3/17/23 4:18 AM, Rodrigo Morales wrote:
> Thanks for the quick answer. After reading your answer and the relevant
> part of the documentation, I understand that this configuration needs to
> be set at the system level (i.e. /etc/config.scm). Wouldn't it be
> possible to set a layout for an user-account?

Well the default layout for the Xserver is set when the server starts, 
so there is no way to know which user is running the system until login. 
After login you might be able to set the keyboard layout autostarting a 
script that runs setxkbmap or xcape, or any other program you might 
need, this depends on the desktop environment/window manager you are 
using; in the case of EXWM you might add something to init.el as you 
were suggesting in your first email. In my setup GDM starts dwm directly 
from ~/.xsession which is analogous to an ~/.xinitrc, you may try 
experimenting with this file if the system configuration fails you.

> The code block below shows my configuration which was generated using
> the graphical installation (besides adding new users, I haven't made any
> modification). As you can see below, I have two users: rdrg20 and
> rdrg21, I would like rdrg20 to have the "us" keyboard layout and I would
> like rdrg21 to have the "fr" (French) keyboard layout.
> 
> ,----
> | (use-modules (gnu))
> | (use-service-modules cups desktop networking ssh xorg)
> |
> | (operating-system
> |   (locale "en_US.utf8")
> |   (timezone "America/Lima")
> |   (keyboard-layout (keyboard-layout "us"))
> |   (host-name "sony")
> |
> |   ;; The list of user accounts ('root' is implicit).
> |   (users (cons* (user-account
> |                   (name "rdrg")
> |                   (comment "This is a comment for user rdrg")
> |                   (group "users")
> |                   (home-directory "/home/rdrg")
> |                   (supplementary-groups '("wheel" "netdev" "audio" 
> "video")))
> | (user-account
> |                   (name "rdrg20")
> |                   (comment "This is a comment for user rdrg20")
> |                   (group "users")
> |                   (home-directory "/home/rdrg20")
> |                   (supplementary-groups '("wheel" "netdev" "audio" 
> "video")))
> | (user-account
> |                   (name "rdrg21")
> |                   (comment "This is a comment for user rdrg21")
> |                   (group "users")
> |                   (home-directory "/home/rdrg21")
> |                   (supplementary-groups '("wheel" "netdev" "audio" 
> "video")))
> | (user-account
> |                   (name "rdrg22")
> |                   (comment "This is a comment for user rdrg22")
> |                   (group "users")
> |                   (home-directory "/home/rdrg22")
> |                   (supplementary-groups '("wheel" "netdev" "audio" 
> "video")))
> |                 %base-user-accounts))
> |
> |   ;; Packages installed system-wide.  Users can also install packages
> |   ;; under their own account: use 'guix search KEYWORD' to search
> |   ;; for packages and 'guix install PACKAGE' to install a package.
> |   (packages (append (list (specification->package "emacs")
> |                           (specification->package "emacs-exwm")
> |                           (specification->package
> |                            "emacs-desktop-environment")
> |                           (specification->package "nss-certs"))
> |                     %base-packages))
> |
> |   ;; Below is the list of system services.  To search for available
> |   ;; services, run 'guix system search KEYWORD' in a terminal.
> |   (services
> |    (append (list
> |
> |                  ;; To configure OpenSSH, pass an 'openssh-configuration'
> |                  ;; record as a second argument to 'service' below.
> |                  (service openssh-service-type)
> |                  (set-xorg-configuration
> |                   (xorg-configuration (keyboard-layout keyboard-layout))))
> |
> |            ;; This is the default list of services we
> |            ;; are appending to.
> |            %desktop-services))
> |   (bootloader (bootloader-configuration
> |                 (bootloader grub-efi-bootloader)
> |                 (targets (list "/boot/efi"))
> |                 (keyboard-layout keyboard-layout)))
> |   (swap-devices (list (swap-space
> |                         (target (uuid
> |                                 
>   "21a4d7a3-b35b-45e1-9d91-e4fa97a593c0")))))
> |
> |   ;; The list of file systems that get "mounted".  The unique
> |   ;; file system identifiers there ("UUIDs") can be obtained
> |   ;; by running 'blkid' in a terminal.
> |   (file-systems (cons* (file-system
> |                          (mount-point "/boot/efi")
> |                          (device (uuid "E04D-B82E"
> |                                        'fat32))
> |                          (type "vfat"))
> |                        (file-system
> |                          (mount-point "/")
> |                          (device (uuid
> |                                   "67aa77a1-4cb4-4cf5-bca6-ea51c4e5632e"
> |                                   'ext4))
> |                          (type "ext4")) %base-file-systems)))
> `----

In your system configuration you can also specify multiple keyboard 
layouts and a key combination to switch between them with an option like 
'grp:alt_shift_toggle', see the relevant docs:

https://guix.gnu.org/en/manual/en/html_node/Keyboard-Layout.html

There may also be some other way I'm not aware of to set the keyboard 
layout per user, if someone else on the mailing list knows how to do 
this, feel free to correct me or suggest other possible ways.
-- 
Mario


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Execute startxbmap at login to map Ctrl Caps to Escape
  2023-03-17  2:31 Execute startxbmap at login to map Ctrl Caps to Escape Rodrigo Morales
  2023-03-17  2:46 ` Mario Forzanini
@ 2023-03-17 15:05 ` Gary Johnson
  1 sibling, 0 replies; 4+ messages in thread
From: Gary Johnson @ 2023-03-17 15:05 UTC (permalink / raw)
  To: Rodrigo Morales; +Cc: help-guix

Rodrigo Morales <moralesrodrigo1100@gmail.com> writes:

> 1 The context
> =============
>
>   8<---------------------------------------------------------------->8
>                         ...TEXT ELIDED...
>   8<---------------------------------------------------------------->8
>
>   In Guix, I'm using Emacs with EXWM and I want to map Caps Lock to
>   Escape as I did in Arch in Linux. I don't necessarily want to
>   execute `startx' or `xinitrc'. I'm happy with whatever solution that
>   guarantee that the `setxbmap' command is executed.
>
>
> 2 The question
> ==============
>
>   What's the Guix way to map Caps Lock to Escape?

Hi Rodrigo,

  A thoroughly Guix way to do this would probably be to just set the
  `keyboard-layout` property in your operating system record like so:

```system.scm
(operating-system
 ...
 (keyboard-layout (keyboard-layout "emacs"))
 ...)
```

This should update the keymap at your tty sessions, but I'm not sure if
it will propagate into your X session. Perhaps someone else here has
tried it?

I also run EXWM as my window manager on Guix System, and I've addressed
this keymapping issue by just inserting it into my $HOME/.xsession file
like so:

```.xsession
# Change cursor to left arrow
xsetroot -cursor_name left_ptr

# Set keyboard repeat rate
xset r rate 200 60

# Change Caps Lock to Ctrl
setxkbmap -option "ctrl:nocaps"
setxkbmap -option "terminate:ctrl_alt_bksp"

# Start Emacs with the exwm script:
exwm
```

Have fun and happy hacking!
  Gary

-- 
=======================================================================
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

Why is HTML email a security nightmare? See https://useplaintext.email/

Please avoid sending me MS-Office attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-18 15:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-17  2:31 Execute startxbmap at login to map Ctrl Caps to Escape Rodrigo Morales
2023-03-17  2:46 ` Mario Forzanini
     [not found]   ` <CAGxMbPZOwaw8WzOqEXkcjy8sH-94DTSLy1XVK0kZQM0Vb9H01g@mail.gmail.com>
2023-03-17 12:40     ` Mario Forzanini
2023-03-17 15:05 ` Gary Johnson

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.