1
0
Fork 0
forked from ahurac/dotfiles
This commit is contained in:
Hippolyte Chauvin 2023-04-13 00:04:20 +02:00
commit c1c1d8adbd
19 changed files with 501 additions and 0 deletions

16
local/bin/Hyprland Executable file
View file

@ -0,0 +1,16 @@
#!/bin/sh -xe
# cd to home
cd
# Add the Wayland version of Wine to the path
export PATH="/opt/wine-wl/usr/bin:$PATH"
# Set librewolf as default browser
export BROWSER=librewolf
# Execution
dbus-launch --exit-with-session \
ssh-agent \
/usr/bin/Hyprland

6
local/bin/coless Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh
env \
LESSOPEN='| /usr/bin/src-hilite-lesspipe.sh %s' \
LESS=' -R ' \
less "$@"

61
local/bin/glurp Executable file
View file

@ -0,0 +1,61 @@
#!/bin/bash
# Functions
# Error
function error {
>&2 echo -e "\033[1;31mERROR:\033[0m $1"; shift
exit "${1:-1}"
}
# Throw a value
function throw-value {
error "Value \"${1}\" invalid for ${2}." 1
}
function screenshot-path {
printf '%s%s-screenshot-%s.png' "${screenshot_d}/" "${LOGNAME}" "$(date +'%Y_%m_%d_%s')"
}
# Variables
declare -a prepend _command append
screenshot_d=/tmp
# Arguments
selection_mode="$1"; shift
saving_mode="$1" ; shift
# Command building
_command+=(grim)
case "$selection_mode" in
full)
:
;;
area)
_command+=(-g -)
prepend+=(slurp)
;;
*)
throw-value "$selection_mode" 'selection mode'
;;
esac
case "$saving_mode" in
clip)
_command+=(-)
append+=(wl-copy -t image/png)
;;
file)
_command+=("$(screenshot-path)")
;;
*)
throw-value "$saving_mode" 'saving mode'
;;
esac
# Debug
#echo "${prepend[@]} | ${_command[@]} | ${append[@]}"
#exit 0
# Execution
set -xe
"${prepend[@]}" | "${_command[@]}" | "${append[@]}"

53
local/bin/miam Executable file
View file

@ -0,0 +1,53 @@
#!/bin/bash
# Functions
# Throw
function throw {
>&2 echo "$1"
exit "$2"
}
# Throw a value
function throw-value {
throw "Invalid value for \"$1\": \"$2\"" "$3"
}
# Variables
selection_mode="$1"
saving_mode="$2"
screenshot_d="/tmp"
_command=()
# Command building
_command+=("maim")
case "$selection_mode" in
"full")
:
;;
"area")
_command+=("-s")
;;
*)
throw-value "selection mode" "$selection_mode" 1
;;
esac
case "$saving_mode" in
"clip")
_command+=("|")
_command+=("xclip" "-selection" "clipboard" "-t" "image/png")
;;
"file")
_command+=(">" "${screenshot_d}/$(printf '%s-screenshot-%s.png' "$LOGNAME" "$(date +'%Y_%m_%d_%s')")")
;;
*)
throw-value "saving mode" "$saving_mode" 2
;;
esac
# Debug
#echo "${_command[@]}"
#exit 0
# Execution
"${_command[@]}"

5
local/bin/mkddate Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh -e
path="${1:-.}/$(date +'%Y_%m_%d')"
mkdir -p "$path"
echo "$path"

24
local/bin/mount-phone Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash
# Variable
dest="/mnt/ahurac/phone"
# Commands building
# Create destination
create_destination=(
mkdir
-p
"$dest"
)
# Mount phone
mount_phone=(
aft-mtp-mount
"$dest"
)
# Execution
set -xe
"${create_destination[@]}"
"${mount_phone[@]}"

7
local/bin/sensible-browser Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
if [ -n "$BROWSER" ]; then
exec "$BROWSER"
else
exit 127
fi

58
local/bin/ssh-fwd Executable file
View file

@ -0,0 +1,58 @@
#!/bin/bash -e
shopt -s expand_aliases
[[ $TERM = xterm-kitty ]] && alias ssh='kitty +kitten ssh'
# Variables
ssh=ssh
declare -a args
# Display the usage
function usage {
cat << EOF
Usage: $(basename "$0") SSH_HOST LOCAL_PORT DISTANT_PORT [TARGET] [-- SSH_OPTIONS]
EOF
}
function error {
>&2 usage
exit "${1:-1}"
}
# Arguments
while [[ -n $* ]]; do
case "$1" in
"--")
shift
ssh_options=("$@")
set --
;;
*)
args+=("$1")
shift
;;
esac
done
# Checking the validity of the args
[[ -z ${args[2]} ]] && error 1
[[ -z ${args[3]} ]] && args[3]=localhost
# Command building
ssh_com=(
"$ssh"
"${ssh_options[@]}"
-f
-N
-L "${args[1]}:${args[3]}:${args[2]}"
"${args[0]}"
)
# Debug
#echo "${ssh_com[@]}"
#exit 0
# Execution
set -x
"${ssh_com[@]}"

5
local/bin/sshot-file Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
exec printf \
"screenshot-%s.${1:-png}" \
"$(date +"%Y_%m_%d-%N")"

25
local/bin/sway Executable file
View file

@ -0,0 +1,25 @@
#!/bin/sh -xe
# cd
cd
# Environment
# XDG
export \
XDG_CURRENT_DESKTOP=sway \
XDG_SESSION_DESKTOP=sway
# Backends
export \
QT_QPA_PLATFORM='wayland;xcb' \
QT_QPA_PLATFORMTHEME=qt6ct \
CLUTTER_BACKEND=wayland \
SDL_VIDEODRIVER=wayland \
_JAVA_AWT_WM_NONREPARENTING=1 \
MOZ_ENABLE_WAYLAND=1
# Execution
exec dbus-launch --exit-with-session \
ssh-agent \
/usr/bin/sway

29
local/bin/swaylock Executable file
View file

@ -0,0 +1,29 @@
#!/bin/sh
# Run swaylock
exec /usr/bin/swaylock \
--daemonize \
--indicator \
--clock \
--screenshots \
--effect-blur 20x10 \
--indicator-radius 100 \
--font 'Hack Nerd Font' \
--bs-hl-color '#FF3366' \
--inside-color '#CC99FF22' \
--inside-clear-color '#F3E6FFDD' \
--inside-ver-color '#9933FF22' \
--inside-wrong-color '#FF336622' \
--key-hl-color '#9933FF' \
--text-color '#F3E6FF' \
--text-caps-lock-color '#FFB3C6' \
--line-uses-ring \
--ring-color '#1A0033' \
--ring-clear-color '#9933FF' \
--ring-ver-color '#4F0099' \
--ring-wrong-color '#800020' \
--text-clear-color '#4F0099' \
--text-ver-color '#F3E6FF' \
--text-wrong-color '#FFB3C6' \
--separator-color '#00000000'

4
local/bin/update-grub Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
grub-mkconfig \
-o /boot/grub/grub.cfg

25
local/bin/updateall Executable file
View file

@ -0,0 +1,25 @@
#!/bin/bash
# Variable
commands_d="$HOME/.local/share/updateall/commands.d"
# Function
# Create a clear separator, adapts to the screen size
function separator {
local char="${2:-=}"
local separator cols
(( cols = $(tput cols) / 3 ))
while [[ ${#separator} -le $cols ]]; do
separator+="$char"
done
printf '\n%s\n\t%s\n%s\n' "$separator" "$1" "$separator"
}
# Loop
for pm in "$commands_d/"*; do
separator "$(basename "$pm")"
source "$pm"
done

33
local/bin/vncctl Executable file
View file

@ -0,0 +1,33 @@
#!/bin/bash
# Variables
declare -a vncctl
systemctl=systemctl
systemd_unit=vncserver
verb="${1:-status}"; shift
display="${1:-1}" ; shift
# Prepending sudo if necessary
case "$verb" in
start|restart|stop)
sudo=sudo
;;
esac
# Command building
[[ -n $sudo ]] && vncctl+=("$sudo")
vncctl+=(
"$systemctl"
"$@"
"$verb"
"${systemd_unit}@:${display}"
)
# Debug
#echo "${vncctl[@]}"
#exit 0
# Command execution
set -xe
"${vncctl[@]}"

35
local/bin/vncsconnect Executable file
View file

@ -0,0 +1,35 @@
#!/bin/bash
# Variables
declare -a make_ssh_bridge open_vnc_session
ssh_fwd=ssh-fwd
vncviewer=vncviewer
localhost=localhost
# Arguments
ssh_host="$1"
local_port="${2:-9900}"
distant_port="${3:-5900}"
target="$4"
# Commands building
# Make SSH bridge
make_ssh_bridge+=(
"$ssh_fwd"
"$ssh_host"
"$local_port"
"$distant_port"
"$target"
)
# Open VNC session
open_vnc_session+=(
"$vncviewer"
"${localhost}:${local_port}"
)
# Execution
set -xe
"${make_ssh_bridge[@]}"
"${open_vnc_session[@]}"

19
local/bin/waybar Executable file
View file

@ -0,0 +1,19 @@
#!/bin/sh -x
# Waybar wrapper to reload it anytime the
# configuration is edited
# Variable
waybar_config_d="${HOME}/.config/waybar"
monitored_events=(
modify
create
delete
)
# Execution
while :; do
/usr/bin/waybar "$@" &
inotifywait "${monitored_events[@]/#/-e}" "${waybar_config_d}"
jobs -p | xargs kill
done

35
local/bin/weston-rdp Executable file
View file

@ -0,0 +1,35 @@
#!/bin/bash
# Variables
weston=weston
backend=rdp-backend.so
rdp_d="${HOME}/.rdp"
hostname="$(hostname)"
crt="${rdp_d}/${hostname}.crt"
key="${rdp_d}/${hostname}.key"
socket=wayland-1
# Arguments
width="${1:-1920}" ; shift
height="${1:-1080}"; shift
# Command building
weston_com=(
"$weston"
"--backend=${backend}"
"--rdp-tls-cert=${crt}"
"--rdp-tls-key=${key}"
"--width=${width}"
"--height=${height}"
"--socket=${socket}"
)
# Debug
#echo "${weston_com[@]}"
#exit 0
# Execution
set -xe
cd
"${weston_com[@]}"

53
local/bin/wolf Executable file
View file

@ -0,0 +1,53 @@
#!/bin/bash
# Arguments
hostname="$1"; shift
# Variables
declare mac
declare -a wol_com options
name="$(basename "$0")"
wolf_d="${HOME}/.wolf"
wolf_host="${wolf_d}/${hostname}"
# Functions
# Throw an error
function error {
>&2 echo -e "${name}: \033[1;31mERROR:\033[0m ${1:-No further details}"; shift
exit "${1:-1}"
}
# Parse variable in options file
function getvar {
grep '^'"$1"' ' "$wolf_host" | cut -d ' ' -f 2
}
# Parsing
[[ -f $wolf_host ]] || error "\"${hostname}\": No such host"
# Assign the options
mac="$(getvar Mac)"
ip="$(getvar IP)"
port="$(getvar Port)"
# Add options if necessary
[[ -n $ip ]] && options+=(-i "$ip" )
[[ -n $port ]] && options+=(-p "$port")
# Commands building
# wol
wol_com=(
wol
"$@"
"${options[@]}"
"$mac"
)
# Debug
#echo "${wol_com[@]}"
#exit 0
# Execution
set -xe
"${wol_com[@]}"

8
local/bin/xdg-session-start Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh
/usr/lib/xdg-desktop-portal-wlr &
dbus-update-activation-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
sleep 1
artix-pipewire-loader &
sleep 1
waybar