How to remove Left Win button from Level 3 in setxkbmap? - keyboard

I wish to use 'Left Win' button to switch keyboard layouts. This works fine on my PC: I just added two keyboards in Xfce4 and defined 'Left Win' as a switch: screenshot of xfce keyboard layouts
I have the next setxkbmap on my PC that works fine:
$ setxkbmap -query
rules: evdev
model: pc105
layout: us,ru
variant: ,
options: compose:sclk,grp:lwin_toggle
But the same configs in Xfce4 Keyboard layouts do not work on laptop. I noticed that on Laptop I also have this in setxkbmap:
$ setxkbmap -query
rules: evdev
model: pc105
layout: ru,us
variant: ,
options: grp:lwin_toggle,lv3:lwin_switch
and this does not work. I think that the reason is that 'Left Win' presents in both grp and lv3 options, and this makes it is not working.
How can I remove option 'lv3:lwin_switch' from setxkbmap the easiest way?
Update 2022-08-07 01:16 utc:
I just found how to remove options from setxkbmap with link
setxkbmap -option
But when I set 'Left Win' for switch keyboard, I get again unworkable config:
$ setxkbmap -query -print
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+ru+us:2+inet(evdev)+group(lwin_toggle)+level3(lwin_switch)" };
xkb_geometry { include "pc(pc105)" };
};
rules: evdev
model: pc105
layout: ru,us
variant: ,
options: grp:lwin_toggle,lv3:lwin_switch
I think it is a bug of my version of xfce4:
$ xfce4-panel -V
Gtk-Message: 04:19:48.448: Failed to load module "atk-bridge"
xfce4-panel 4.12.2 (Xfce 4.12)
How to fix this bug?

with these links bbs.archlinux.org, devuan installation and also reading manuals
man setxkbmap
man xkeyboard-config
I fixed my own problem. That was a mistake during installation of Devuan, when it asked configuration of keyboard. I ran under root:
# dpkg-reconfigure keyboard-configuration
and chose keyboard, language, and AltGear key, compose key. I chose to none, and after that I could set 'Left Win' for keyboard switch in Xfce4 settings.
Also i can do it manually with this:
setxkbmap -option
setxkbmap -option 'grp:lwin_toggle'
First line just erase all the options from setxkbmap, the second line adds option for keyboard switch. But this works only for current session, not permanently.
Refining my question: What set 'Left Win' as level3 key? - That was xorg settings, that I fixed with dpkg-reconfigure keyboard-configuration. How to set 'Left Win' for keyboard switch? - Go to Keyboard settings, and disable standard configurations, add layouts and set 'Left Win' as keyboard switch. But be sure xorg configs do not break it, check xorg configs under root: dpkg-reconfigure keyboard-configuration.

Related

How can I disable CONFIG_PM when building Linux kernel for x86_64

I've unselected all options in the "Power Management and ACPI options" submenu,
But options CONFIG_PM, CONFIG_PM_SLEEP are still enabled,
# Power management and ACPI options
#
# CONFIG_SUSPEND is not set
CONFIG_HIBERNATE_CALLBACKS=y
# CONFIG_HIBERNATION is not set
CONFIG_PM_SLEEP=y
CONFIG_PM_SLEEP_SMP=y
# CONFIG_PM_AUTOSLEEP is not set
# CONFIG_PM_WAKELOCKS is not set
CONFIG_PM=y
# CONFIG_PM_DEBUG is not set
CONFIG_PM_CLK=y
CONFIG_PM_GENERIC_DOMAINS=y
# CONFIG_WQ_POWER_EFFICIENT_DEFAULT is not set
CONFIG_PM_GENERIC_DOMAINS_SLEEP=y
CONFIG_PM_GENERIC_DOMAINS_OF=y
# CONFIG_ENERGY_MODEL is not set
CONFIG_ARCH_SUPPORTS_ACPI=y
# CONFIG_ACPI is not set
CONFIG_X86_PM_TIMER=y
And manually editing .config to change all options to "is not set" didn't work either. After running "make", these options would be enabled automatically. How can I disable CONFIG_PM and CONFIG_PM_SLEEP?
I used the following from the top level of my kernel source:
find . -name Kconfig -exec grep -H 'select PM$' {} \;
which, unless you are running on arm/mach, finds only kernel/power/Kconfig. PM will be forced on only if you turn on PM_SLEEP. Otherwise, turning off PM turns off all power management.
Edit: Note that PM_SLEEP has "def_bool y" This means that unless explicitly set, it will be turned on. To turn it off, change .config to:
CONFIG_PM_SLEEP=n
Note that this means the developers are pretty sure they want this on all the time, so the code isn't being tested with it off. You will be on your own to find and fix bugs that may result from turning it off.

XKB_DEFAULT_OPTIONS=grp:shift_caps_switch with more than two keyboard layouts

This option if set allows me to switch to first (us) and second (ru) layouts by simply pressing CapsLock and Shift+CapsLock respectively.
I'm happy with that behavior, since it's very ergonomic and distraction-free.
However, additionally I need third (pl) and fourth (ua) layouts, and looks like there's no predefined shortcut for them, nor any (documented?) option to enable it.
I don't want to change CapsLock → us, Shift+CapsLock → ru, behavior, ideally Ctrl+CapsLock shortcut should cycle between secondary (pl and ua) layouts.
What's the best way to bind it?
Finally, I've switched to sway WM and got a proper setup with the following config:
input "1:1:AT_Translated_Set_2_keyboard" {
xkb_options caps:none,shift:both_capslock,compose:ralt
xkb_layout us
xkb_numlock enabled
}
bindcode Ctrl+Shift+66 \
input "1:1:AT_Translated_Set_2_keyboard" xkb_layout ua; \
input "1:1:AT_Translated_Set_2_keyboard" xkb_options caps:none,shift:both_capslock,compose:ralt
bindcode Shift+66 \
input "1:1:AT_Translated_Set_2_keyboard" xkb_layout ru; \
input "1:1:AT_Translated_Set_2_keyboard" xkb_options caps:none,shift:both_capslock,compose:ralt
bindcode Ctrl+66 \
input "1:1:AT_Translated_Set_2_keyboard" xkb_layout pl; \
input "1:1:AT_Translated_Set_2_keyboard" xkb_options caps:none,shift:both_capslock,lv3:ralt_switch_multikey
bindcode 66 \
input "1:1:AT_Translated_Set_2_keyboard" xkb_layout us; \
input "1:1:AT_Translated_Set_2_keyboard" xkb_options caps:none,shift:both_capslock,compose:ralt
Here, I've disabled primary CapsLock, so it started to emit 66 keycode which then I've bound to combinations with other keys to corresponding keyboard layouts.
Also, xkb_options are set alongside just to bind RightAlt as compose key on ua, ru, us and as lv3 symbols access key on pl layout.
CapsLock functionality is still accessible with shift:both_capslock option.
I believe you are looking for the toggle option.
XKB_DEFAULT_OPTIONS=grp:shift_caps_toggle
You could also pass this to the setxkb command
setxkbmap -rules xorg -model $model -layout "us,ru,pl,ua" \
-option "grp:shift_caps_toggle"
The documentation is rather spotty but you could use the xorg documentation or source description.
Admittedly as mentioned in the comments this is less than ideal, however setting two keygroups should be trivial.
# This is the primary set
setxkbmap -rules xorg -model $model -layout "us,ru" \
-option "grp:shift_caps_toggle"
# This is the secondary
setxkbmap -rules xorg -model $model -layout "pl,ua" \
-option "grp:ctrl_caps_toggle"

tilde key not working in Fedora Linux on Macbook Air

I am pretty much brand new to Linux and command line. I am trying to learn the commands and I got to a section that needed the ~ key. When I am using Fedora, the ~` key types ><. I have tried searching for this and I cannot find the answer. I have attempted many different fixes that I have found across multiple sites and the issue isn't resolved. Any help is greatly appreciated!
I am using an American English Macbook Air, 13-inch mid 2013, model 6,2
Finally found the answer from this post:
https://superuser.com/a/622365
# clear all options
setxkbmap -model "pc105" -layout "hr,us" -option ""
# set the Apple keyboard
setxkbmap -rules "evdev" -model "pc105" -layout "hr,us" -option "terminate:ctrl_alt_bksp,lv3:rwin_switch,grp:shifts_toggle,caps:ctrl_modifier,altwin:swap_lalt_lwin"
# swap the grave-tilde with less-greater key
# - variant without dead keys
xmodmap -e "keycode 94 = grave asciitilde"
xmodmap -e "keycode 49 = less greater less greater bar brokenbar bar brokenbar"

Use backtick/Grave/Tilde as modifier key

I'm looking for a way to create keyboard shortcuts in Linux using backtick (`) / tilde (~) key and some other key. In an ideal case:
pressing tilde down does nothing
pressing another key while the tilde is pressed down triggers a (customizable) shortcut
when releasing the tilde before/without pressing another key, just send the tilde keystroke.
I have something similar in AutoHotKey for Windows, and i've been searching for a way to recreate this in a (any) Linux environment. I would consider using any GUI if i could get this working, but of course a more "general" solution would be even better.
I think i finally got it!!
I use xmodmap to turn the grave key into the modifier Hyper_L, and XCape to send the grave if the key is released without another key being pressed.
Xcape was intended to open the app menu ("Start menu") when the meta-key ("windows key") is pressed and released without another key, so as an added bonus, it does that too. Meaning you can both use Meta as a modifier, like Meta-F to open the file manager AND use the meta-key seperately to open the whiskers menu.
If all is right, you can open the keyboard settings manager using ~-k, and you can make new shortcuts using the ~-key. Because that's still tiresome and not easily portable between different systems, i've included some shortcuts using xfconf-query, which will probably only work in Xfce.
Here's the basics of my script:
#!/bin/sh
# reset pretty much ALL keyboard settings
setxkbmap
# Free up the mod3 and mod4 flags from all keys it may be associated with:
xmodmap -e "clear mod3"
xmodmap -e "clear mod4"
# Add Hyper_L to the grave key (49)
xmodmap -e "keycode 49 = Hyper_L asciitilde grave asciitilde"
# You need a grave key somewhere else (!) so, bind it to an unused key:
xmodmap -e "keycode 250 = grave"
# Restore Mod4 but without Hyper_L (which was at location 4)
xmodmap -e "add mod4 = Super_L Super_R Super_L"
# Assign the mod3 to Hyper_L:
xmodmap -e "add mod3 = Hyper_L"
dist=100
/usr/bin/xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/\<Hyper\>Right -s "xdotool mousemove_relative -- $dist 0" --create -t string
/usr/bin/xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/\<Hyper\>Down -s "xdotool mousemove_relative -- 0 $dist" --create -t string
/usr/bin/xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/\<Hyper\>Left -s "xdotool mousemove_relative -- -$dist 0" --create -t string
/usr/bin/xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/\<Hyper\>Up -s "xdotool mousemove_relative -- 0 -$dist" --create -t string
/usr/bin/xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/\<Hyper\>space -s "xdotool click 1" --create -t string
/usr/bin/xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/\<Hyper\>k -s "xfce4-keyboard-settings" --create -t string
# (re)starting xcape to produce a ` after key-up if no other key was pressed
killall xcape
xcape -t5000 -e "#49=grave;Super_L=Control_L|Escape" &
A more extended version of the script, with some more shortcuts can be found here.
I am not sure if it will work out for you but you should check:
xdotool (http://manpages.ubuntu.com/manpages/precise/man1/xdotool.1.html)
zenity (http://manpages.ubuntu.com/manpages/precise/man1/zenity.1.html)
Both these tools let you create some custom actions and shortcuts.
Here is an example of xdotool: https://askubuntu.com/questions/212154/create-a-custom-shortcut-that-types-clipboard-contents
Hope it helps and good luck :)
Bruno
After switching to Ubuntu on another machine, I also wanted to use tilde as a modifier key the way I use it in my AHK scripts.
I did quite some research on different tools for ex. xdotool, xev, autotools, xbindkeys and so on and finally found a solution to that. Here are the steps.
Install Autokey, python, python evded module, xte(sudo apt-get install xautomation).
Read a little about Autokey and how it launches python scripts or create hotstrings. In Autokey, we can set a hotkey to call a python script. So you can assign the python script down below to your tilde key or for that matter whatever custom hotkey you plan to create.
Here is the required custom functionality(thought not yet completely ported to linux, I have it scripted in autohotkey and just love it. It keeps the hand glued to keyboard ;))
Tilde + Up arrow: Move mouse pointer upwards by 100 positions
Tilde + Down arrow: Move mouse pointer downwards by 100 positions
Tilde + Right arrow: Move mouse pointer to right by 100 positions
Tilde + Left arrow: Move mouse pointer to left by 100 positions
Tilde + Enter: Left Mouse click (not present in the python script)
Tilde + Alt + Enter: Right Mouse Click
I use the tilde (KEY_GRAVE) as my modifier key. When this key is pressed, Autokey launches the python script. The scripts runs a loop until the tilde key is released. In the loop, the script keeps on detecting the keyboard inputs. On a UP arrow key(KEY_UP) press, the script sends a command to move a mouse by relative position (0, -100) utilizing 'xte' and so on.
from evdev import InputDevice, categorize, ecodes
from select import select
dev = InputDevice('/dev/input/event4')
releasekey = False
while releasekey==False:
r,w,x = select([dev], [], [])
for event in dev.read():
if event.type == ecodes.EV_KEY:
#system.exec_command("xte 'mousermove 0 3'", False)
#break
if event.code == ecodes.KEY_UP:
if event.value == 1:
system.exec_command("xte 'mousermove 0 -100'", False)
if event.code == ecodes.KEY_DOWN:
if event.value == 1:
system.exec_command("xte 'mousermove 0 100'", False)
if event.code == ecodes.KEY_RIGHT:
if event.value == 1:
system.exec_command("xte 'mousermove 100 0'", False)
if event.code == ecodes.KEY_LEFT:
if event.value == 1:
system.exec_command("xte 'mousermove -100 0'", False)
if event.code == ecodes.KEY_GRAVE:
if event.value == 0:
releasekey = True
break
You have to adjust the dev = InputDevice('/dev/input/event4') line to assign the correct name of your keyboard. In my case, event4 is my keyboard. Yours might be different. You can check out the handy tutorial "Reading Events" on python-evdev. That code actually outputs the name of your keyboard listed under /dev/input. Actually, my script is an extention to that tutorial script.
The only problem is that the python script must be started as a root user otherwise the keyboard input device can not be accessed. You can overcome this by creating a udev rule file which changes the permission of the device to make it available for reading writing eg. create a rule file and add this line
KERNEL=='event4', MODE="0660" and load the rule . At the end you must add yourself in the GROUP which have read/write permission for the device. The information regarding file permission can be found using ls -la in the /dev/input folder.
I hope it works for you. In it doesn´t work at first go, then get a cup of coffee and fight on till it works ;)

How do I change bash history completion to complete what's already on the line?

I found a command a couple of months ago that made my bash history auto-complete on what's already on the line when pressing the up arrow:
$ vim fi
Press ↑
$ vim file.py
I'd like to set this up on my new computer, because it saves a lot of time when keeping a big history. The problem is that I can't for the life of me remember where it was mentioned and reading through endless bash references and tutorials unfortunately didn't help either.
Does anybody know the command?
Probably something like
# ~/.inputrc
"\e[A": history-search-backward
"\e[B": history-search-forward
or equivalently,
# ~/.bashrc
if [[ $- == *i* ]]
then
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
fi
(the if statement checks for interactive mode)
Normally, Up and Down are bound to the Readline functions previous-history and next-history respectively. I prefer to bind PgUp/PgDn to these functions, instead of displacing the normal operation of Up/Down.
# ~/.inputrc
"\e[5~": history-search-backward
"\e[6~": history-search-forward
After you modify ~/.inputrc, restart your shell or use Ctrl+X, Ctrl+R to tell it to re-read ~/.inputrc.
By the way, if you're looking for relevant documentation:
Bash uses The GNU Readline Library for the shell prompt and history.
Update .inputrc with the following:
"\C-[OA": history-search-backward
"\C-[[A": history-search-backward
"\C-[OB": history-search-forward
"\C-[[B": history-search-forward
If set enable-keypad on is in your ~/.inputrc as some st (suckless simple terminal) users might, be aware that the arrows keys are in keypad mode. Ubuntu ships with this useful /usr/share/doc/bash/inputrc.arrows:
# This file controls the behaviour of line input editing for
# programs that use the Gnu Readline library.
#
# Arrow keys in keypad mode
#
"\C-[OD" backward-char
"\C-[OC" forward-char
"\C-[OA" previous-history
"\C-[OB" next-history
#
# Arrow keys in ANSI mode
#
"\C-[[D" backward-char
"\C-[[C" forward-char
"\C-[[A" previous-history
"\C-[[B" next-history
#
# Arrow keys in 8 bit keypad mode
#
"\C-M-OD" backward-char
"\C-M-OC" forward-char
"\C-M-OA" previous-history
"\C-M-OB" next-history
#
# Arrow keys in 8 bit ANSI mode
#
"\C-M-[D" backward-char
"\C-M-[C" forward-char
"\C-M-[A" previous-history
"\C-M-[B" next-history
So I'm not sure if you'll need all, but it might not hurt to have in your ~/.inputrc:
# Arrow keys in keypad mode
"\C-[OA": history-search-backward
"\C-[OB": history-search-forward
"\C-[OC": forward-char
"\C-[OD": backward-char
# Arrow keys in ANSI mode
"\C-[[A": history-search-backward
"\C-[[B": history-search-forward
"\C-[[C": forward-char
"\C-[[D": backward-char
This is also on the same topic: My cursor keys do not work and also this xterm: special keys
With ohmyzsh, use this in your .zshrc :
bindkey '\e[A' history-search-backward
bindkey '\e[B' history-search-forward
To reload, source ~/.zshrc or relaunch terminal.
Source: https://superuser.com/a/418299/71680
You may need to enabled bash completion.
Check
/etc/profile
/etc/bash.bashrc
~/.bashrc
to see if any of the above files source /etc/bash_completion. i.e.
. /etc/bash_completion
If /etc/bash___completion is not sourced by any of the above files you will need to add it to one of them.
If you want all bash users on your machine to have bash completion, source /etc/bash_completion from /etc/bash.bashrc.
If it's just you who wants bash completion, source /etc/bash_completion from your ~/.bashrc.

Resources