First of all you should know that most of the downloading and uploading are done
by curl program. in this article i'm talking about telling
this program to use proxy and how to use shell to make this process faster.
As the manpage says it looks for two environment variables that you should export:
$ export http_proxy="http://<address>:<port>"
for example:
$ export http_proxy="http://127.0.0.1:2081"
and also another one for https protocol:
$ export https_proxy=$http_proxy
Programs mostly use curl for transfering data so now you are using proxy. when you done
your job and don't want to use proxy anymore, you should unset this variables:
$ unset http_proxy https_proxy
You can simply make a shell function for toggling proxy. put this in your '.bashrc'
or '.zshrc' and if you are using fish you shouldn't use that:
Now you can simply use that function:
$ toggle_proxy
and where you are done:
$ toggle_proxy
I hope this article helped you. you can email me: ryo@nopwd.lol
Send signal to process
In unix you can send different signals to processes or group of processes.
Think of it as a command, you send that to a program for different goals.
*) How can i send that?
There a is simple CLI program called 'kill' for this job.
List all signal names
$ kill -l
Send a signal <signame> to a process with id <pid>:
$ kill -s <signame> <pid>
Also you can put signal number instead of it's name:
$ kill -<signum> <pid>
*) How to find a process id(pid)?
You can find it using 'pgrep', for example to find the pid of surf browser:
$ pgrep surf
Note: if you have multiple instances of a program, you will get the pid of all of them.
*) How 'kill' command itself works?
The 'signal' is a concept in unix so you use it in your C programs, this 'kill' command
is just a program that uses this feature. Check out the signal(7) man page for more info.
For example in Suckless Surf browser you can reload the browser by sending SIGHUP signal.
$ kill -s SIGHUP $(pgrep surf)
Screen Brightness
- This solution does not depend on x11 or wayland.
- You don't need root permission.
There is program called brightnessctl that you can use for this job, That's included
in many distributions like Arch and Void. Simply set the brightness:
$ brightnessctl set 400
*) I wrote this simple script to avoid being flashbanged when starting computer at night:
now=$(TZ=Iran date +%H)
night=21
morning=6
if [ "$now" -ge "$night" ] ||
[ "$now" -le "$morning" ]
then
brightnessctl set 300
else
brightnessctl set 600
fi
You should run this script at startup, for example in .xinitrc file:
dash /path/to/script.shNote: remember to place it somewhere before executing the window manager.
*) Also you can give shortcuts to increase/decrease the brightness.
For example in bspwm config file:
super + F11
brightnessctl set +50
super + F12
brightnessctl set 50-
Installing GTK themes
You can easily install new GTK themes, just follow this steps:
First download the theme and check that it contain xfwm folder, for example you can get
my favorite one Raleigh, old but gold.
Now you should move the theme folder(e.g /themes/Raleigh-Dark) to a specific path like
$HOME/.local/share/themes(you can put it in $HOME/.themes but don't do it). Also move the icon
folder(e.g /icons/Raleigh-Dark) to $HOME/.local/share/icons.
More info in arch wiki.
Then just tell the GTK to use this theme and icon:
~/.config/gtk-3.0/settings.ini
------------
[Settings]
gtk-theme-name = Raleigh-Dark
gtk-icon-theme-name = Raleigh-Dark
Done! just quit and reopen the gtk apps.
* But i don't like this boomer theme
Most of the people not going to like my opinion, for them i suggest Yaru.
It is a bloat one so it take some minutes to clone, also you can just get latest tag.
After cloning or extracting the compressed tag you should build and compile it:
$ mkdir build; cd build$ meson setup . .. -D prefix=$HOME/.local -D buildtype=release$ ninja install
Now you have installed the most bloat theme ever, just go to the settings.ini and change
the names to Yaru-dark.
Swap Capslock and Escape
Great location, useless job, it's capslock.
$ setxkbmap -option caps:swapescape
Put it on in your .xinitrc file, before running window manager.
The 'swapescape' is the mostly used option but not the only one, you can see
all of the options with their description in this file:
/usr/share/X11/xkb/rules/base.lst
Just search for the word 'caps:'.
Read news using RSS
Instead of going to each program's website to check for updates you can use RSS to read
them all in one place. It's just an XML file called feed, that contains the information
and you can put that into a RSS client and done!
Many websites have RSS feeds, they mostly put the link of that in an icon like this:
- What client i suggest? newsboat
It is easy to use and also terminal BASED, also in the Void and Arch repository.
After installing, you need to create this file:
$HOME/.config/newsboat/urls
With this content:
https://ryo.nopwd.lol/rss.xml
https://lukesmith.xyz/index.xml
https://voidlinux.org/atom.xml
https://brycevandegrift.xyz/rss.xml
Now just start 'newsboat' program, you need to reload the feeds(press R), enjoy!
No to Videos, Templates...
If you hate those annoying folders like Videos, Templates, Downloads etc, that always
respawned after you delete them, just do this simple thing:
There is a file named 'user-dirs.dirs' in '$HOME/.config' path, just change the content
to whatever you want, also you can remove them so you'll get rid of them.
This is my config for this file, enjoy the minimalism:
XDG_DESKTOP_DIR="$HOME/.local/desktop"
XDG_DOWNLOAD_DIR="$HOME/pocket/browser"
Installing Fonts
You can install fonts by moving them to a specific path:
Note: First create the destination folder if you haven't it already.
$ mv avenir_roman_12.otf ~/.local/share/fonts
You can install fonts in any format, i just use an OTF font in this example.
Then reload the system fonts:
$ fc-cache -f
Now you can find the exact name of the font you just installed, by:
$ fc-list | grep -i aven
~/.local/share/fonts/avenir_roman_12.otf: Avenir:style=Roman,Regular
Just write a part of that so you will get the name(in this example Avenir).
Manpage in Vim
You can use vim as a manpager[0] and even better give it a shortcut to open
the manpage of the word that is under the cursor(useful for c/shell coding).
[0]: program that displays the manpage in a formatted way like what a browser
does for a html page.
- Why?
The default manpager on most of the Linux/BSD distributions is 'less'
and that's fine but not even comparable to the power of Vim.
Put this commands on your vimrc:
runtime ftplugin/man.vim
set keywordprg=:Man
first: loads the 'man.vim' script(that's built in)
second: run the 'Man' command with word under the cursor as it's argument
when you press 'K'.
LaTeX Installation
Don't install it using the mainstream package managers(e.g. apt, pacman...),
instead just go to the TeX Live website
and get the installer and choose the basic scheme, it's about 300M!
Emojis Not Showing Up
If you see squares instead of emojis on the browser, that's because they are not
available on your system. There is a font package that contains most of them,
and that's called noto and included
on most of the package managers.
archlinux: noto-fonts-emoji
Git Shallow Clone
You can do a shallow clone with:
$ git clone --depth=1 --no-tags --single-branch someurl
In big projects it saves you a lot of time and space.
To know what this switches mean, check out the git-clone manpage.
Curl get the file size
Sat Mar 23: You can get size of a file on a http server using curl.
$ curl --head https://nopwd.lol/test.pdf
Order in $PATH
Thu Mar 21: When you want to run a program in a shell it will read a variable
called PATH and search for the executables in the order.
For example if the content of this variable on your system is like this:
/usr/bin:/home/you/.local/bin
and you have a executable with name zathura in both of this paths, shell will
run the one that is in /usr/bin, so the order is important.
Fix a Meson Warning
I've found xupric web browser interesting, so decided to check this project.
In the building step i saw this:
WARNING: find_library('libconfuse') starting in "lib" only
works by accident and is not portable fix: I just opened the 'meson.build' file and delete the 'lib' part.