serhii.net

In the middle of the desert you can say anything you want

24 May 2021

Day 874

i3status VPN

My older approach was to use this:

run_watch VPN {
        pidfile = "/etc/openvpn/mv.pid"
}

And start openvpn in a way that it writes that specific pid file.

i3: i3status(1)’s documentation points at this:

path_exists VPN {
        # path exists when a VPN tunnel launched by nmcli/nm-applet is active
        path = "/proc/sys/net/ipv4/conf/tun0"
}

On my computer it was tap0 instead of tun0. But it works!

stow symlinks/targets

My ~/.dotfiles is a symlink to another place. stow follows it, and uses as target the parent directory of the directory the symlink points to, not ~/!

Explicitly setting a target directory is stow -t ~/ thing-to-stow (interestingly, stow -t ../ also uses the parent directory relative to the symlink target of the current one).

First I did the logical thing:

alias st='stow -t ~/'

Then, after reading the manual1, created a ~/.stowrc:

--target=~/

Works now :)

Wallabag tagging rules

Wallabag supports tagging rules based on parameters, such as domain names or reading time. Nice!

qutebrowser wallabag bookmarklet

Added ww as binding to the bookmarklet.

Fiamma qutebrowser-specific vimrc

I finally moved Fiamma (my link wiki) to a the new server! Which reminded me about the bindings I wrote to automatically format the input for the links I add there.

For example, on Ron Burk: Commas Depend on Linebreaks - Fiamma, I edited the pre-filled things to look like this:

http://ronburk.blogspot.de/2009/09/commas-depend-on-linebreaks.html
Ron Burk: Commas Depend on Linebreaks
6
5

language, linguistics, internet, style, etiquette, mildly interesting

Language
Style

Then a vim snippet from hell transformed it to

{{B|
http://ronburk.blogspot.de/2009/09/commas-depend-on-linebreaks.html
|Ron Burk: Commas Depend on Linebreaks
|6
|5
}}
{{#set:
k=language, linguistics, internet, style, etiquette, mildly interesting
|+sep=, }}

[[Category: Language]]
[[Category: Style]]

Though they were in latin-1 encoding, the .vimrc got converted to utf8, and it all got lost.

Now I have a solution. ~/.config/qutebrowser/.qb-vimrc is:

source ~/.vimrc

" let @H = 'gg<80>ýc<80>ýbi<80>ýc<80>ýb{{B|^[^[^[j0i|^[^[^[ji|j<80>kb^[^[^[ji|^[^[^[o}};q' " For the 5 lines
" let @L = 'ji{{$<80>kb%<80>kb#set:\^Mk=<80>kD^[o|+sep=,}}^[' " For the tags
" let @C = 'i[[C;tj<80>kb<80>kb<80>kbategory: ^[^[^[A]];q' " For each individual category
" let @F = 'jjVG:norm! @C\^M' "Apply that to all lines till the end
" let @d = '@H@L@F'
" let @q = '^[A^[bbbbbbi|<80>ü^B<80>kb^[:%s/=/{{=}}/ge^M'

" Summed up:
let @C = 'i[[C;tj<80>kb<80>kb<80>kbategory: ^[^[^[A]];q' " For each individual category
"let @H = '^[A^[bbbbbbi|<80>ü^B<80>kb^[:%s/=/{{=}}/ge^Mgg<80>ýc<80>ýbi<80>ýc<80>ýb{{B|^[^[^[j0i|^[^[^[ji|j<80>kb^[^[^[ji|^[^[^[o}};qji{{$<80>kb%<80>kb#set:^Mk=<80>kD^[o|+sep=,}}^[jjVG:norm! @C^M:x^M'
let @H = '^[A^[bbbbbbi|<80>ü^B<80>kb^[:%s/=/{{=}}/ge^Mgg<80>ýc<80>ýbi<80>ýc<80>ýb{{B|^[^[^[j0i|^[^[^[ji|j<80>kb^[^[^[ji|^[^[^[o}};qji{{$<80>kb%<80>kb#set:^Mk=<80>kD^[o|+sep=,}}^[jjVG:norm! @C^M' " Without closing at the end
" let @d = '@H@L@F'

" Start in insert mode
startinsert

And in qutebrowser config, I set the editor to:

c.editor.command = ['kitty', 'vim', '-u', str(config.configdir / '.qb-vimrc'), '+{line}', '{file}']

This way, standard-vim uses the standard fancy utf8 config file, but qutebrowser uses a separate one that overwrites the needed lines with the latin-1 macros. vim +10 filename means open it and put the cursor on line 10, idea comes from Reddit[^ideared

(Macros are really hard to read. How can I use something like python next time for this?)

Also - them being defined in the ~/.vimrc seems to have broken the newer ones, had to comment them out. Does vim not like redefined macros?

Updated my yank-for-markdown yank.py userscript to remove the anchor text ("…#!~:text=Text on the page to scroll to"), so I can paste it without it messing up the markdown formatting:

#!/usr/bin/python3
import os

title = os.environ['QUTE_TITLE']
title = title.replace("|", "\\|")

url = os.environ['QUTE_URL']
url = url.split("#:~:")[0]

command = "yank inline \"[{}]({})\"".format(title, url)

with open(os.environ['QUTE_FIFO'], 'w') as f:
    f.write(command)

Better Fiamma page creation with preloading

Rewrote the whole mechanism, now there’s one template that gets pre-filled by URI. First the qb userscript gets the data, writes them to a file; then opens this file in vim. When closed, it calls the new template passing the entire content of the file as first parameter.

Better because much simpler and less steps needed.

Random / quotes

[23:07:35] i mean, i have important work to do. dealing with an IRC network is not really something i want to be doing this decade outside of fucking around for fun with IRCX [23:07:51] i have code running on two planets 2

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus