mirror of
https://github.com/Ascyii/scripts.git
synced 2026-01-01 04:44:24 -05:00
Init
This commit is contained in:
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# General purpose scripts
|
||||||
|
|
||||||
|
Different scripts to automate workflow to be used with cron as a clock. Some configurations depend on those scripts to be present in `~/projects/scripts`.
|
||||||
5
data/projects
Normal file
5
data/projects
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.config
|
||||||
|
.config/nvim
|
||||||
|
~/
|
||||||
|
vault
|
||||||
|
management/office
|
||||||
8
other/yaz.zsh
Executable file
8
other/yaz.zsh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
function y() {
|
||||||
|
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
|
||||||
|
yazi "$@" --cwd-file="$tmp"
|
||||||
|
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
|
||||||
|
builtin cd -- "$cwd"
|
||||||
|
fi
|
||||||
|
rm -f -- "$tmp"
|
||||||
|
}
|
||||||
81
python/extract_mail.py
Normal file
81
python/extract_mail.py
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import os
|
||||||
|
import email
|
||||||
|
from email import policy
|
||||||
|
from email.parser import BytesParser
|
||||||
|
import re
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
# Path to the email file
|
||||||
|
input_file = "/home/jonas/mail/saved-messages"
|
||||||
|
|
||||||
|
# Output folder
|
||||||
|
output_dir = "/home/jonas/mail/plain_emails"
|
||||||
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
|
|
||||||
|
def sanitize_filename(name):
|
||||||
|
"""Remove problematic characters for filenames"""
|
||||||
|
return re.sub(r'[\\/*?:"<>|]', "", name)
|
||||||
|
|
||||||
|
def parse_email_datetime(date_str):
|
||||||
|
"""Try to parse the Date header into YYYY-MM-DD_HH-MM format"""
|
||||||
|
try:
|
||||||
|
parsed_date = email.utils.parsedate_to_datetime(date_str)
|
||||||
|
return parsed_date.strftime('%Y-%m-%d_%H-%M')
|
||||||
|
except Exception:
|
||||||
|
return "unknown-date"
|
||||||
|
|
||||||
|
# Read the whole file
|
||||||
|
with open(input_file, "rb") as f:
|
||||||
|
raw_data = f.read()
|
||||||
|
|
||||||
|
# Split raw emails (assuming mbox format with "From " separator)
|
||||||
|
emails = raw_data.split(b'\nFrom ')
|
||||||
|
|
||||||
|
# If first email doesn't start with "From ", fix it
|
||||||
|
if emails and not emails[0].startswith(b'From '):
|
||||||
|
emails[0] = b'From ' + emails[0]
|
||||||
|
|
||||||
|
# Save the first email to keep
|
||||||
|
first_email = emails[0]
|
||||||
|
|
||||||
|
# Process the rest, ignoring the first
|
||||||
|
for raw_email in emails[1:]:
|
||||||
|
if not raw_email.strip():
|
||||||
|
continue
|
||||||
|
|
||||||
|
raw_email = b'From ' + raw_email # Add back separator if missing
|
||||||
|
msg = BytesParser(policy=policy.default).parsebytes(raw_email)
|
||||||
|
|
||||||
|
subject = msg['subject'] or "No Subject"
|
||||||
|
sender = msg['from'] or "Unknown Sender"
|
||||||
|
receiver = msg['to'] or "Unknown Receiver"
|
||||||
|
date = msg['date'] or "Unknown Date"
|
||||||
|
|
||||||
|
subject_clean = sanitize_filename(subject.strip())
|
||||||
|
date_clean = parse_email_datetime(date)
|
||||||
|
|
||||||
|
# Get the plain text part
|
||||||
|
if msg.is_multipart():
|
||||||
|
for part in msg.walk():
|
||||||
|
if part.get_content_type() == "text/plain":
|
||||||
|
body = part.get_payload(decode=True).decode(part.get_content_charset() or 'utf-8', errors='replace')
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
body = "(No plain text part found)"
|
||||||
|
else:
|
||||||
|
body = msg.get_payload(decode=True).decode(msg.get_content_charset() or 'utf-8', errors='replace')
|
||||||
|
|
||||||
|
# Create the filename: Date_Time_Subject.txt
|
||||||
|
filename = f"{date_clean}_{subject_clean}.txt"
|
||||||
|
output_path = os.path.join(output_dir, filename)
|
||||||
|
|
||||||
|
# Write to file
|
||||||
|
with open(output_path, "w", encoding="utf-8") as out_f:
|
||||||
|
out_f.write(f"Date: {date}\n")
|
||||||
|
out_f.write(f"From: {sender}\n")
|
||||||
|
out_f.write(f"To: {receiver}\n\n")
|
||||||
|
out_f.write(body)
|
||||||
|
|
||||||
|
# After processing, overwrite the mailbox with only the first email
|
||||||
|
with open(input_file, "wb") as f:
|
||||||
|
f.write(first_email)
|
||||||
11
shell/autostart.sh
Executable file
11
shell/autostart.sh
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Doing some default configurations
|
||||||
|
#/home/johah/scripts/mousecenter2.sh
|
||||||
|
#xdotool key Super+b
|
||||||
|
#/home/johah/scripts/mousecenter1.sh
|
||||||
|
#xdotool key Super+b
|
||||||
|
|
||||||
|
# Launching the st terminal with neofetch and spacing on startup
|
||||||
|
st -t "FocusDone" -e bash -c 'echo " " && echo " " && echo -e " Workstation\033[0m is\033[1;92m ready\033[0m!" && echo " " && echo " " && neofetch && echo " " && cd; bash'
|
||||||
|
xsetroot -name "ZeroSum"
|
||||||
64
shell/autostart_server.sh
Executable file
64
shell/autostart_server.sh
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SESSION_NAME="services"
|
||||||
|
PROJECTS_DIR="$HOME/projects"
|
||||||
|
|
||||||
|
################################
|
||||||
|
|
||||||
|
# autoscan for start.sh in the projects dir
|
||||||
|
|
||||||
|
# Array of [dirname startscript]
|
||||||
|
# Ony extra
|
||||||
|
entries=(
|
||||||
|
"djangowebtrack" "./run.sh host"
|
||||||
|
)
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
# Scan folders
|
||||||
|
for dir in "$PROJECTS_DIR"/*/; do
|
||||||
|
dirname="$(basename "$dir")"
|
||||||
|
|
||||||
|
if [[ -x "$dir/start.sh" ]]; then
|
||||||
|
entries+=("$dirname" "./autostart.sh")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# No entries found
|
||||||
|
if [[ ${#entries[@]} -eq 0 ]]; then
|
||||||
|
echo "No start scripts found in $PROJECTS_DIR."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start tmux session if it does not exist
|
||||||
|
if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
|
||||||
|
tmux new-session -d -s "$SESSION_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get list of already existing windows
|
||||||
|
existing_windows=$(tmux list-windows -t "$SESSION_NAME" -F "#{window_name}")
|
||||||
|
|
||||||
|
# Create new windows only if they don't already exist
|
||||||
|
for ((i = 0; i < ${#entries[@]}; i += 2)); do
|
||||||
|
dirname="${entries[i]}"
|
||||||
|
startcmd="${entries[i + 1]}"
|
||||||
|
|
||||||
|
if echo "$existing_windows" | grep -Fxq "$dirname"; then
|
||||||
|
echo "Window '$dirname' already exists, skipping..."
|
||||||
|
else
|
||||||
|
echo "Starting '$dirname'..."
|
||||||
|
tmux new-window -t "$SESSION_NAME" -n "$dirname" "cd \"$PROJECTS_DIR/$dirname\" && $startcmd"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Kill default window if empty
|
||||||
|
if tmux list-windows -t "$SESSION_NAME" | grep -q "^1: bash"; then
|
||||||
|
tmux kill-window -t "$SESSION_NAME:1" 2>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Attach if not inside tmux
|
||||||
|
if [[ -z "$TMUX" ]]; then
|
||||||
|
tmux attach-session -t "$SESSION_NAME"
|
||||||
|
else
|
||||||
|
echo "Already inside tmux. Session '$SESSION_NAME' updated."
|
||||||
|
fi
|
||||||
13
shell/battery_shutdown.sh
Executable file
13
shell/battery_shutdown.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Get battery percentage from /sys/class/power_supply/BAT0/capacity
|
||||||
|
BATTERY=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||||
|
STATUS=$(cat /sys/class/power_supply/BAT0/status)
|
||||||
|
|
||||||
|
echo $BATTERY
|
||||||
|
echo $STATUS
|
||||||
|
|
||||||
|
# Only shutdown if on battery (discharging) and low
|
||||||
|
if [ "$STATUS" = "Discharging" ] && [ "$BATTERY" -lt 15 ]; then
|
||||||
|
systemctl poweroff
|
||||||
|
fi
|
||||||
49
shell/cabalmod.sh
Executable file
49
shell/cabalmod.sh
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check if filename argument is provided
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: $0 <filename>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Get the current directory
|
||||||
|
current_dir=$(pwd)
|
||||||
|
# Find the nearest Cabal file
|
||||||
|
cabal_file=$(find . -maxdepth 1 -type f -name "*.cabal" | head -n 1)
|
||||||
|
if [ -z "$cabal_file" ]; then
|
||||||
|
echo "Error: No Cabal file found in the current directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Extract module name from the provided filename
|
||||||
|
module_name=$(basename "$1" .hs)
|
||||||
|
|
||||||
|
# Check if required variables are set
|
||||||
|
if [ -z "$cabal_file" ] || [ -z "$module_name" ]; then
|
||||||
|
echo "Error: cabal_file and module_name variables are not set."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Find the line with "other-modules:"
|
||||||
|
other_modules_line=$(rg -e 'other-modules:' "$cabal_file")
|
||||||
|
line_number=$(rg -n -e 'other-modules:' "$cabal_file" | cut -d: -f1)
|
||||||
|
|
||||||
|
if [[ -z "$other_modules_line" ]]; then
|
||||||
|
echo "other-modules: not found in $cabal_file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the line is commented
|
||||||
|
if [[ $other_modules_line == " -- "* ]]; then
|
||||||
|
# Remove the comment "-- "
|
||||||
|
sed -i "${line_number}s/ -- other-modules:/ other-modules:/" "$cabal_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Append module_name with comma
|
||||||
|
sed -i "s/ other-modules:/ other-modules: $module_name,/" "$cabal_file"
|
||||||
|
# Create the .hs file in the app directory
|
||||||
|
hs_file="./app/$1.hs"
|
||||||
|
touch "$hs_file"
|
||||||
|
# Add boilerplate code to the .hs file
|
||||||
|
echo "module $module_name where" >"$hs_file"
|
||||||
|
echo "" >>"$hs_file"
|
||||||
|
# Open the file with neovim
|
||||||
|
nvim "$hs_file"
|
||||||
67
shell/check_git.sh
Executable file
67
shell/check_git.sh
Executable file
@@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Read the list of Git repositories from /tmp/all_git_projects
|
||||||
|
repos=$(cat /tmp/all_git_projects)
|
||||||
|
|
||||||
|
# Function to handle each repository
|
||||||
|
sync_repo() {
|
||||||
|
repo=$1
|
||||||
|
if [ -d "$HOME/$repo" ]; then
|
||||||
|
cd "$HOME/$repo" || return
|
||||||
|
|
||||||
|
if [ -d ".git" ]; then
|
||||||
|
git add .
|
||||||
|
remote_count=$(git remote -v | wc -l)
|
||||||
|
status_output=$(git status --short)
|
||||||
|
|
||||||
|
if [ -n "$status_output" ]; then
|
||||||
|
echo "Status for: $repo"
|
||||||
|
echo "$status_output"
|
||||||
|
|
||||||
|
if git rev-parse --verify HEAD >/dev/null 2>&1; then
|
||||||
|
last_msg=$(git log -1 --pretty=%B)
|
||||||
|
|
||||||
|
# Use rg to check for `+ auto` at the end
|
||||||
|
if printf "%s" "$last_msg" | rg '\+ auto$' >/dev/null; then
|
||||||
|
amend_output=$(git commit --amend --no-edit 2>&1)
|
||||||
|
else
|
||||||
|
new_msg="${last_msg} + auto"
|
||||||
|
amend_output=$(git commit --amend -m "$new_msg" 2>&1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Amended last commit for $repo: $amend_output"
|
||||||
|
else
|
||||||
|
commit_output=$(git commit -m 'auto + auto' 2>&1)
|
||||||
|
echo "Initial commit for $repo: $commit_output"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$remote_count" -gt 0 ]; then
|
||||||
|
fetch_output=$(git fetch --all 2>&1)
|
||||||
|
pull_output=$(git pull 2>&1)
|
||||||
|
push_output=$(git push 2>&1)
|
||||||
|
if [ -n "$fetch_output" ]; then
|
||||||
|
echo "Fetching updates for $repo: $fetch_output"
|
||||||
|
fi
|
||||||
|
if [ "$pull_output" != "Already up to date." ]; then
|
||||||
|
echo "Pulling changes for $repo: $pull_output"
|
||||||
|
fi
|
||||||
|
if [ "$push_output" != "Everything up-to-date" ]; then
|
||||||
|
echo "Pushing changes to remote for $repo: $push_output"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
for repo in $repos; do
|
||||||
|
basename_repo=$(basename "$repo")
|
||||||
|
case "$basename_repo" in
|
||||||
|
r_*) continue ;;
|
||||||
|
esac
|
||||||
|
sync_repo "$repo" &
|
||||||
|
done
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
|
echo "Sync completed for all repositories."
|
||||||
54
shell/check_language.sh
Executable file
54
shell/check_language.sh
Executable file
@@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# List programming languages based on common installation paths
|
||||||
|
|
||||||
|
echo "Programming languages installed on your system:"
|
||||||
|
|
||||||
|
# Check if Python is installed
|
||||||
|
if command -v python3 &>/dev/null; then
|
||||||
|
echo "- Python"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if Ruby is installed
|
||||||
|
if command -v ruby &>/dev/null; then
|
||||||
|
echo "- Ruby"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if Node.js is installed
|
||||||
|
if command -v node &>/dev/null; then
|
||||||
|
echo "- Node.js"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if Java is installed
|
||||||
|
if command -v java &>/dev/null; then
|
||||||
|
echo "- Java"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if Go is installed
|
||||||
|
if command -v go &>/dev/null; then
|
||||||
|
echo "- Go"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if PHP is installed
|
||||||
|
if command -v php &>/dev/null; then
|
||||||
|
echo "- PHP"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if Rust is installed
|
||||||
|
if command -v rustc &>/dev/null; then
|
||||||
|
echo "- Rust"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if C compiler is installed (GCC)
|
||||||
|
if command -v gcc &>/dev/null; then
|
||||||
|
echo "- C"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if C++ compiler is installed (g++)
|
||||||
|
if command -v g++ &>/dev/null; then
|
||||||
|
echo "- C++"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add more checks for other languages as needed
|
||||||
|
|
||||||
|
echo "End of list."
|
||||||
22
shell/clipsend.sh
Executable file
22
shell/clipsend.sh
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
REMOTE_FILE="~/clip"
|
||||||
|
SEPARATOR='---xx---'
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
append)
|
||||||
|
clipboard_content=$(wl-paste)
|
||||||
|
formatted_content="$SEPARATOR\n$clipboard_content\n"
|
||||||
|
echo -e "$formatted_content" | ssh bi "cat >> $REMOTE_FILE"
|
||||||
|
echo "Clipboard contents appended to remote file."
|
||||||
|
;;
|
||||||
|
retrieve)
|
||||||
|
lines=$(ssh bi "tac $REMOTE_FILE | awk '/$SEPARATOR/ {exit} {print}' | tac")
|
||||||
|
echo -e "$lines" | wl-copy
|
||||||
|
echo "Last entry copied to clipboard."
|
||||||
|
wtype $lines
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {append|retrieve}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
3
shell/deltmp.sh
Executable file
3
shell/deltmp.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
find ~ -name ".bash_history-*.tmp" -type f -delete
|
||||||
37
shell/diffv_wrap.sh
Executable file
37
shell/diffv_wrap.sh
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
OLD="$1"
|
||||||
|
NEW="$2"
|
||||||
|
MERGED="$3" # Optional
|
||||||
|
BASE="$4" # Optional
|
||||||
|
|
||||||
|
#shift 4 # Shift all four known arguments
|
||||||
|
PATHS="$@" # Everything left are additional paths/options
|
||||||
|
|
||||||
|
# Quoting and checking empty variables safely
|
||||||
|
if [ -d "$OLD" ]; then
|
||||||
|
# Directory diff
|
||||||
|
nvim -d -c "DiffviewFileHistory"
|
||||||
|
if [ -z "$PATHS" ]; then
|
||||||
|
# nvim -d "$OLD" "$NEW" -c "DiffviewFileHistory"
|
||||||
|
echo "starting diff view wrapper with no paths"
|
||||||
|
|
||||||
|
else
|
||||||
|
#nvim -d "$OLD" "$NEW" -c "DiffviewFileHistory $PATHS"
|
||||||
|
echo "starting diff view wrapper with paths"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# File diff
|
||||||
|
if [ -z "$MERGED" ]; then
|
||||||
|
nvim -d "$OLD" "$NEW"
|
||||||
|
else
|
||||||
|
nvim -d -c "DiffviewOpen"
|
||||||
|
if [ -z "$PATHS" ]; then
|
||||||
|
#nvim -d "$OLD" "$NEW" -c "DiffviewOpen"
|
||||||
|
echo "starting diff view wrapper with no paths"
|
||||||
|
else
|
||||||
|
#nvim -d "$OLD" "$NEW" -c "DiffviewOpen $PATHS"
|
||||||
|
echo "starting diff view wrapper with paths"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
46
shell/find_gits.sh
Executable file
46
shell/find_gits.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Global vars
|
||||||
|
file_n="all_git_projects"
|
||||||
|
|
||||||
|
# First get the project dirs
|
||||||
|
project_dirs=$(cat ../data/projects)
|
||||||
|
|
||||||
|
# Get the folder name of a git project and store it in a variable
|
||||||
|
cd ~
|
||||||
|
if [ -e "/tmp/$file_n" ]; then
|
||||||
|
folder=$(fzf <"/tmp/$file_n")
|
||||||
|
else
|
||||||
|
# Store the result
|
||||||
|
# #################### Exclusion
|
||||||
|
git_repos=$(find . -type d \( -path ./.cache -o -path ./.local -o -path ./SCRATCH -o -path ./BACKUP_YESTERDAY \) -prune -o -name '.git' -print | sed 's|^\./||; s|/.git||')
|
||||||
|
combined_repos=$(echo -e "$git_repos\n$project_dirs")
|
||||||
|
echo "$combined_repos" >"/tmp/$file_n"
|
||||||
|
folder=$(echo "$combined_repos" | fzf)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure folder is not empty
|
||||||
|
if [ -n "$folder" ]; then
|
||||||
|
#session_name=$(basename "$folder") # Use only the last part of the path as session name
|
||||||
|
session_name=$(echo "$folder" | sed 's/\.\([^ ]*\)/_\1/g')
|
||||||
|
|
||||||
|
if tmux has-session -t "$session_name" 2>/dev/null; then
|
||||||
|
if [ -n "$TMUX" ]; then
|
||||||
|
tmux switch-client -t "$session_name" # If inside tmux, switch session
|
||||||
|
else
|
||||||
|
tmux attach-session -t "$session_name" # If outside tmux, attach session
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
cd $folder
|
||||||
|
tmux new-session -d -s "$session_name"
|
||||||
|
if [ -n "$TMUX" ]; then
|
||||||
|
tmux switch-client -t "$session_name" # If inside tmux, switch session
|
||||||
|
else
|
||||||
|
tmux attach-session -t "$session_name" # If outside tmux, attach session
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No selection made."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit
|
||||||
17
shell/get_vol.sh
Executable file
17
shell/get_vol.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get the current active sink
|
||||||
|
active_sink=$(pactl info | grep 'Default Sink:' | awk '{print $3}')
|
||||||
|
|
||||||
|
# Check which sink is active and get its volume
|
||||||
|
if [ "$active_sink" == "alsa_output.pci-0000_01_00.1.hdmi-stereo" ] || [ "$active_sink" == "alsa_output.pci-0000_00_1f.3.analog-stereo" ]; then
|
||||||
|
volume=$(pactl list sinks | grep -A 10 "Name: $active_sink" | grep -m 1 'Volume:' | awk '{print $5}')
|
||||||
|
|
||||||
|
pre=''
|
||||||
|
if [ "$active_sink" == "alsa_output.pci-0000_01_00.1.hdmi-stereo" ]; then pre='M'; elif [ "$active_sink" == "alsa_output.pci-0000_00_1f.3.analog-stereo" ]; then pre='H'; fi
|
||||||
|
|
||||||
|
if [ $(pulsemixer --get-mute) -eq 0 ]; then echo "($pre) $volume"; else echo "($pre) Muted"; fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Active sink not recognized."
|
||||||
|
fi
|
||||||
13
shell/ghci_wrapper.sh
Executable file
13
shell/ghci_wrapper.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Set the directory path
|
||||||
|
dir_path="app/"
|
||||||
|
|
||||||
|
# Check if the directory exists and contains at least one .hs file
|
||||||
|
if [ -d "$dir_path" ] && [ "$(ls -A $dir_path/*.hs 2>/dev/null)" ]; then
|
||||||
|
# If the directory exists and contains .hs files, execute ghci with them
|
||||||
|
ghci "$dir_path"*.hs
|
||||||
|
else
|
||||||
|
# If the directory doesn't exist or doesn't contain .hs files, execute ghci without them
|
||||||
|
ghci
|
||||||
|
fi
|
||||||
9
shell/giter.sh
Executable file
9
shell/giter.sh
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
git add .
|
||||||
|
git commit -a -m 'auto commit'
|
||||||
|
|
||||||
|
git fetch -a
|
||||||
|
git pull
|
||||||
|
|
||||||
|
git push
|
||||||
3
shell/hitcc.sh
Executable file
3
shell/hitcc.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
xdotool key Super+b &
|
||||||
7
shell/hyprfix.sh
Executable file
7
shell/hyprfix.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
file=~/configuration/dotfiles/.config/hypr/hyprland.conf
|
||||||
|
|
||||||
|
echo "#" >>file &
|
||||||
|
sleep 1
|
||||||
|
sed -i '$ d' file &
|
||||||
23
shell/initer.sh
Executable file
23
shell/initer.sh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "WARNING THIS COULD BREAK THINGS. CONFIRM BY C-C!"
|
||||||
|
cat
|
||||||
|
|
||||||
|
mkdir -p $HOME/projects
|
||||||
|
mkdir -p $HOME/configuration
|
||||||
|
|
||||||
|
git clone git@gitlab.gwdg.de:j.hahn02/scripts.git $HOME/projects/scripts
|
||||||
|
git clone git@gitlab.gwdg.de:j.hahn02/nixos.git $HOME/configuration/nixos
|
||||||
|
git clone git@gitlab.gwdg.de:j.hahn02/dotfiles.git $HOME/configuration/dotfiles
|
||||||
|
git clone git@gitlab.gwdg.de:j.hahn02/brainstore.git $HOME/management/brainstore
|
||||||
|
|
||||||
|
cd $HOME/configuration/dotfiles
|
||||||
|
bash $HOME/configuration/dotfiles/install.sh
|
||||||
|
|
||||||
|
cd
|
||||||
|
|
||||||
|
#scp -r syncer:sync/office $HOME/management
|
||||||
|
|
||||||
|
# optional insta reabiuld when on nix
|
||||||
|
echo 'rebuilding nix - if there'
|
||||||
|
sudo nixos-rebuild switch --flake '/home/jonas/configuration/nixos#'
|
||||||
3
shell/lowervolume.sh
Executable file
3
shell/lowervolume.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
pulsemixer --unmute --change-volume -1
|
||||||
40
shell/mount_ssd.sh
Executable file
40
shell/mount_ssd.sh
Executable file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
SSD_LABEL="Pass500" # Replace this with the label of your SSD
|
||||||
|
MOUNT_POINT="$HOME/ExternalSSD" # Directory to mount the SSD
|
||||||
|
|
||||||
|
# Check if the SSD is connected
|
||||||
|
SSD_DEVICE=$(lsblk -l -o LABEL,NAME | grep "$SSD_LABEL" | awk '{print $2}')
|
||||||
|
if [ -z "$SSD_DEVICE" ]; then
|
||||||
|
echo "The external SSD ($SSD_LABEL) is not connected."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SSD_DEVICE="/dev/$SSD_DEVICE"
|
||||||
|
|
||||||
|
# Check if the directory exists; if not, create it
|
||||||
|
if [ ! -d "$MOUNT_POINT" ]; then
|
||||||
|
mkdir -p "$MOUNT_POINT"
|
||||||
|
echo "Created mount point at $MOUNT_POINT."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Mount the SSD
|
||||||
|
sudo mount "$SSD_DEVICE" "$MOUNT_POINT"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to mount $SSD_DEVICE to $MOUNT_POINT."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Change ownership to the current user
|
||||||
|
sudo chown -R "$(id -u):$(id -g)" "$MOUNT_POINT"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to set ownership for $MOUNT_POINT."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Successfully mounted $SSD_LABEL at $MOUNT_POINT."
|
||||||
|
|
||||||
|
# Change to the mounted directory and open a shell
|
||||||
|
cd "$MOUNT_POINT" || exit
|
||||||
|
exec $SHELL
|
||||||
3
shell/mousecenter1.sh
Executable file
3
shell/mousecenter1.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
xdotool mousemove 50 1030
|
||||||
3
shell/mousecenter2.sh
Executable file
3
shell/mousecenter2.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
xdotool mousemove 2970 540
|
||||||
15
shell/mp4.sh
Executable file
15
shell/mp4.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Find all .mp4 files in the current directory and subdirectories
|
||||||
|
media_files=$(find . -type f \( -name "*.mp4" -o -name "*.mp3" \))
|
||||||
|
|
||||||
|
# Use fzf to allow the user to select a file
|
||||||
|
selected_file=$(echo "$media_files" | fzf)
|
||||||
|
|
||||||
|
# Check if a file was selected
|
||||||
|
if [[ -n $selected_file ]]; then
|
||||||
|
# Play the selected file with mpv
|
||||||
|
mpv "$selected_file" --save-position-on-quit
|
||||||
|
else
|
||||||
|
echo "No file selected."
|
||||||
|
fi
|
||||||
39
shell/nix_conf.sh
Executable file
39
shell/nix_conf.sh
Executable file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Ensure we are in the correct directory
|
||||||
|
cd ~/configuration/nixos || {
|
||||||
|
echo "Failed to find ~/configuration/nixos"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the current generation for naming the commit later
|
||||||
|
GENERATION=$(nix-env --list-generations | tail -n 1 | awk '{print $1}')
|
||||||
|
|
||||||
|
# Open the configuration in Neovim
|
||||||
|
nvim configuration.nix
|
||||||
|
|
||||||
|
# Check if there are any changes to the configuration file
|
||||||
|
if git diff --quiet hosts/asus-vivo/configuration.nix; then
|
||||||
|
echo "No changes made to configuration.nix."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Show the updated diff
|
||||||
|
echo -e "\n--- Changes Detected ---\n"
|
||||||
|
git diff configuration.nix
|
||||||
|
|
||||||
|
# Build the NixOS configuration
|
||||||
|
echo -e "\n--- Building NixOS Configuration ---"
|
||||||
|
if sudo nixos-rebuild switch; then
|
||||||
|
echo -e "\n--- Build Successful ---"
|
||||||
|
else
|
||||||
|
echo -e "\n--- Build Failed ---"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Commit the changes to the repo with the generation name
|
||||||
|
echo -e "\n--- Committing Changes ---"
|
||||||
|
git add configuration.nix
|
||||||
|
git commit -m "Update to generation $GENERATION"
|
||||||
|
|
||||||
|
echo -e "\nChanges committed with message: 'Update to generation $GENERATION'"
|
||||||
5
shell/oathi.sh
Executable file
5
shell/oathi.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
KEY=LSDKFJ9879SDF98
|
||||||
|
|
||||||
|
oathtool --totp -b $KEY
|
||||||
5
shell/pgadmin_run.sh
Executable file
5
shell/pgadmin_run.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source ~/pgadmin4/bin/activate
|
||||||
|
firefox "http://127.0.0.1:5050" &
|
||||||
|
pgadmin4
|
||||||
10
shell/pomodoro_wrapper.sh
Executable file
10
shell/pomodoro_wrapper.sh
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Starting pomodoro timer
|
||||||
|
~/bin/tomatoshell $1
|
||||||
|
|
||||||
|
# When started without argument, then clear the console (make it visible again)
|
||||||
|
if [ "$#" -eq 0 ]; then
|
||||||
|
tput reset
|
||||||
|
fi
|
||||||
|
|
||||||
5
shell/raisevolume.sh
Executable file
5
shell/raisevolume.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
pulsemixer --unmute --change-volume +1
|
||||||
|
|
||||||
|
pulsemixer --max-volume 80
|
||||||
12
shell/rnote_mapper.sh
Executable file
12
shell/rnote_mapper.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "okay"
|
||||||
|
|
||||||
|
libinput debug-events | while read -r line; do
|
||||||
|
if echo "$line" | grep -q 'TABLET_PAD_BUTTON.*10 pressed'; then
|
||||||
|
echo "Tablet Button 6 pressed. Launching Rnote..."
|
||||||
|
rnote &
|
||||||
|
# optional: add `disown` if you don't want it tied to terminal
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
13
shell/run_kitty.sh
Executable file
13
shell/run_kitty.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This is a script to always have only one instance of kitty running
|
||||||
|
# You can run another one if you wish if you use the menu manager
|
||||||
|
# Use tmux or the
|
||||||
|
|
||||||
|
if hyprctl clients | grep -q 'class: kitty'; then
|
||||||
|
# Focus existing kitty
|
||||||
|
hyprctl dispatch focuswindow class:kitty
|
||||||
|
else
|
||||||
|
# No kitty window found, launch kitty
|
||||||
|
kitty &
|
||||||
|
fi
|
||||||
15
shell/run_unison.sh
Executable file
15
shell/run_unison.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
## wrapper to make unison dynamic
|
||||||
|
#net=$(ping -c 1 hahn1.one)
|
||||||
|
#echo $net
|
||||||
|
#
|
||||||
|
#if [ $net = "" ]; then
|
||||||
|
# echo "cannot reach cloud"
|
||||||
|
#else
|
||||||
|
#fi
|
||||||
|
|
||||||
|
# TODO: implement net logic
|
||||||
|
|
||||||
|
unison MainAll -root "$HOME/synced" -root "ssh://jonas@hahn1.one/synced"
|
||||||
|
|
||||||
39
shell/screenshot.sh
Executable file
39
shell/screenshot.sh
Executable file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Take a screenshot on wayland with swaymsg, jq, grim, slurp, and swappy
|
||||||
|
#
|
||||||
|
# Make sure the script is executable (chmod +x ./screenshot.sh)
|
||||||
|
#
|
||||||
|
# If you don't use sway, replace `swaymsg` with whatever your window manager
|
||||||
|
# gives you to query window information.
|
||||||
|
#
|
||||||
|
# Example sway configuration
|
||||||
|
#
|
||||||
|
# bindsym Print exec ~/.local/bin/screenshot.sh region
|
||||||
|
# bindsym Shift+Print exec ~/.local/bin/screenshot.sh window
|
||||||
|
# bindsym Ctrl+Print exec ~/.local/bin/screenshot.sh output
|
||||||
|
# bindsym Ctrl+Shift+Print exec ~/.local/bin/screenshot.sh all
|
||||||
|
|
||||||
|
# region|window|output|all
|
||||||
|
mode="$1"
|
||||||
|
|
||||||
|
case $mode in
|
||||||
|
"region")
|
||||||
|
grim -g "$(slurp)" - | swappy -f -
|
||||||
|
;;
|
||||||
|
"window")
|
||||||
|
grim -g "$(swaymsg -t get_tree | jq -j '.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"')" - | swappy -f -
|
||||||
|
;;
|
||||||
|
"output")
|
||||||
|
grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') - | swappy -f -
|
||||||
|
;;
|
||||||
|
"all")
|
||||||
|
grim - | swappy -f -
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo >&2 "unsupported command \"$mode\""
|
||||||
|
echo >&2 "Usage:"
|
||||||
|
echo >&2 "screenshot.sh <region|window|output|all>"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
8
shell/search.sh
Executable file
8
shell/search.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Usage: rgnvim KEYWORD
|
||||||
|
rg --vimgrep "$@" |
|
||||||
|
fzf --delimiter : --nth 1,2,3,4 \
|
||||||
|
--preview 'bat --style=numbers --color=always --highlight-line {2} {1}' |
|
||||||
|
awk -F: '{print $1, $2}' |
|
||||||
|
xargs -r sh -c 'nvim +"$1" "$0"'
|
||||||
30
shell/set_res.sh
Executable file
30
shell/set_res.sh
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get the list of connected displays with their modes
|
||||||
|
connected_displays=$(xrandr | grep " connected" | awk '{print $1}')
|
||||||
|
|
||||||
|
# Extract the primary display (first in the list)
|
||||||
|
primary_display=$(echo "$connected_displays" | sed -n '1p')
|
||||||
|
|
||||||
|
# Extract the secondary display (second in the list, if it exists)
|
||||||
|
secondary_display=$(echo "$connected_displays" | sed -n '2p')
|
||||||
|
|
||||||
|
# Extract the highest resolution for the primary display
|
||||||
|
primary_resolution=$(xrandr | grep -A1 "^$primary_display connected" | tail -n1 | awk '{print $1}')
|
||||||
|
echo $primary_display $secondary_display $primary_resolution
|
||||||
|
|
||||||
|
# If there's a secondary display, extract its highest resolution
|
||||||
|
if [ -n "$secondary_display" ]; then
|
||||||
|
secondary_resolution=$(xrandr | grep -A1 "^$secondary_display connected" | tail -n1 | awk '{print $1}')
|
||||||
|
|
||||||
|
# Extract the width of the primary display to calculate the correct offset
|
||||||
|
primary_width=$(echo "$primary_resolution" | cut -d'x' -f1)
|
||||||
|
echo $primary_width
|
||||||
|
|
||||||
|
# Set up xrandr with the detected displays, resolutions, and correct positioning
|
||||||
|
xrandr --output "$primary_display" --primary --mode "$primary_resolution" --pos 0x0 --rotate normal \
|
||||||
|
--output "$secondary_display" --mode "$secondary_resolution" --pos "${primary_width}x0" --rotate normal
|
||||||
|
else
|
||||||
|
# If there's only one display, just set it as primary with the highest resolution
|
||||||
|
xrandr --output "$primary_display" --primary --mode "$primary_resolution" --pos 0x0 --rotate normal
|
||||||
|
fi
|
||||||
22
shell/start_typst.sh
Executable file
22
shell/start_typst.sh
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get the directory and file of the current Typst file
|
||||||
|
FILE="$1"
|
||||||
|
echo $FILE
|
||||||
|
DIR=$(dirname "$FILE")
|
||||||
|
echo $DIR
|
||||||
|
PDF_FILE="${DIR}/$(basename "$FILE" .typ).pdf"
|
||||||
|
|
||||||
|
#swaymsg workspace 2
|
||||||
|
|
||||||
|
# Start typst watch in the background
|
||||||
|
typst watch "$FILE" --root ../ &>/dev/null &
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
#swaymsg workspace 1
|
||||||
|
sioyek --new-window "$PDF_FILE" &>/dev/null &
|
||||||
|
# Open a new workspace in Sway (workspace number 2 in this example)
|
||||||
|
# Change this workspace number as needed
|
||||||
|
|
||||||
|
# Print process information for debugging
|
||||||
|
echo "Started typst watch and opened PDF in sioyek on workspace 2."
|
||||||
2
shell/stop_typst.sh
Executable file
2
shell/stop_typst.sh
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
killall typst
|
||||||
|
killall sioyek
|
||||||
24
shell/sync_all.sh
Executable file
24
shell/sync_all.sh
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Path to the file containing the list of paths
|
||||||
|
file="$HOME/.syncs"
|
||||||
|
|
||||||
|
# Iterate over each line in the file
|
||||||
|
while IFS= read -r path; do
|
||||||
|
# Process each path
|
||||||
|
cd ~/$path
|
||||||
|
# Check arguments
|
||||||
|
if [ "$1" = "out" ]; then
|
||||||
|
echo "Syncing OUT to $path ..."
|
||||||
|
bash ./sync.sh out
|
||||||
|
elif [ "$1" = "in" ]; then
|
||||||
|
echo "Syncing OUT to $path ..."
|
||||||
|
bash ./sync.sh out
|
||||||
|
else
|
||||||
|
echo "Usage: $0 [out|in]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ~
|
||||||
|
|
||||||
|
done <"$file"
|
||||||
37
shell/sync_manage.sh
Executable file
37
shell/sync_manage.sh
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#set -eu
|
||||||
|
|
||||||
|
# need a way to use curl and rsync here
|
||||||
|
exit
|
||||||
|
|
||||||
|
# Try to fetch a webpage
|
||||||
|
curl -Is https://www.duckduckgo.com | head -n 1 &> /dev/null
|
||||||
|
|
||||||
|
# Check if the request was successful
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
# Define the local and remote directories
|
||||||
|
LOCAL_DIR="$HOME/management"
|
||||||
|
REMOTE_USER="gui" # Replace with the remote username
|
||||||
|
REMOTE_SERVER="localhost" # Replace with the remote server address
|
||||||
|
REMOTE_DIR="management" # Replace with the remote directory path
|
||||||
|
|
||||||
|
# Log the current date and time
|
||||||
|
echo "Sync started at $(date)"
|
||||||
|
|
||||||
|
# Use rsync to sync the local directory to the remote server
|
||||||
|
rsync -adt --update "$LOCAL_DIR/" "$REMOTE_USER@$REMOTE_SERVER:$REMOTE_DIR"
|
||||||
|
|
||||||
|
# Check if rsync succeeded
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Sync completed successfully at $(date)"
|
||||||
|
else
|
||||||
|
echo "Sync failed at $(date)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No internet connection."
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
12
shell/tmp_note.sh
Executable file
12
shell/tmp_note.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# This is for nixos specific
|
||||||
|
|
||||||
|
# simple script to create and use a temporary note file
|
||||||
|
|
||||||
|
# Create new temporary file if not already exists for this date
|
||||||
|
if [ ! -f /tmp/notes.md ]; then
|
||||||
|
echo -e "# $(date)\n\n" >/tmp/notes.md
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Instantly enter the insert mode at the bottom for less friction
|
||||||
|
nvim -c "e /tmp/notes.md" -c "normal G" -c "normal k" -c "normal o" -c "startinsert"
|
||||||
19
shell/toggle_wifi.sh
Executable file
19
shell/toggle_wifi.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check if an interface name is provided
|
||||||
|
#if [ -z "$1" ]; then
|
||||||
|
# echo "Usage: $0 <interface_name>"
|
||||||
|
# exit 1
|
||||||
|
#fi
|
||||||
|
|
||||||
|
INTERFACE="wlo1"
|
||||||
|
|
||||||
|
# Parse the interface state from `ip a`
|
||||||
|
STATE=$(ip a show "$INTERFACE" 2>/dev/null | grep -oP '(?<=state )\w+')
|
||||||
|
|
||||||
|
# Check if the interface exists
|
||||||
|
if [ $STATE = "UP" ]; then
|
||||||
|
sudo ip link set $INTERFACE down
|
||||||
|
else
|
||||||
|
sudo ip link set $INTERFACE up
|
||||||
|
fi
|
||||||
15
shell/togglesink.sh
Executable file
15
shell/togglesink.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Execute the initial command and capture the output
|
||||||
|
sink_output=$(pacmd list-sinks | awk '/\*/ {getline; print $2}')
|
||||||
|
|
||||||
|
# Check the output and set the default sink accordingly
|
||||||
|
if [ "$sink_output" == "<alsa_output.pci-0000_00_1f.3.analog-stereo>" ]; then
|
||||||
|
pacmd set-default-sink 0
|
||||||
|
echo "Default sink set to 0"
|
||||||
|
elif [ "$sink_output" == "<alsa_output.pci-0000_01_00.1.hdmi-stereo>" ]; then
|
||||||
|
pacmd set-default-sink 1
|
||||||
|
echo "Default sink set to 1"
|
||||||
|
else
|
||||||
|
echo "Unknown sink output: $sink_output"
|
||||||
|
fi
|
||||||
10
shell/unison_sync.sh
Executable file
10
shell/unison_sync.sh
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
dunstify 'Sync Start' "Started to sync this to ⭐ hub"
|
||||||
|
|
||||||
|
# Capture Unison output
|
||||||
|
OUTPUT=$(~/projects/scripts/run_unison.sh 2>&1)
|
||||||
|
LAST_LINE=$(echo "$OUTPUT" | tail -n 1)
|
||||||
|
|
||||||
|
# Notify with last line
|
||||||
|
dunstify 'Sync Finished ✅' "$LAST_LINE"
|
||||||
14
shell/update_stud.sh
Executable file
14
shell/update_stud.sh
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd ~/projects/studCrawl
|
||||||
|
|
||||||
|
# List your dependencies here (space-separated, Nix/Nixpkgs attribute names)
|
||||||
|
PYTHON_DEPS="requests beautifulsoup4"
|
||||||
|
|
||||||
|
# Optional: set path to your main script
|
||||||
|
SCRIPT="src/just_update.py"
|
||||||
|
|
||||||
|
# Call nix-shell with your dependencies; -p means "with these packages in environment"
|
||||||
|
nix-shell -p "python3.withPackages (ps: with ps; [ $PYTHON_DEPS ])" --run "python3 $SCRIPT"
|
||||||
Reference in New Issue
Block a user