diff options
| Commit | 6372141c6e09825e15dbdde96611194760fa16d5 (patch) | |
|---|---|---|
| Author | 2023-03-28 15:01:05 +0300 | |
| Committer | 2023-03-28 15:01:05 +0300 | |
| Files | 4066e94ce33c743d336e9c0ee7934dde066cc0e0 | |
| syndamia.com-6372141c6e09825e15dbdde96611194760fa16d5.tar syndamia.com-6372141c6e09825e15dbdde96611194760fa16d5.tar.gz syndamia.com-6372141c6e09825e15dbdde96611194760fa16d5.zip | ||
| Parent | 3a1f63f42ba18421c0f11b07bed6e760f1636857 (diff) | |
[blog/p9ilmm] Added bash info to code blocks
1 files changed, 8 insertions, 8 deletions
| -rw-r--r-- | src/blog/plan9-in-linux-mouse-menus/index.md | 16 |
diff --git a/src/blog/plan9-in-linux-mouse-menus/index.md b/src/blog/plan9-in-linux-mouse-menus/index.md index ec33709..a231a4a 100644 --- a/src/blog/plan9-in-linux-mouse-menus/index.md +++ b/src/blog/plan9-in-linux-mouse-menus/index.md @@ -141,7 +141,7 @@ Getting the current selection turns out to be easy, X11's selections (clipboard) As for getting it inside our script, [xclip](https://github.com/astrand/xclip) is a perfect choice. In the very beginning, we'll just store the selection in a variable and work from there: -``` +```bash selection="$(xclip -o)" ``` @@ -193,7 +193,7 @@ More info on these options can be found in the [manpage](https://jgmenu.github.i Putting it all together, it looks something like this: -``` +```bash action=$(echo -ne "Send,echo 1\nResize,echo 2\nMove,echo 3\n" | jgmenu --at-pointer --simple --config-file="$HOME/.config/jgmenu/jgmenusimplerc") case "$action" in @@ -218,7 +218,7 @@ My preferred way is to have a variable `menu` to which different options are app To work with regular expressions more easily, I've made a function which returns a status code depending on matching. All in all, it would look something like this: -``` +```bash menu="" windowOptions=0 @@ -247,7 +247,7 @@ However, the script is ran completely independently from the current program, so This problem was solved somewhat by Luke Smith, he figured out a way to find (and `cd` into) the current directory of the active window (`pid1` should be `pid`, but you'll see later why I did that change): -``` +```bash pid=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3) pid1=$(pstree -lpA "$pid" | tail -n 1 | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g') cd "$(readlink /proc/"$pid1"/cwd)" @@ -269,7 +269,7 @@ I use zsh, so I implemented it by creating a zsh widget: certain functionality t Examples include key binds, completion, navigation through history, undo and redo. User-defined widgets are just zsh functions, so we create a function that stores the current directory, add it as a widget and bind it to our keyboard combination[^escape-sequences]: -``` +```bash plumb-store-cwd () { pwd > /tmp/plumb-cwd } @@ -279,7 +279,7 @@ bindkey "^[[5;7~" plumb-store-cwd # Ctrl+Alt+Page_Up Finally, in our script, we want to read that file, only if we're inside a terminal: -``` +```bash wname="$(cat /proc/"$pid"/comm)" if [ $wname == "TERMINAL" ]; then # Replace with your terminal emulator name xdotool key Control+Alt+Page_Up # Execute the shell-compatible combination @@ -295,7 +295,7 @@ For the uninitiated, [xdotool](https://github.com/jordansissel/xdotool) is a gen Sending the command to the current shell is by far the simplest action. `xdotool` supports "typing out" text, so I'll give it the selection and let it do it's thing: -``` +```bash xdotool type --delay 0 "$selection" ``` @@ -307,7 +307,7 @@ Sadly I couldn't figure out how to do anything like that. As promised, I won't dive into it too much, but the easiest way to implement window management actions is via another dirty hack: sending key presses that make the window manager do something. For example, normally resizing is done via Alt+RightClick, so I'll just do this: -``` +```bash xdotool keydown Alt xdotool mousedown 3 xdotool keyup Alt |