Posts tagged: linux
All posts with the tag "linux"
gpg setup for kdewallet
Today I discovered brightnessctl to adjust the screen brightness on my
AwesomeWM machine. Its a command line utility that you can use to adjust the
brightness of your screen. A command line interface like this gives you the
ability to bind keys with something like [[xbindkeys]] or your window manager
configuration.
sudo apt install brightnessctl
# or
paru -S brightnessctl
Now that you have it installed you can use it to adjust the brightness of your screen, this worked particularly well for my laptop screen, I don’t think this works for monitors, in my experience they are usually controlled by the built in osd.
# Increase brightness by 10%
brightnessctl set +10%
# Decrease brightness by 10%
brightnessctl set 10%-
# Set brightness to 50%
brightnessctl set 50%
# Set brightness to 100%
brightnessctl set 100%
Note
on my machine I had to use `sudo` to run the command, otherwise I got the following error:
Can't modify brightness: Permission denied
You should run this program with root privileges.
Alternatively, get write permissions for device files.
You can unset multiple environment variables at once. I did not know this was a
thing, its something that ended up happening organically on a call and asking
someone to run unset. They had never done it before and did not know how it
works, but did exactly as I said instead of what I meant. I like this handy
shortcut doing it in one line rather than each one individually, I will be
using this in the future. You might need this for something like
running aws cli commands with localstack.
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION
i3lock is a fantastic lockscreen for tiling window managers.
If you are using a tiling window manager within a public space you need to add a lockscreen. I have one machine that I take with me to a public space. Its secure enough that I can leave it, but not secure enough that I want to leave it unlocked. So when I need to leave it behind for the restroom I need to lock it up.
paru -S i3lock
# or
apt install i3lock
Now that you have i3lock installed lets lock that screen.
# lock it with a pure white flashbang
i3lock
# lock it with a black background
i3lock -c 000000
# lock it with a custom color
i3lock -c 2e1330
# lock it with a wallpaper
i3lock -c 000000 ~/Pictures/Wallpapers/mywallpaper.png
You can use your window manager or something more generic like xbindkeys to set
a hotkey. This way you don’t have to open a terminal and type out the command
every time you leave your desk. You can just press something like SUPER+L
like you would on other OS’s.
Fancy #
If you like it a bit fancier, you can use i3lock-fancy, it can blur,
pixelate, and greyscale your current screen. I did not really like this
because you can still tell what is going on the screen. It’s probably secure
enough and looks better, but I went with regular i3lock.
paru -S i3lock-fancy-git
# or
apt install i3lock-fancy
Linux Is About Choice
backup distrobox image
Using pbpaste for command substitution keeps sensitive or long URLs out of
your shell history. Instead of typing git clone https://github.com/user/repo-with-long-name.git, copy the URL to clipboard and
run git clone "$(pbpaste)". This prevents the URL from appearing in
~/.bash_history or ~/.zsh_history.
To get pbpaste working on both Xorg and Wayland, add this to your shell config:
if [[ $(command -v wl-copy) ]]; then
alias pbcopy='wl-copy'
pbpaste() { wl-paste; }
elif [[ $(command -v xclip) ]]; then
alias pbcopy='xclip -selection clipboard'
pbpaste() { xclip -selection clipboard -o; }
fi
The function approach (instead of alias) enables command substitution, while
the quotes around $(pbpaste) handle spaces and special characters safely.
Now you can use it.
git clone "$(pbpaste)"
More importantly secrets can stay out of your history.
export GITHUB_TOKEN="$(pbpaste)"
export AWS_ACCESS_KEY_ID="$(pbpaste)"
export AWS_SECRET_ACCESS_KEY="$(pbpaste)"
export DATABASE_URL="$(pbpaste)"
Today I ran into an interesting question, why am I being asked to configure
tzdata while installing npm. Turns out that the aptitude cli has a why
command that very handily nails down why you have something installed on a
debian based system.
Install aptitude #
apt install aptitude
Why tzdata #
Now we can query why we need tzdata and see the full chain with the root
package being npm.
root@47685221fb82:/# aptitude why tzdata
i npm Depends node-gyp
i A node-gyp Depends gyp (>= 0.1+20200513gitcaa6002)
i A gyp Depends python3:any
i A python3 Provides python3:any
i A python3 Depends python3.12 (>= 3.12.3-0~)
i A python3.12 Depends tzdata
Today I ran into this interactive prompt on ubuntu while installing node and npm, and I do not want to manually configure this interactively every time I run an install, moreso in docker I do not have the interactive terminal to do so.
Configuring tzdata
------------------
Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by presenting a list of cities, representing the time zones in which they are located.
1. Africa 2. America 3. Antarctica 4. Arctic 5. Asia 6. Atlantic 7. Australia 8. Europe 9. Indian 10. Pacific 11. Etc 12. Legacy
Geographic area:
Why tzdata #
Checking aptitude why tzdata it shows that the chain goes back through npm.
root@47685221fb82:/# aptitude why tzdata
i npm Depends node-gyp
i A node-gyp Depends gyp (>= 0.1+20200513gitcaa6002)
i A gyp Depends python3:any
i A python3 Provides python3:any
i A python3 Depends python3.12 (>= 3.12.3-0~)
i A python3.12 Depends tzdata
The solution, configure tzdata #
export TZ="America/Chicago"
export DEBIAN_FRONTEND=noninteractive
apt update
apt install tzdata -y
ln -fs /usr/share/zoneinfo/$TZ /etc/localtime
dpkg-reconfigure -f noninteractive tzdata
DEBIAN_FRONTEND=noninteractive
This is required, because apt installing tzdata will trigger the
interactive prompt. You will manually configure it in the next two steps.
https://www.youtube.com/watch?v=03KsS09YS4E&t=610s
Today I learned about the basic calculator, bc. At the very end of this video prime uses it to add numbers in vim.
REPL #
You can start a calculator repl at the command line, by running bc.
Vim #
Since bc supports standard unix pipes you can easily pipe data from vim into bc
and back out using !!bc. All you need is a string of math on the line you
want to calculate, go to normal mode and run !!bc to get the answer.
Traditionally I will open my system calculator or ipython to do something like this.
To keep the equation and the result in the same line you can send the equation to stderr and the result to stdout using tee.
:.!tee >(cat >&2) | bc