#!/bin/sh

# List keyboard layouts from here
localectl list-keymaps

# Test if boot mode is UEFI (true if no error)
ls /sys/firmware/efi/efivars

# Connecting to WIFI using connmanctl (openrc | runit | s6 | 66 | dinit)
connmanctl << EOF
# Enabling wifi
enable wifi

# Enabling the agent (only use if needed passphrase)
agent on

# Scanning for access points
scan wifi

# Printing the access points (services) names
services

# Connecting to the access point
connect SERVICE_ID

# Enable the auto connection at startup option
config SERVICE_ID --autoconnect yes
EOF

# Connect to WIFI using iwctl (systemd)
iwctl << EOF
# Getting the list of available devices
device list

# Scanning for access points
station <device> scan

# Printing the access points names
station <device> get-networks

# Password-less
station <device> connect <SSID>

# Passphrase
iwctl --passphrase <passphrase> station <device> connect <SSID>
exit
EOF

# Arch package name            | Description
# base                         | Minimal package set to define a basic Arch Linux installation
# linux                        | The Linux kernel and modules
# linux-lts                    | The LTS Linux kernel and modules
# linux-zen                    | The Linux ZEN kernel and modules
# linux-hardened               | The Security-Hardened Linux kernel and modules
# linux-firmware               | Firmware files for Linux
# neovim                       | Fork of Vim, a terminal text editor
# doas                         | Run commands as super user or another user
# networkmanager               | Network connection manager and user applications
# networkmanager-iwd           | Network connection manager and user applications; using iwd backend instead of wpa_supplicant
# wpa_supplicant               | A utility providing key negotiation for WPA wireless networks
# grub                         | GNU GRand Unified Bootloader
# efibootmgr                   | UEFI Boot manager
# neofetch                     | A CLI system information tool written in BASH that supports displaying images
# which                        | A utility to show the full path of commands
# iwd                          | Internet Wireless Daemon
# ntfs-3g                      | NTFS file system driver and utilities
# keepass                      | Easy-to-use password manager for Windows, Linux, Mac OS X and mobile devices
# keepassxc                    | Cross-platform community-driven port of Keepass password manager
# dmenu                        | shortcut to launch other applications
# nvidia                       | NVIDIA drivers for newer cards (see wiki if doubt)
# nvidia-utils                 | NVIDIA utilities
# nvidia-settings              | NVIDIA settings page
# nvidia-prime                 | NVIDIA optimus like tool
# xf86-video-intel             | Intel graphics card drivers
# pulseaudio                   | Audio support
# pulseaudio-bluetooth         | Audio bluetooth support
# pulsemixer                   | CLI audio mixer
# bluez                        | Bluetooth support
# bluez-utils                  | Provides bluetoothctl to connect to devices
# openssh                      | Provides utilities to generate ssh keys
# xclip                        | Being able to copy from CLI
# picom                        | X compositor that may fix tearing issues
# vlc                          | Multi-platform MPEG, VCD/DVD, and DivX player
# i3-gaps                      | A fork of i3wm tiling window manager with more features, including gaps
# xorg-xinit                   | Xorg initialisation program
# xorg-server                  | Xorg X server
# xorg-xset                    | User preference utility for X
# feh                          | Fast and light imlib2-based image viewer
# alacritty                    | terminal emulator
# os-prober                    | Utility to detect other OSes on a set of drives
# git                          | The fast distributed version control system
# wget                         | Network utility to retrieve files from the Web
# unzip                        | For extracting and viewing files in .zip archives
# firefox                      | Standalone web browser from mozilla.org
# virtualbox                   | Powerful x86 virtualization for enterprise as well as home use
# virtualbox-guest-utils       | VirtualBox Guest userspace utilities
# virtualbox-host-modules-arch | Virtualbox host kernel modules for Arch Kernel
# bash-completion              | Programmable completion for the bash shell
# intel-ucode                  | Microcode update files for Intel CPUs
# reflector                    | Python utility to get the fastest pacman mirrors
# rsync                        | A fast and versatile file copying tool for remote and local files (optional dependency of reflector)
# nodejs                       | Evented I/O for V8 javascript
# npm                          | A package manager for javascript
# ripgrep                      | search tool that combines the usability of ag with the raw speed of grep
# cuda                         | NVIDIA's GPU programming toolkit
# python                       | Next generation of the python high-level scripting language
# python-pip                   | The PyPA recommended tool for installing Python packages
# lazygit                      | Simple terminal UI for git commands
# cryptsetup                   | Userspace setup tool for transparent encryption of block devices using dm-crypt
# discord                      | All-in-one voice and text chat for gamers that's free and secure.
# htop                         | Interactive process viewer
# thunderbird                  | Standalone mail and news reader from mozilla.org
# brightnessctl                | Lightweight brightness control tool
# fakeroot                     | Tool for simulating superuser privileges
# sed                          | GNU stream editor
# gcc                          | The GNU Compiler Collection - C and C++ frontends
# grep                         | A string search utility
# make                         | GNU make utility to maintain groups of programs
# man-db                       | A utility for reading man pages
# openvpn                      | An easy-to-use, robust and highly configurable VPN
# pkgconf                      | Package compiler and linker metadata toolkit

# Artix package name           | Description
# openrc                       | Gentoo's universal init system
# elogind-openrc               | OpenRC elogind init script
# connman-openrc               | OpenRC connman init script
# runit                        | A cross-platform Unix init scheme with service supervision
# elogind-runit                | Runit service scripts for elogind
# connman-runit                | Runit service script for connman
# s6-base                      | Packages, hooks, and scripts to define a basic s6 init system implementation for Artix Linux.
# elogind-s6                   | s6-rc service scripts for elogind
# connman-s6                   | s6-rc service scripts for connman
# suite66                      | small tools built around s6 and s6-rc programs
# elogind-suite66              | 66 script for elogind
# connman-suite66              | 66 script for connman
# dinit                        | Service monitoring/init system -- init package
# elogind-dinit                | dinit service scripts for elogind
# connman-dinit                | dinit service scripts for connman

# AUR package name | Description                                                                              | Upstream link
# polybar          | A fast and easy-to-use status bar                                                        | https://aur.archlinux.org/polybar.git
# davmail          | a POP/IMAP/SMTP/Caldav/LDAP gateway for the exchange service                             | https://aur.archlinux.org/davmail.git
# font-manager     | A simple font management application for GTK+ Desktop Environments                       | https://aur.archlinux.org/font-manager.git
# tor-browser      | anonymous browsing using Firefox and Tor                                                 | https://aur.archlinux.org/tor-browser.git
# lazydocker       | A simple terminal UI for docker and docker-compose, written in Go with the gocui library | https://aur.archlinux.org/lazydocker.git

# NOTE : Before installing tor, type : gpg --auto-key-locate nodefault,wkd --locate-keys torbrowser@torproject.org

# Get the list of all available time zones
timedatectl list-timezones

# Removing users from specific group
gpasswd -d "$USERNAME" "$GROUP"

# Dual boot setup with os-prober
echo 'GRUB_DISABLE_OS_PROBER=0' >> /etc/default/grub
update-grub

# If bluez bluetooth device is org.bluez.Error.Blocked
rfkill block bluetooth
rfkill unblock bluetooth
# If it still doesn't work
## systemd
systemctl restart bluetooth
## OpenRC
rc-service bluetoothd restart

# Setup a custom DNS server (systemd)
systemctl enable systemd-resolved
systemctl start systemd-resolved
mkdir /etc/systemd/resolved.conf.d
echo '[Resolve]
DNS=192.168.35.1 fd7b:d0bd:7a6e::1
Domains=~.e' > /etc/systemd/resolved.conf.d/dns_servers.conf