You are not logged in.
Hi, all.
i am suspend to system with a bash function in command line.
suspend ()
{
echo -n mem | sudo tee /sys/power/state
}after wake up, i found swap capslock/ctrl is invalid, which is work
before suspend.
Question: how to make capslock/ctrl keep working even wake up from suspend?
Following is some attempt, but no luck. (maybe wrong)
1. create a executable script /usr/lib/systemd/system-sleep/run_xmodmap, no work.
#!/bin/bash
case $1 in
pre)
echo 'enter suspend' > /tmp/enter_suspend
;;
post)
xmodmap /home/zw963/.Xmodmap
echo 'enter suspend' > /tmp/exit_suspend
/home/zw963/Dropbox/common/sh/say
esacAnd run `systemctl suspend`, and wake up, script in post is executed,
but Ctrl is not swapped as expected.
The same issue happen on following command which invalid after suspend.
gsettings set org.gnome.desktop.interface gtk-key-theme EmacsThanks
--------------
BTW: I use xorgs, and bumblebee.
Last edited by zw963 (2019-05-02 01:41:56)
Offline
The keyboard gets (virtually) re-attached, you'd have to go for xkb configuration in an xorg configlet: https://wiki.archlinux.org/index.php/Xo … tion_files
As for xmodmap, the sleep hooks (as well as udev rules, if you wanted) run as root and w/o any knowledge of the X11 server, ie. you'll have to "sudo -u zw963" and also (typically) "export DISPLAY=:0"
Here's nice script to fetch the relevant environment variables from the xinit process, you'll have to adjust that if you're not using xinit: https://gist.github.com/AladW/de1c5676d93d05a5a0e1
Offline
> Here's nice script to fetch the relevant environment variables from the xinit process, you'll have to adjust that if you're not using xinit: https://gist.github.com/AladW/de1c5676d93d05a5a0e1
This function not owrk for me, e.g. $DISPlAY wrong result, i use GDM.
DISPLAY=:1BASH_FUNC_my_editor_open%%=() { local ln=${line_number++}${line_number};
Following is code:
pid=$(pgrep -t tty$(fgconsole) gdm)
pid=$(pgrep -P $pid -n)
echo $pid
import_environment() {
(( pid )) && for var; do
IFS='=' read key val < <(egrep -z "$var" /proc/$pid/environ)
printf -v "$key" %s "$val"
[[ ${!key} ]] && export "$key"
done
}
import_environment XAUTHORITY USER DISPLAY> As for xmodmap, the sleep hooks (as well as udev rules, if you wanted) run as root and w/o any knowledge of the X11 server, ie. you'll have to "sudo -u zw963" and also (typically) "export DISPLAY=:0"
After add following code to /usr/lib/systemd/system-sleep/run_xmodmap, still not work
case $1 in
pre)
echo 'enter suspend' > /tmp/enter_suspend
;;
post)
export DISPLAY=:1 # <= this DISPLAY before suspend
sudo -u zw963 xmodmap /home/zw963/.Xmodmap &> /tmp/exit_suspend # <= no see any error here.
esacThanks
Last edited by zw963 (2019-05-03 04:53:46)
Offline
Because GDM runs on DISPLAY :0 and spawns your session on DISPLAY :1
sudo will drop the environment, you'll have to set it there. Eg. using "env"
Offline