Announcement!!!

I recently found out about Hugo and start writing blogs with it.
Check my new blogs here: Hugo Blogs

Videos

You don't need to download this videos, watch them online using mpv(or vlc):
$ mpv <video url>

  • Pidgin - XMPP Client <- NEW
  • Adding search engine to firefox
  • Voidlinux Installation
  • Vim Macro Demo
  • Notes

  • Announcement!!! <- NEW
  • Searxng using Docker and Nginx
  • Proxy in terminal
  • Send signal to process
  • Screen Brightness
  • Installing GTK themes
  • Torrent Guide
  • Swap Capslock and Escape
  • Read news using RSS(Important)
  • No to Videos, Templates...
  • Void Linux Installation
  • Installing Fonts
  • Qemu basics
  • Manpage in Vim
  • LaTeX Installation
  • Emojis Not Showing Up
  • Install Programs Manually
  • Git Shallow Clone
  • Curl get the file size
  • Order in $PATH
  • Meson Warning
  • Setup

    Projects

  • XML to SQL converter <- NEW
  • Vless to V2ray config
  • Morris Mano Assembler
  • Neatroff PT-macro patch
  • Snake game using Raylib
  • Temp


    TikZ Basics

    I want to start sharing my knowledge about TikZ in here.
    For now just look at this demo i made:
    
    output file: tikz-demo.pdf
    source code: tikz-demo.tex
    

    Searxng using Docker and Nginx

    You don't need to be a docker wizard to setup searxng, i'll show you step by step.
    Unfortunately we are banned from Docker Hub so you should do something:
    - registry key (the one i use)
    - dns/proxy
    
    Change the registry key in Docker Daemon file:
    
    /etc/docker/daemon.json
    -------------
    {
      "registry-mirrors": ["https://docker.iranserver.com"]
    }
    
    Or you can pass it through the daemon as an argument:
    # dockerd --registry-mirror "<url>"
    
    I like to run Docker as a non-root user, so first add your user to 'docker' group:
    # usermod -a -G docker <user>
    
    ! Now if you want to run Searxng on your pc for testing purposes, just follow
    the original document . I'll show you the setup in a vps with domain, so it depends
    on your needs to follow or not.
    
    First you need a domain/sub domain, i like the name sx.<domain> but it's yours.
    
    - create a directory for the Container and cd to it.
    - choose a port for docker, i choose 1234 for example.
    
    Pull the image:
    $ docker pull searxng/searxng
    Create and run the container:
    $ docker run --rm -d -p 8791:8080 -v "${PWD}/searxng:/etc/searxng" searxng/searxng
    
    !! the important thing you should do is this option in 'searxng/settings.yml' file
    that you need root access to edit:
    base_url: https://sx.nopwd.lol/
    * just search for 'base_url' and change it from 'false' to the url you want.
    
    It's time to setup Nginx and we are done.
    ! Setup SSL with Certbot and change domain.com to your own.
    
    
    server { listen 80; listen [::]:80; server_name domain.com; location / { proxy_pass http://127.0.0.1:8791/; proxy_buffering off; proxy_set_header Host $host; proxy_set_header X-Real-IP \$remote_addr; } listen 443 ssl; ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; }
    Just reload the server and done! $ systemctl reload nginx I hope this article helped you, it took me some days to figure it out.

    Proxy in terminal

    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:
    
    proxy_connect=0 PS2=$PS1 toggle_proxy() { if [[ "$proxy_connect" -eq 0 ]]; then export http_proxy="http://127.0.0.1:2081" export https_proxy=$http_proxy proxy_connect=1 echo "activated" PS1="%{$fg[red]%}][proxy]%{$reset_color%}$%b " else unset http_proxy unset https_proxy proxy_connect=0 echo "deactivated" PS1=$PS2 fi }
    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

    test
    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 is a 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.sh
    Note: 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.
    
    

    Torrent Guide

    You should be careful about torrent websites, you're on your own, but you can decrease
    the risk by some researching. Find official URL of the torrent sites from subreddits.
    Check the number of seeds, five is good. Seed is a computer that sharing file(s).

    After getting the torrent file or magnet link you need a bittorrent client.
    I use transmission because it is lightweight and easy to use, also you can find it in most of distributions.
    voidlinux: transmission
    archlinux: transmission-cli

    First you need to run the daemon:
    $ transmission-daemon
    
    You can check the content of a torrent file with:
    $ transmission-show somefile.torrent
    but it only works with files not magnet links.
    
    Get the status of all torrents you have been added:
    $ transmission-remote --list
    Note: You need the ID of the added torrent for later steps.
    
    Add the torrent file or magnet link to the client but start the download paused.
    I guessed you don't want all files, if so, just remove the last switch and go to stop part:
    $ transmission-remote --add somefile.torrent --start-paused
    Note: In case of magent link don't forget to put '"' around the link.
    If it succeed, it will give you a success message.
    
    Then list files of the torrent:
    $ transmission-remote --torrent <ID> --files
    As you can see the Get option for all of them is Yes so if you start, all of them
    will start downloading, so set all of them to No by:
    $ transmission-remote --torrent <ID> --no-get all
    
    Now select file(s) that you want:
    $ transmission-remote --torrent <ID> --get <num>,<num>,...
    For example:
    $ transmission-remote --torrent 1 --get 5,7-10,4,2
    It marks files #5, #7, #8, #9, #10 and #4 to the download list.
    Now start the torrent:
    $ transmission-remote --torrent <ID> --start
    
    You can check the status with:
    $ transmission-remote --torrent <ID> --list
    By using Watch command you don't need to enter that many times:
    $ watch transmission-remote --torrent <ID> --list
    
    After it is downloaded just stop it from seeding(uploading):
    $ transmission-remote --torrent <ID> --stop
    
    + Getting notification after download completed
    In the daemon settings file there is two options for this:
    $HOME/.config/transmission-daemon/settings.json
    
    ...
    "script-torrent-done-enabled": true,
    "script-torrent-done-filename": "~/.local/script/tordone.sh",
    ...
    
    The tordone.sh script is where we want to call our notification to say something:
    
    #!/usr/bin/env dash
    dunstify "Torrent Done"
    
    Also don't forget to make it executable:
    $ chmod u+x tordone.sh
    
    * Does this client only has this little options?
    No, you can find many more options in the manual(transmission-remote(1) manpage).
    For example how to limit the download speed, or how to change download folder.
    

    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"