Using NetworkManager in Gentoo Linux
Planet Larry is an aggregation of blogs written by users of Gentoo Linux. This is similar to Planet Gentoo, except it is by and for users rather than developers. If you use Gentoo Linux, feel free to contact me and add your own blog.
, 16/02/2021 | Source: Hund
It’s easy to take a lot of things for granted when you’ve been using them for longer than you can remember. Coloured manual pages is one of those things.
By default, there’s no colours for the manual pages, which can make it more difficult to distinguish parts and sections of the documentation than it has to be.
If you want to put some colours on your own manual pages; simply add this to your configuration file for your shell:
man() {
env LESS_TERMCAP_mb=$'\E[01;31m' \
LESS_TERMCAP_md=$'\E[01;33;5;74m' \
LESS_TERMCAP_me=$'\E[0m' \
LESS_TERMCAP_se=$'\E[0m' \
LESS_TERMCAP_so=$'\E[38;5;246m' \
LESS_TERMCAP_ue=$'\E[0m' \
LESS_TERMCAP_us=$'\E[04;39;5;146m' \
man "$@"
}
If you want to change the colour of the yellow text, you have to change the value 33
on line 3 and if you want to change the cyan colour, you then have to change the value 36
on line 8.
Here are the codes if you haven’t memorised them:
Colour | Code |
---|---|
Black | 30 |
Red | 31 |
Green | 32 |
Yellow | 33 |
Blue | 34 |
Purple | 35 |
Cyan | 36 |
Light Gray | 37 |
, 12/02/2021 | Source: Hund
I often read my plain text documents using cat
. For the most part that works just fine, but for some larger documents—especially documents with documentation that contains a lot of headers, lists and folds—it can be somewhat difficult to read the document.
That’s why I’m using Supercat for things like this. It works just like cat
(hence the name), but it also supports colours using regular expressions.
The markers “{{{” and “}}}” are Neovim folds. I can’t imagine living without folds. I use them all the time, even though they do make the file ‘cluttery’ to read with any other standard tool.
It should be noted that this works with a pager as well. If the document is really large, I will page it to less
.
Supercat works by specifying a configuration file and the file you want to print:
$ spc -c ~/.config/supercat/markdown.conf demo.md
My configuration file for my Markdown documents looks like this:
# spc configuration file
#
# col - color (blk, red, grn, yel, blu, mag, cya, whi)
#
# a - color attribute (console_code)
# ' ':normal (0)
# '-':normal (0)
# 'b':bold (1)
# 'u':underline (4)
# 'r':reverse-video (7)
# 'k':blink (5)
#
# n - number of matches, (' ':1, '1'-'9':1-9, '0':all)
#
# t - pattern type
# 'c':chars (strchr)
# 's':string (strstr)
# 't':regexp (regcomp) (convert 10-digit unix time to MMDDHHMMSS)
# 'r':regexp (regcomp)
# ' ':regexp (regcomp)
#
# col a n t pattern
#################### ### # # # ########################################
H1 red 1 (^#\s.*$)
H2 yel 1 (^##\s.*$)
H3 yel 1 (^###\s.*$)
H4 yel 1 (^####\s.*$)
Header red 1 (^---.*$)
Fold blk 1 (# \}\}\})
Fold blk 1 (\}\}\})
Fold blk 1 (\{\{\{)
List blu 1 (^\s*\*)
It only supports headers, lists and folds, which is all that I use for formatting my plaintext documents.
, 04/02/2021 | Source: Hund
I recently wrote about wtwitch (a CLI-client for Twitch) and while it’s a really good client, I was missing the ability to launch the streams via Rofi like I used to be able to do in the past with Twitchy.
That’s why I adapted my current Rofi script for wtwitch instead of Twitchy:
And here’s the script itself:
#!/bin/bash
handle_selection() {
if [[ $1 ]]; then
name=$(echo $1 | awk {'print $1'} | sed 's/\://')
notify-send "wtwitch" "Launching the livestream with $name"
streamlink https://twitch.tv/$name --title "{author}: {title} ({category})"
else
exit 1
fi
}
handle_selection "$( wtwitch check | sed -n '/Live/,/Settings/p' | sed '/Live channels/d;/Settings/d' | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g;s/ //;' | rofi -font "xos4terminus 12" -bw 3 -dmenu -i -p 'wtwitch' )"
The only thing it’s missing is the current online time of the channels, but that’s a limitation of wtwitch and not my script.
And I know, I haven’t made a post about Rofi itself yet. I’ve been using it for years now, perhaps it’s time for it soon.
, 03/02/2021 | Source: Hund
I was recently made aware of doas, a simplified and lightweight alternative to sudo, which are two utilities to execute commands as another user. The most common use case for these utilities is to execute commands as the “super user” also known as the root user.
doas was originally written for OpenBSD, but are now ported to Linux, FreeBSD, NetBSD and illumos.
In terms of disk usage, the binary file for doas is about four times smaller than sudo on my computer with Gentoo and about 27 (!) times smaller on my computer with Alpine Linux (1216 KiB vs 44 KiB).
When it comes to the configuration, I would say it’s a bit more straightforward, but not enough to be a dealbreaker. In terms of functionality, it seems like doas have some features that sudo is currently lacking, like denying a user access to a specific command.
To allow all users in the wheel
group to gain access to root, add this to the configuration file /etc/doas.conf
:
permit :wheel
Allow a user to execute a command without entering the password:
permit nopass <user> cmd <command>
Deny users access to commands (even if they’re in the wheel
group):
deny <user> cmd <command>
, 29/01/2021 | Source: Hund
I recently wrote about my new Twitch client wtwitch. It’s been a good replacement for my previous client Twitchy (which has been abandoned and stopped working last year), but there has been one thing that I’ve been missing from my previous client, and that’s the ability to count and print the online channels.
With twitchy it was as easy as:
$ twitchy --non-interactive | wc -l
I used this command to display the online channels in Polybar like this:
[module/twitch]
inherit = script/defaults
exec = twitchy --non-interactive | wc -l
format-prefix = " "
format-prefix-foreground = ${colors.magenta}
And this is what it looks like:
This is also possible with wtwitch, even though it doesn’t support it, I just had to use a few tools to get around it:
$ wtwitch check | sed -n '/Live/,/Settings/p' | sed '/Live channels/d;/Settings/d' | head -n -1 | wc -l