Tagged: icewm emacs
- This topic has 11 replies, 3 voices, and was last updated Apr 13-11:55 am by Brian Masinick.
-
AuthorPosts
-
April 11, 2023 at 4:28 am #104518Member
bci
@bobc:
BCI, If you have question, its much better to create your own thread rather than risk confusing the op of another thread who is getting all kinds of irrelevant replies to his post.
I think I see your point. I think I was getting a little too comfy in that thread. š
To address a point you make in your post, I didn’t have any questions per se; I was merely following up on a series of comments made by another forum member ( @masinick).
I assume this particular section of the forum is an appropriate place to leave general comments of a technical, but somewhat conversational and open-ended nature.
Emacs is a terminal based app, and therefore how it acts will be affected by what terminal you are using and how its configured…
Precisely for this reason I dislike terminal based editors; at least I don’t rely on them heavily. I always use Emacs as a GUI application (what in Debian is known as emacs-gtk), and it’s recommended to use it as such. To quote the end of that article,
Live in the blissful world of 16.7 million colors, different font sizes, and infinite key bindings. Live in the GUI, forever.
I’ve included a screenshot of GUI Emacs running on my own system, so you can see it in (at least some of) its glory š
…as well as the window manager, and anything else running (like clip for example).
Yep, this (the window manager thing) indeed is an issue. As for xclip (I think that’s what you meant?), I think it’s an awesome program, but I haven’t really needed it recently.
You can use grep on the keys file, and separately on the preferences overlaid by prefoverride, then combined to make a complete list of IceWM keys.
If you add the ones from the terminal you are using, you could then match them up with a similar list from emacs to find the conflicts.
Its your system, so you can change what you donāt like to something you do like.Reading this several times over, I actually see what you’re getting at now – basically, compile a list of every single key binding that’s in use by everything. I’ll definitely keep that idea in mind, thanks!
- This topic was modified 3 weeks, 1 day ago by bci. Reason: enforce "syntax highlighting" for @-mention
- This topic was modified 3 weeks, 1 day ago by bci. Reason: add attachment
Attachments:
April 11, 2023 at 6:57 am #104522ModeratorBobC
::You could try this:
#!/bin/bash echo 'icekeys - lists key mapping of IceWM' echo > $HOME/.icewm/icekeys.txt echo 'IceWM - Keyboard Shortcut from keys' >> $HOME/.icewm/icekeys.txt cat $HOME/.icewm/keys | sed -e '/^#key /Id' | sed -e '/^###/d' | sed -e 's/^key //Ig' | sed -e 's/\"//g' >> $HOME/.icewm/icekeys.txt echo >> $HOME/.icewm/icekeys.txt echo 'IceWM - Keyboard Shortcuts from preferoverride' >> $HOME/.icewm/icekeys.txt cat $HOME/.icewm/prefoverride | grep -e '^Key' | sed -e 's/Key//g' | sed -e 's/\"//g' | sed -e 's/\=/ /g' >> $HOME/.icewm/icekeys.txt echo >> $HOME/.icewm/icekeys.txt echo 'IceWM - Keyboard Shortcuts from Preferences' >> $HOME/.icewm/icekeys.txt cat $HOME/.icewm/preferences | grep -e '^Key' | sed -e 's/Key//g' | sed -e 's/\"//g' | sed -e 's/\=/ /g' >> $HOME/.icewm/icekeys.txt echo >> $HOME/.icewm/icekeys.txt echo 'New icekeys.txt follows:' cat $HOME/.icewm/icekeys.txtApril 11, 2023 at 11:45 am #104527ModeratorBobC
::So, maybe emacs has a configuration file with keyboard mapping that you could match up to the results above to identify the conflicts and come up with mapping you like.
April 11, 2023 at 12:17 pm #104530Moderator
Brian Masinick
::Both Emacs and IceWM are rich in the ability to modify resources through text configuration files. I’ve never had a problem with either of them but at least for me it’s trivial to change a few values when conflicts exist,
--
Brian MasinickApril 12, 2023 at 5:02 am #104569Memberbci
::I decided to use this. Tell me what you think.
#!/bin/bash dir="$HOME"/.icewm output="$dir"/icekeys.txt echo "" > $output for file in "$dir"/{keys,preferences,prefoverride} ; do if [[ -a $file ]] ; then echo -e "\nInformation in " | tee -a $output echo $(basename $file) | tee -a $output grep -vE '^$' $file | grep -vE '^#' | tee -a $output fi doneThe file-existence check is there because I don’t have prefoverride in my current (core) installation, but I wanted to preserve the generality of the solution. I’ll admit this is a pretty good approach to finding active IceWM keybindings. (I’m still paranoid that the source contains some irreplaceable definitions, though; I’ll see about that later.)
So, maybe emacs has a configuration file with keyboard mapping that you could match up to the results above to identify the conflicts and come up with mapping you like.
In Emacs, keybindings are largely organized by the text-editing modes you use. In general, though, documentation for a keybinding (and, as a corollary, checking whether a given keybinding even exists), is always a Ctrl+h c or Ctrl+h k away. That’s one thing I love about Emacs, and what’s kept me using it ever since: it’s very heavily self-documenting, and in general places a huge emphasis on good and thorough documentation.
For one, its built-in Info reader is fantastic, and it’s what I used to review grep and Bash for-loop syntax for the script above.
Tee? M-x man RET tee.So, unlike IceWM, Emacs doesn’t have one or several flat files where a whole bunch of keys are bound (or maybe it does in some obscure part of its source code, but it actually is never, and I mean never, necessary to tweak directly.)
Both Emacs and IceWM are rich in the ability to modify resources through text configuration files. Iāve never had a problem with either of them but at least for me itās trivial to change a few values when conflicts exist.
Indeed. Maybe I was too lazy at the time to attack the problem directly and with sufficient energy, and had just given up. I’m close to having a good core installation of IceWM, though I notice the ‘icewmbg’ program is missing. Is this intentional (because AntiX has its own way of setting the wallpaper)?
April 12, 2023 at 8:21 am #104580ModeratorBobC
::I admit yours looks prettier but it doesn’t work to do what I was trying to do. I’m talking about the fancy loop. You didn’t allow for the file structures being different, and won’t be able to match up the results. I suppose you could use ifs or a case structure to handle that but the code gets less pretty.
Neither of us allowed for prefoverride possibly overriding entries from preferences.
I did try emacs a couple times, but didn’t like it. I do understand that all of us have our editor preferences and reasons for them. My personal favorite decades ago was Brief because it was so configurable and reasonably easy to program, but it was a long time ago, and my requirements today are very different. I use Geany here, and Notepad++ for Win and the Win servers, as well as for editing the Qshell scripts for the iSeries, but I haven’t been able to really control either via configuration or programming like I was able to with Brief.
I am intrigued by your use of tee, however. I have never gotten that command to work for me. I’ll have to investigate and try using it again.
I have to be a bit extra careful because I work in a Win environment for 75% of my programming time where anything *nix oriented is either frowned upon or outright banned. I try to use syntax that works on GNU Win (at work), IBM iSeries Qshell (at work) and under Linux (at home) so that what I can do for one I can at least apply for any of the others. It drives me nuts when what I expect to work fails when I really need it. I understand that you wouldn’t worry about those other constraints.
PS: I tried your tee method on linux and it worked here. I’ll have to try it on my other systems…
I cleaned up my code and used shellcheck on it. Its a program to help write better code.
#!/bin/bash echo 'icekeys - lists key mapping of IceWM' echo > "$HOME"/.icewm/icekeys.txt echo 'IceWM - Keyboard Shortcut from keys' >> "$HOME"/.icewm/icekeys.txt sed -e '/^#key /Id' "$HOME"/.icewm/keys | sed -e '/^###/d' | sed -e 's/^key //Ig' | sed -e 's/\"//g' >> "$HOME"/.icewm/icekeys.txt echo >> "$HOME"/.icewm/icekeys.txt echo 'IceWM - Keyboard Shortcuts from preferoverride' >> "$HOME"/.icewm/icekeys.txt grep -e '^Key' "$HOME"/.icewm/prefoverride | sed -e 's/Key//g' | sed -e 's/\"//g' | sed -e 's/\=/ /g' >> "$HOME"/.icewm/icekeys.txt echo >> "$HOME"/.icewm/icekeys.txt echo 'IceWM - Keyboard Shortcuts from Preferences' >> "$HOME"/.icewm/icekeys.txt grep -e '^Key' "$HOME"/.icewm/preferences | sed -e 's/Key//g' | sed -e 's/\"//g' | sed -e 's/\=/ /g' >> "$HOME"/.icewm/icekeys.txt echo >> "$HOME"/.icewm/icekeys.txt echo 'New icekeys.txt follows:' cat "$HOME"/.icewm/icekeys.txt- This reply was modified 3 weeks ago by BobC.
- This reply was modified 2 weeks, 6 days ago by BobC.
April 12, 2023 at 2:17 pm #104594Memberbci
::I copy-pasted your version on it, ran it, and also ran shellcheck on it. Shellcheck suggested that I “consider using { cmd1; cmd2; } >> file instead of individual redirects”, and so I did just that (keeping your original grep and sed invocations):
#!/bin/bash output="$HOME"/.icewm/bobc-icekeys.txt echo 'icekeys - lists key mapping of IceWM' echo > "$output" { echo 'IceWM - Keyboard Shortcut from keys' sed -e '/^#key /Id' "$HOME"/.icewm/keys | sed -e '/^###/d' | sed -e 's/^key //Ig' | sed -e 's/\"//g' echo echo 'IceWM - Keyboard Shortcuts from prefoverride' grep -e '^Key' "$HOME"/.icewm/prefoverride | sed -e 's/Key//g' | sed -e 's/\"//g' | sed -e 's/\=/ /g' echo echo 'IceWM - Keyboard Shortcuts from Preferences' grep -e '^Key' "$HOME"/.icewm/preferences | sed -e 's/Key//g' | sed -e 's/\"//g' | sed -e 's/\=/ /g' } | tee "$output"When I run this, I get (both stdout and contents of output file):
IceWM – Keyboard Shortcut from keys
# This is an example for icewm hotkey definition file.
# It will be installed as /usr/share/icewm/keys.
# Place your variants in /etc/X11/icewm or in $HOME/.icewm since
# modifications to this file will be overwritten when you reinstall icewm.
#
# A list of all valid keyboard symbols can be found in
# /usr/include/X11/keysym.h, keysymdefs.h, XF86keysym.h, …
# You’ll have to omit XK_ prefixs and to replace XF86XK_ prefixes by
# XF86. Valid modifiers are Alt, Ctrl, Shift, Meta, Super and Hyper.
#
Alt+Ctrl+t x-terminal-emulator
Alt+Ctrl+b xdg-open about:blank
Alt+Ctrl+s xdg-open https://www.google.comSuper+KP_Subtract amixer sset Master 5%-
Super+KP_Add amixer sset Master 5%+# Multimedia key bindings for Xorg. Gather the keycodes of your
# advanced function keys by watching the output of the xev command whilest
# pressing those keys and map those symbols by using xmodmap.# Note: some of them might have unwanted side effects through concurrency with
# other listeners like systemd for the suspend key events
#
# key XF86Standby /bin/sh -c { test -e /run/systemd/system && systemctl suspend; } ||:
# key XF86Sleep /bin/sh -c { test -e /run/systemd/system && systemctl suspend; } ||:
XF86AudioLowerVolume amixer sset Master 5%-
XF86AudioRaiseVolume amixer sset Master 5%+
XF86AudioMute amixer sset Master toggle
XF86HomePage xdg-open about:blank
XF86Search xdg-open https://www.google.com
XF86Eject eject
XF86Calculator /bin/sh -c gnome-calculator || xcalc || ( type bc >/dev/null 2>&1 && x-terminal-emulator -e bc -l)switchkey Super+p icewm-menu-xrandr
IceWM – Keyboard Shortcuts from preferoverride
IceWM – Keyboard Shortcuts from Preferences
SysWorkspacePrevIn Preferences: I’ve erased (via Settings > Preferences) the keybinding for Ctrl+Alt+LeftArrow, and so ‘KeySysWorkspacePrev’ is being assigned the empty string. Since the sed invocation erases the ‘=’ and quotes, nothing is left! Also, it looks like the ‘Key’ prefix is lopped off, I’m assuming that’s intentional though. Everything else looks straightforward.
So, all in all, not bad. Also, I’m kind of rusty with Bash, and so I had forgotten that ‘echo’ by itself prints a newline. š
- This reply was modified 2 weeks, 6 days ago by bci. Reason: Add comment about 'echo'
April 12, 2023 at 2:30 pm #104596Moderator
Brian Masinick
::The “online” Emacs manual has all kinds of ideas about ways you can use and customize any part of it.
A long lasting joke has been it’s the “Emacs operating system”. Emacs Lisp, in reality, wouldn’t be
the fastest way to “run” an operating system, but who knows, if anyone ever created a cached, optimized
version of Emacs Lisp or anything close to it, the language itself is very good for character, word,
and string manipulation, and another good thing about it is that Richard Stallman is as much against
private exploitation as anyone I’ve ever seen. In his mind, while it’s OK to make money from software
efforts, it should always be permissible and encouraged to share, reuse, and rewrite any code, as
long as any previous works are properly mentioned and cited.Here’s one useful section for customization:
49.4 The Emacs Initialization File
==================================When Emacs is started, it normally tries to load a Lisp program from an
āinitialization fileā, or āinit fileā for short. This file, if it
exists, specifies how to initialize Emacs for you. Traditionally, file
ā~/.emacsā is used as the init file, although Emacs also looks at
ā~/.emacs.elā, ā~/.emacs.d/init.elā, ā~/.config/emacs/init.elā, or other
locations. *Note Find Init::.--
Brian MasinickApril 12, 2023 at 2:44 pm #104599Moderator
Brian Masinick
::As far as preferoverride goes, I’m sure there are use cases where this is helpful, but for every day use, I prefer to assign all of my desired preferences in a file with that name: preferences, which, as we’ve been discussing, is located in ~/.icewm for personal configurations.
Between that file and ~/.emacs, it ought to be possible to put together some stuff that avoids conflicts, but also results in only a few changes.
On the other hand, both are quite customizable; you can make either one behave however you wish; the only issue with that is that if you want any kind of consistency across systems, if you DO run more than one system, then you have to carry them around. No big deal; I’ve been saving files like .kshrc, .bashrc, .profile, and .emacs for at least 25 years when I still used UNIX servers; I did as much as I could to be able to carry them around, as long as I could somehow bring them to my employer; if not, at least I’d have my own, and I STILL have them!--
Brian MasinickApril 12, 2023 at 2:45 pm #104600Moderator
Brian Masinick
::toolbar, preferences, etc. from IceWM I haven’t carried around as much, but they’re pretty easy to obtain and modify.
--
Brian MasinickApril 13, 2023 at 3:14 am #104642ModeratorBobC
::Yes, that last one looks reasonably readable and less code.
I tried the tee on my iSeries and Win/10 and Win servers and it worked there too. Thanks for the tip.
April 13, 2023 at 11:55 am #104650Moderator
Brian Masinick
::Tee can be a handy command. While I don’t use it often, when I need it this classic command is useful, particularly in short scripts.
--
Brian Masinick -
AuthorPosts
- You must be logged in to reply to this topic.
