diff options
| author | bard <[email protected]> | 2024-04-15 06:24:14 -0400 |
|---|---|---|
| committer | bard <[email protected]> | 2024-04-15 06:24:14 -0400 |
| commit | 168120d4068eff9816c11f0503738c12861821ae (patch) | |
| tree | 635e839eeca920432fcaa8417b282e074e84a4c2 /bin/.local | |
initial commit
Diffstat (limited to 'bin/.local')
35 files changed, 1250 insertions, 0 deletions
diff --git a/bin/.local/bin/scripts/alert b/bin/.local/bin/scripts/alert new file mode 100755 index 0000000..d9e418f --- /dev/null +++ b/bin/.local/bin/scripts/alert @@ -0,0 +1,3 @@ +#!/bin/sh + +paplay --volume=40000 $HOME/.local/bin/scripts/bell.mp3 diff --git a/bin/.local/bin/scripts/backup.sh b/bin/.local/bin/scripts/backup.sh new file mode 100755 index 0000000..acf6ad8 --- /dev/null +++ b/bin/.local/bin/scripts/backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Set paths +SOURCE_DIRS=( + "/home/bard/Pictures/" + "/home/bard/Documents/" + "/home/bard/Code/" + "/home/bard/Notes/" + "/home/bard/Playlists/" + "/home/bard/Repositories/" + "/home/bard/Music/" + "/home/bard/Videos/" +) + +DESTINATION_BASE="/mnt/hdd/" +LOG_FILE="/mnt/hdd/backup.log" +LOG_STATUS_FILE="/mnt/hdd/backup_status.log" +ICON_PATH="/usr/share/icons/gnome/16x16/devices/drive-harddisk.png" + +# Log start time +echo "Backup started at $(date)" >> "$LOG_FILE" +notify-send -i $ICON_PATH "Backup started at $(date)" + +# Run rsync for each source directory +for SOURCE_DIR in "${SOURCE_DIRS[@]}"; do + DESTINATION_DIR="$DESTINATION_BASE$(basename "$SOURCE_DIR")" + rsync -avuP "$SOURCE_DIR" "$DESTINATION_DIR" >> "$LOG_FILE" 2>&1 + # rsync -avuPn "$SOURCE_DIR" "$DESTINATION_DIR" >> "$LOG_FILE" 2>&1 +done + +# Display summary made for notifications +NOTIF_SUMMARY="" +for SOURCE_DIR in "${SOURCE_DIRS[@]}"; do + DESTINATION_DIR="$DESTINATION_BASE$(basename "$SOURCE_DIR")" + BACKUP_SIZE=$(du -sh "$DESTINATION_DIR" | cut -f1) + NOTIF_SUMMARY+="$(basename "$SOURCE_DIR"): $BACKUP_SIZE\n" +done + +# Display summary made for log file +LOG_SUMMARY="" +for SOURCE_DIR in "${SOURCE_DIRS[@]}"; do + DESTINATION_DIR="$DESTINATION_BASE$(basename "$SOURCE_DIR")" + BACKUP_SIZE=$(du -sh "$DESTINATION_DIR" | cut -f1) + LOG_SUMMARY+="$(basename "$SOURCE_DIR"): $BACKUP_SIZE\n" +done + +# Log end time and display completion message with summary +echo -e "\nBackup Summary:\n$NOTIF_SUMMARY" >> "$LOG_FILE" +notify-send -i "$ICON_PATH" "Backup completed at $(date)" "$NOTIF_SUMMARY" +echo -e "Most recent backup $(date)\n$LOG_SUMMARY" >> "$LOG_STATUS_FILE" diff --git a/bin/.local/bin/scripts/bell.mp3 b/bin/.local/bin/scripts/bell.mp3 Binary files differnew file mode 100644 index 0000000..cac0ece --- /dev/null +++ b/bin/.local/bin/scripts/bell.mp3 diff --git a/bin/.local/bin/scripts/cht.sh b/bin/.local/bin/scripts/cht.sh new file mode 100755 index 0000000..bec30aa --- /dev/null +++ b/bin/.local/bin/scripts/cht.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +languages=$(echo "cpp clojure haskell ocaml python typescript" | tr " " "\n") +core_utils=$(echo "find xargs sed awk" | tr " " "\n") + +selected=$(echo -e "$languages\n$core_utils" | fzf) +read -p "query: " query + +if echo "$languages" | grep -qs $selected; then + tmux split-window -h bash -c "curl cht.sh/$selected/$(echo "$query" | tr " " "+") | less" +else + curl cht.sh/$selected~$query +fi diff --git a/bin/.local/bin/scripts/countdown b/bin/.local/bin/scripts/countdown Binary files differnew file mode 100755 index 0000000..8188637 --- /dev/null +++ b/bin/.local/bin/scripts/countdown diff --git a/bin/.local/bin/scripts/daily.sh b/bin/.local/bin/scripts/daily.sh new file mode 100755 index 0000000..937cff7 --- /dev/null +++ b/bin/.local/bin/scripts/daily.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Weather information +weather_info="Погода $(curl -s wttr.in/?format="%c+%C+%t+%p\n")" + +# Top todos from todo.org file under "Important Stuff" +todos=$(grep -A 100 '^\*\* Important Stuff$' /home/bard/Notes/Org-Roam/todo.org | grep '^\*\*\* TODO' | sed -E 's/^\*\*\* TODO (.+)$/\1/' | sed -E 's/\s*:[^:]+:\s*//g' | sed 's/^/☑ /') +todos_message="Задачи на сегодня:\n${todos}" + +# Most recent backup status +backup_log="/mnt/hdd/backup_status.log" +backup_status=$(sed -n '1p; 2,9p' "$backup_log" | tr '\n' '\n') + +# Send desktop notification +notify-send -i ~/.local/share/icons/Glass/cup.png "Доброе Утро Данила" "<b>${weather_info}</b>\n${todos_message}\n${backup_status}" +echo -e "Доброе Утро Данила" "${weather_info}\n${todos_message}\n${backup_status}" diff --git a/bin/.local/bin/scripts/directory_navigator b/bin/.local/bin/scripts/directory_navigator new file mode 100755 index 0000000..2bf01e4 --- /dev/null +++ b/bin/.local/bin/scripts/directory_navigator @@ -0,0 +1,34 @@ +#!/bin/bash + +# Navigate directories with fzf and open a program based on file extension + +# Function to navigate directories with fzf +navigate_directories() { + selected_file=$(find "$HOME" -type f | fzf --height=50%) + if [ -n "$selected_file" ]; then + file_extension="${selected_file##*.}" + + case "$file_extension" in + "pdf") + zathura "$selected_file" + ;; + ".org") + emacsclient -c "$selected_file" + ;; + ".png" | ".webp" | ".gif" | ".jpg") + nsxiv "$selected_file" + ;; + *) + # Example: open other file types with a default program + xdg-open "$selected_file" + ;; + esac + fi +} + +# Main script +main() { + navigate_directories +} + +main diff --git a/bin/.local/bin/scripts/dired_selector b/bin/.local/bin/scripts/dired_selector new file mode 100755 index 0000000..ef40af6 --- /dev/null +++ b/bin/.local/bin/scripts/dired_selector @@ -0,0 +1,10 @@ +#!/bin/bash + +selectable_dirs=("~/Code/" "~/Repositories/" "~/Documents/" "~/Notes/Org-Roam/" "~/Pictures/" "~/Pictures/wallpaper" "~/Pictures/screenshots/" "~/Downloads/" "~/Music/" "~/Playlists/" "~/Videos/" "~/Videos/Youtube/Programming/Prot/" "~/Desktop/" "~/.local/bin/scripts/") +# Use dmenu to select a directory +selected_dir=$(printf "%s\n" "${selectable_dirs[@]}" | dmenu -p "Dired here: ") + +# Open the selected directory in Emacsclient with Dired mode +if [ -n "$selected_dir" ]; then + emacsclient -c -e "(dired \"$selected_dir\")" +fi diff --git a/bin/.local/bin/scripts/dmenuunicode b/bin/.local/bin/scripts/dmenuunicode new file mode 100755 index 0000000..b444742 --- /dev/null +++ b/bin/.local/bin/scripts/dmenuunicode @@ -0,0 +1,18 @@ +#!/bin/sh + +# The famous "get a menu of emojis to copy" script. + +# Get user selection via dmenu from emoji file. +chosen=$(cut -d ';' -f1 ~/.local/share/fonts/emoji | dmenu -i -l 30 | sed "s/ .*//") + +# Exit if none chosen. +[ -z "$chosen" ] && exit + +# If you run this command with an argument, it will automatically insert the +# character. Otherwise, show a message that the emoji has been copied. +if [ -n "$1" ]; then + xdotool type "$chosen" +else + printf "%s" "$chosen" | xclip -selection clipboard + notify-send "'$chosen' copied to clipboard." & +fi diff --git a/bin/.local/bin/scripts/dzen2.sh b/bin/.local/bin/scripts/dzen2.sh new file mode 100644 index 0000000..42e9af6 --- /dev/null +++ b/bin/.local/bin/scripts/dzen2.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Set the font and colors +FONT="-*-terminus-medium-*-*-*-12-*-*-*-*-*-*-*" +FG_COLOR="#FFFFFF" +BG_COLOR="#333333" + +# Set the Dzen2 geometry (position and size) +GEOMETRY="1920x24+0+0" + +# Create the Dzen2 bar with specified settings +dzen2 -fn "$FONT" -fg "$FG_COLOR" -bg "$BG_COLOR" -ta l -w 800 -h 24 -x 0 -y 0 -e "onstart=lower" & +DZEN_PID=$! + +# Function to update the Dzen2 bar +update_dzen() { + while true; do + DATE=$(date +"%A, %B %d %Y - %H:%M:%S") + echo -e "$DATE" + sleep 1 + done +} + +# Call the update_dzen function to continuously update the bar +update_dzen | dzen2 -fn "$FONT" -fg "$FG_COLOR" -bg "$BG_COLOR" -x 800 -y 0 -w 1120 -h 24 -ta r -e "onstart=lower" + +# Clean up when the script exits +trap "kill $DZEN_PID" EXIT + +# Wait for Dzen2 to finish +wait diff --git a/bin/.local/bin/scripts/emacs-theme.el b/bin/.local/bin/scripts/emacs-theme.el new file mode 100644 index 0000000..4554cc3 --- /dev/null +++ b/bin/.local/bin/scripts/emacs-theme.el @@ -0,0 +1,10 @@ +(defun bard/disable-all-themes () + "Disable all active themes." + (dolist (i custom-enabled-themes) + (disable-theme i))) + +(bard/disable-all-themes) + +(setq selected-emacs-theme (car command-line-args-left)) + +(load-theme (intern selected-emacs-theme) t) diff --git a/bin/.local/bin/scripts/emacs/emacs-daemon.sh b/bin/.local/bin/scripts/emacs/emacs-daemon.sh new file mode 100755 index 0000000..a5133bd --- /dev/null +++ b/bin/.local/bin/scripts/emacs/emacs-daemon.sh @@ -0,0 +1,121 @@ +#!/bin/bash + +set -e + +kill_server() +{ + local SERVER_DIR="/run/user/1000/emacs/" + + usage() + { + cat <<EOT +Usage '$0 kill': +- -d <dir> or --server-dir <dir> + - Specify the directory where Emacs server sockets live, default is '$SERVER_DIR'. +EOT + exit 1 + } + + while [[ $# -gt 0 ]]; do + case "$1" in + -d|--server-dir ) shift; SERVER_DIR="$1";; + -h|--help ) usage;; + * ) usage;; + esac + shift + done + + local -a sockets + local socket_name + + mapfile -t sockets < <(command ls -1 "$SERVER_DIR") + + socket_name=$(printf '%s\n' "${sockets[@]}" | dmenu -p "Kill") + socket_path="${SERVER_DIR}${socket_name}" + + emacsclient --eval '(kill-emacs)' --socket-name="$socket_path" +} + +start_client() +{ + + local SERVER_DIR="/run/user/1000/emacs/" + local DISPLAY_MODE="graphical" + + usage() + { + cat <<EOT +Usage '$0 start': +- -d <dir> or --server-dir <dir> + - Specify the directory where Emacs server sockets live, default is '$SERVER_DIR'. +- -t, -nw, --tty + - Create the client frame on the current terminal +EOT + exit 1 + } + + while [[ $# -gt 0 ]]; do + case "$1" in + -d|--server-dir ) shift; SERVER_DIR="$1";; + -t|-nw|--tty ) DISPLAY_MODE="tty";; + -h|--help ) usage;; + * ) usage;; + esac + shift + done + + local -a sockets + local socket_name + local cmd + + if [[ ! -e "$SERVER_DIR" ]]; then + mkdir -p "$SERVER_DIR" + fi + + + mapfile -t sockets < <(command ls -1 "$SERVER_DIR") + sockets+=("<no-daemon>") + + socket_name=$(printf '%s\n' "${sockets[@]}" | dmenu -p "Connect") + + if [[ "$socket_name" == "<no-daemon>" ]]; then + cmd+="emacs" + else + socket_path="${SERVER_DIR}${socket_name}" + cmd+="emacsclient -c -a '' --socket-name=$socket_path" + fi + + if [[ "$DISPLAY_MODE" == "tty" ]]; then + cmd+=" -t" + fi + + eval "$cmd" +} + + +usage() +{ + cat <<EOT +Usage '$0': +- start: Choose the Emacs server and start the client to communicate it. +- kill: Choose the Emacs server to kill. +EOT + exit 1 +} + +main() +{ + if [[ $# -eq 0 ]]; then + usage + fi + + case "$1" in + start ) shift; start_client "$@";; + kill ) shift; kill_server "$@";; + help ) usage;; + * ) usage;; + esac +} + + +main "$@" diff --git a/bin/.local/bin/scripts/emacs/show-agenda.el b/bin/.local/bin/scripts/emacs/show-agenda.el new file mode 100644 index 0000000..a36eb4c --- /dev/null +++ b/bin/.local/bin/scripts/emacs/show-agenda.el @@ -0,0 +1,16 @@ +(org-eval-in-environment (org-make-parameter-alist + '(org-agenda-span + 'week + org-agenda-use-time-grid t + org-agenda-remove-tags t + org-agenda-window-setup 'nope)) + (let* ((wins (current-window-configuration)) + org-agenda-sticky) + (save-excursion + (with-current-buffer + (get-buffer-create org-agenda-buffer-name) + (pop-to-buffer (current-buffer)) + (org-agenda nil "a") + (let ((result (buffer-string))) + (with-temp-file "~/.agenda" (insert result))))) + (set-window-configuration wins))) diff --git a/bin/.local/bin/scripts/emacs/show-agenda.sh b/bin/.local/bin/scripts/emacs/show-agenda.sh new file mode 100755 index 0000000..6c2f96e --- /dev/null +++ b/bin/.local/bin/scripts/emacs/show-agenda.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +emacsclient -e "$(cat show-agenda.el)" +cat ~/.agenda diff --git a/bin/.local/bin/scripts/emacs/youtube.el b/bin/.local/bin/scripts/emacs/youtube.el new file mode 100644 index 0000000..5d062af --- /dev/null +++ b/bin/.local/bin/scripts/emacs/youtube.el @@ -0,0 +1,10 @@ +(defun play-video-from-clipboard () + "Play a video from the clipboard using mpv." + (interactive) + (let ((clipboard-contents (shell-command-to-string "xclip -o -selection clipboard"))) + (if (string-empty-p clipboard-contents) + (message "Clipboard is empty.") + (let ((python-env "~/.pyvenv/bin/activate")) + (shell-command (format "source %s && mpv %s" python-env clipboard-contents)))))) + +(global-set-key (kbd "C-c p") 'play-video-from-clipboard) diff --git a/bin/.local/bin/scripts/maimpick b/bin/.local/bin/scripts/maimpick new file mode 100755 index 0000000..da58635 --- /dev/null +++ b/bin/.local/bin/scripts/maimpick @@ -0,0 +1,14 @@ +#!/bin/sh + +# variables +output="$(date '+%y%m%d-%H%M-%S').png" +xclip_cmd="xclip -sel clip -t image/png" + +case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in + "a selected area") maim -u -s $HOME/Pictures/screenshots/pic-selected-"${output}" ;; + "current window") maim -q -d 0.2 -i "$(xdotool getactivewindow)" $HOME/Pictures/screenshots/pic-window-"${output}" ;; + "full screen") maim -q -d 0.2 $HOME/Pictures/screenshots/pic-full-"${output}" ;; + "a selected area (copy)") maim -u -s | ${xclip_cmd} ;; + "current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;; + "full screen (copy)") maim -q -d 0.2 | ${xclip_cmd} ;; +esac diff --git a/bin/.local/bin/scripts/rss.py b/bin/.local/bin/scripts/rss.py new file mode 100644 index 0000000..31e7ea9 --- /dev/null +++ b/bin/.local/bin/scripts/rss.py @@ -0,0 +1,43 @@ +import requests +from bs4 import BeautifulSoup + +# Function to find RSS feeds on a website +def find_rss_feeds(url): + try: + # Send an HTTP GET request to the website + response = requests.get(url) + + # Check if the request was successful + if response.status_code == 200: + # Parse the HTML content of the page using BeautifulSoup + soup = BeautifulSoup(response.text, 'html.parser') + + # Search for RSS feed links in the HTML using a common pattern + rss_links = [] + for link in soup.find_all('a', href=True): + href = link['href'] + if 'rss' in href or 'feed' in href or 'xml' in href: + rss_links.append(href) + + # If RSS feed links are found, return them + if rss_links: + return rss_links + else: + return "No RSS feeds found on this website." + + else: + return f"Failed to retrieve the website. Status code: {response.status_code}" + + except requests.exceptions.RequestException as e: + return f"Request failed: {e}" + +if __name__ == "__main__": + website_url = input("Enter the website URL: ") + rss_feeds = find_rss_feeds(website_url) + + if isinstance(rss_feeds, list): + print("RSS feeds found on the website:") + for rss_feed in rss_feeds: + print(rss_feed) + else: + print(rss_feeds) diff --git a/bin/.local/bin/scripts/school-video b/bin/.local/bin/scripts/school-video new file mode 100755 index 0000000..7931861 --- /dev/null +++ b/bin/.local/bin/scripts/school-video @@ -0,0 +1,29 @@ +#!/bin/bash + +# Prompt for YouTube URL using dmenu +url=$(echo "" | dmenu -p "URL: ") + +# Check if the user provided a valid URL +if [ -z "$url" ]; then + echo "Invalid URL. Exiting..." + exit 1 +fi + +# Set download directory +download_dir="/tmp/school" + +# Download video with captions in MP4 format using youtube-dlp +yt-dlp --write-sub --sub-lang en --format "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" -o "$download_dir/%(title)s.%(ext)s" "$url" + +# Get the filename of the downloaded video +filename=$(youtube-dlp --get-filename --format "%(title)s.%(ext)s" "$url" -o "$download_dir/%(title)s.%(ext)s") + +# Get the filename of the subtitles +subtitles_filename=$(yt-dlp --get-filename --format "%(title)s.%(ext)s" "$url" --sub-lang en -o "$download_dir/%(title)s.%(ext)s") + +# Open captions transcript in Emacs frame using dired +emacsclient -e -c "(dired \"$download_dir\")" & +emacsclient -e "(dired-do-find-regexp \"^$subtitles_filename\\.en\\.vtt$\")" + +# Play the downloaded video with mpv +mpv "$download_dir/$filename" diff --git a/bin/.local/bin/scripts/scratch.sh b/bin/.local/bin/scripts/scratch.sh new file mode 100755 index 0000000..3d9f3ec --- /dev/null +++ b/bin/.local/bin/scripts/scratch.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +modes=("fundamental" "org" "elisp") + +selected_mode=$(printf "%s\n" "${modes[@]}" | dmenu -p "Major mode: ") + +case $selected_mode in + "fundamental") + emacsclient -c -e "(bard/new-text-buffer)" + ;; + "org") + emacsclient -c -e "(bard/new-org-buffer)" + ;; + "elisp") + emacsclient -c -e "(bard/new-elisp-buffer)" + ;; + *) + echo "Invalid option selected." + exit 1; + ;; + esac diff --git a/bin/.local/bin/scripts/startpage.sh b/bin/.local/bin/scripts/startpage.sh new file mode 100755 index 0000000..7e95dc6 --- /dev/null +++ b/bin/.local/bin/scripts/startpage.sh @@ -0,0 +1 @@ +python3 -m http.server -b 127.0.0.1 8080 -d /home/bard/Code/vivendi-startpage/ & python3 -m http.server -b 127.0.0.1 6969 -d /home/bard/Code/operandi-startpage/ diff --git a/bin/.local/bin/scripts/status/battery.sh b/bin/.local/bin/scripts/status/battery.sh new file mode 100755 index 0000000..e027c68 --- /dev/null +++ b/bin/.local/bin/scripts/status/battery.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +# Prints all batteries, their percentage remaining and an emoji corresponding +# to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.). + +case $BLOCK_BUTTON in + 3) notify-send "🔋 Battery module" "🔋: discharging +🛑: not charging +♻: stagnant charge +🔌: charging +⚡: charged +❗: battery very low! +- Scroll to change adjust xbacklight." ;; + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +# Loop through all attached batteries and format the info +for battery in /sys/class/power_supply/BAT?*; do + # If non-first battery, print a space separator. + [ -n "${capacity+x}" ] && printf " " + # Sets up the status and capacity + case "$(cat "$battery/status" 2>&1)" in + "Full") status="⚡" ;; + "Discharging") status="🔋" ;; + "Charging") status="🔌" ;; + "Not charging") status="🛑" ;; + "Unknown") status="♻️" ;; + *) exit 1 ;; + esac + capacity="$(cat "$battery/capacity" 2>&1)" + # Will make a warn variable if discharging and low + [ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗" + # Prints the info + printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn +done && printf "\\n" diff --git a/bin/.local/bin/scripts/status/brightness.sh b/bin/.local/bin/scripts/status/brightness.sh new file mode 100755 index 0000000..821499c --- /dev/null +++ b/bin/.local/bin/scripts/status/brightness.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# One of the following: xrandr, xbacklight, kernel +METHOD="xbacklight" + +# Left click +if [[ "${BLOCK_BUTTON}" -eq 1 ]]; then + xbacklight -inc 5 +# Right click +elif [[ "${BLOCK_BUTTON}" -eq 3 ]]; then + xbacklight -dec 5 +fi + +URGENT_VALUE=10 + +if [[ "${METHOD}" = "xrandr" ]]; then + device="${BLOCK_INSTANCE:-primary}" + xrandrOutput=$(xrandr --verbose) + + if [[ "${device}" = "primary" ]]; then + device=$(echo "${xrandrOutput}" | grep 'primary' | head -n 1 | awk -F ' ' '{print $1}') + fi + + curBrightness=$(echo "${xrandrOutput}" | grep "${device}" -A 5 | grep -i "Brightness" | awk -F ':' '{print $2}') +elif [[ "${METHOD}" = "kernel" ]]; then + device="${BLOCK_INSTANCE:-intel_backlight}" + maxBrightness=$(cat /sys/class/backlight/${device}/max_brightness) + curBrightness=$(cat /sys/class/backlight/${device}/brightness) +elif [[ "${METHOD}" = "xbacklight" ]]; then + curBrightness=$(xbacklight -get) +fi + +if [[ "${curBrightness}" -le 0 ]]; then + exit +fi + +if [[ "${METHOD}" = "xrandr" ]]; then + percent=$(echo "scale=0;${curBrightness} * 100" | bc -l) +elif [[ "${METHOD}" = "kernel" ]]; then + percent=$(echo "scale=0;${curBrightness} * 100 / ${maxBrightness}" | bc -l) +elif [[ "${METHOD}" = "xbacklight" ]]; then + percent=$(echo "scale=0;${curBrightness}" | bc -l) +fi + +percent=${percent%.*} + +if [[ "${percent}" -le 0 ]]; then + exit +fi + +echo "${percent}% " +echo "${percent}% " +echo " " + +if [[ "${percent}" -le "${URGENT_VALUE}" ]]; then + exit 33 +fi diff --git a/bin/.local/bin/scripts/status/internet b/bin/.local/bin/scripts/status/internet new file mode 100755 index 0000000..6d0c513 --- /dev/null +++ b/bin/.local/bin/scripts/status/internet @@ -0,0 +1,33 @@ +#!/bin/sh + +# Show wifi 📶 and percent strength or 📡 if none. +# Show 🌐 if connected to ethernet or ❎ if none. +# Show 🔒 if a vpn connection is active + +case $BLOCK_BUTTON in + 1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;; + 3) notify-send "🌐 Internet module" "\- Click to connect +❌: wifi disabled +📡: no wifi connection +📶: wifi connection with quality +❎: no ethernet +🌐: ethernet working +🔒: vpn is active +" ;; + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +# Wifi +if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then + wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" +elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then + [ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="📡 " || wifiicon="❌ " +fi + +# Ethernet +[ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon="🌐" || ethericon="❎" + +# TUN +[ -n "$(cat /sys/class/net/tun*/operstate 2>/dev/null)" ] && tunicon=" 🔒" + +printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon" diff --git a/bin/.local/bin/scripts/status/mediaplayer b/bin/.local/bin/scripts/status/mediaplayer new file mode 100755 index 0000000..3fa1c38 --- /dev/null +++ b/bin/.local/bin/scripts/status/mediaplayer @@ -0,0 +1,149 @@ +#!/usr/bin/env perl +# Copyright (C) 2014 Tony Crisci <[email protected]> +# Copyright (C) 2015 Thiago Perrotta <perrotta dot thiago at poli dot ufrj dot br> + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# For all media players except mpd/cmus/rhythmbox, MPRIS support should be +# enabled and the playerctl binary should be in your path. +# See https://github.com/acrisci/playerctl + +# Set instance=NAME in the i3blocks configuration to specify a music player +# (playerctl will attempt to connect to org.mpris.MediaPlayer2.[NAME] on your +# DBus session). If instance is empty, playerctl will connect to the first +# supported media player it finds. + +use Time::HiRes qw(usleep); +use Env qw(BLOCK_INSTANCE); + +use constant DELAY => 50; # Delay in ms to let network-based players (spotify) reflect new data. +use constant SPOTIFY_STR => 'spotify'; + +my @metadata = (); +my $player_arg = ""; + +if ($BLOCK_INSTANCE) { + $player_arg = "--player='$BLOCK_INSTANCE'"; +} + +sub buttons { + my $method = shift; + + if($method eq 'mpd') { + if ($ENV{'BLOCK_BUTTON'} == 1) { + system("mpc prev &>/dev/null"); + } elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("mpc toggle &>/dev/null"); + } elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("mpc next &>/dev/null"); + } elsif ($ENV{'BLOCK_BUTTON'} == 4) { + system("mpc volume +10 &>/dev/null"); + } elsif ($ENV{'BLOCK_BUTTON'} == 5) { + system("mpc volume -10 &>/dev/null"); + } + } elsif ($method eq 'cmus') { + if ($ENV{'BLOCK_BUTTON'} == 1) { + system("cmus-remote --prev"); + } elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("cmus-remote --pause"); + } elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("cmus-remote --next"); + } + } elsif ($method eq 'playerctl') { + if ($ENV{'BLOCK_BUTTON'} == 1) { + system("playerctl $player_arg previous"); + usleep(DELAY * 1000) if $BLOCK_INSTANCE eq SPOTIFY_STR; + } elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("playerctl $player_arg play-pause"); + } elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("playerctl $player_arg next"); + usleep(DELAY * 1000) if $BLOCK_INSTANCE eq SPOTIFY_STR; + } elsif ($ENV{'BLOCK_BUTTON'} == 4) { + system("playerctl $player_arg volume 0.01+"); + } elsif ($ENV{'BLOCK_BUTTON'} == 5) { + system("playerctl $player_arg volume 0.01-"); + } + } elsif ($method eq 'rhythmbox') { + if ($ENV{'BLOCK_BUTTON'} == 1) { + system("rhythmbox-client --previous"); + } elsif ($ENV{'BLOCK_BUTTON'} == 2) { + system("rhythmbox-client --play-pause"); + } elsif ($ENV{'BLOCK_BUTTON'} == 3) { + system("rhythmbox-client --next"); + } + } +} + +sub cmus { + my @cmus = split /^/, qx(cmus-remote -Q); + if ($? == 0) { + foreach my $line (@cmus) { + my @data = split /\s/, $line; + if (shift @data eq 'tag') { + my $key = shift @data; + my $value = join ' ', @data; + + @metadata[0] = $value if $key eq 'artist'; + @metadata[1] = $value if $key eq 'title'; + } + } + + if (@metadata) { + buttons('cmus'); + + # metadata found so we are done + print(join ' - ', @metadata); + print("\n"); + exit 0; + } + } +} + +sub mpd { + my $data = qx(mpc current); + if (not $data eq '') { + buttons("mpd"); + print($data); + exit 0; + } +} + +sub playerctl { + buttons('playerctl'); + + my $artist = qx(playerctl $player_arg metadata artist 2>/dev/null); + chomp $artist; + # exit status will be nonzero when playerctl cannot find your player + exit(0) if $? || $artist eq '(null)'; + + push(@metadata, $artist) if $artist; + + my $title = qx(playerctl $player_arg metadata title); + exit(0) if $? || $title eq '(null)'; + + push(@metadata, $title) if $title; + + print substr(join(" - ", @metadata), 0, 40) if @metadata; +} + +sub rhythmbox { + buttons('rhythmbox'); + + my $data = qx(rhythmbox-client --print-playing --no-start); + print($data); +} + +playerctl; + +print("\n"); diff --git a/bin/.local/bin/scripts/status/memory b/bin/.local/bin/scripts/status/memory new file mode 100755 index 0000000..6c19de6 --- /dev/null +++ b/bin/.local/bin/scripts/status/memory @@ -0,0 +1,12 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;; + 2) setsid -f "$TERMINAL" -e btop ;; + 3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total. +- Click to show memory hogs. +- Middle click to open htop." ;; + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠%2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}' diff --git a/bin/.local/bin/scripts/status/player b/bin/.local/bin/scripts/status/player new file mode 100755 index 0000000..5e3fc54 --- /dev/null +++ b/bin/.local/bin/scripts/status/player @@ -0,0 +1,39 @@ +#!/bin/bash +#---------------------------------------------------------------------------------------------------- +# Requires playerctl - https://github.com/acrisci/playerctl +#---------------------------------------------------------------------------------------------------- +#Exit the script if no music players running +[[ "$(playerctl status 2>&1)" = "No players found" ]] && exit 33; + +# Define cursor icons +playIcon=""; +pauseIcon=" ⏸️"; +stopIcon=" ⏹️"; + +#User provided args for playerctl +ARGUMENTS="$INSTANCE"; + +#Mouse actions for the block +case $BLOCK_BUTTON in + 1) playerctl $ARGUMENTS previous ;; + 2) playerctl $ARGUMENTS play-pause ;; + 3) playerctl $ARGUMENTS next ;; + 4) playerctl $ARGUMENTS position 5+ ;; + 5) playerctl $ARGUMENTS position 5- ;; +esac + +#Define song info variables +playerStatus=$(playerctl $ARGUMENTS status); +songArtist="$(playerctl $ARGUMENTS metadata artist)"; +songArtist="${songArtist:-(Unknown Artist)}"; +songTitle=$(playerctl $ARGUMENTS metadata title); +songInfo="$songArtist - $songTitle"; + +#Display output +if [[ "${playerStatus^}" = "Paused" ]]; then + echo "$songInfo$pauseIcon"; +elif [[ "${playerStatus^}" = "Playing" ]]; then + echo "$songInfo$playIcon"; +elif [[ "${playerStatus^}" = "Stopped" ]]; then + echo "Stopped$stopIcon"; +fi diff --git a/bin/.local/bin/scripts/status/volume b/bin/.local/bin/scripts/status/volume new file mode 100755 index 0000000..e15dc20 --- /dev/null +++ b/bin/.local/bin/scripts/status/volume @@ -0,0 +1,39 @@ +#!/bin/sh + +# Prints the current volume or 🔇 if muted. + +case $BLOCK_BUTTON in + 1) setsid -w -f "$TERMINAL" -e alsamixer; pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;; + 2) pactl set-sink-mute @DEFAULT_SINK@ toggle ;; + 4) pactl set-sink-volume @DEFAULT_SINK@ 1%+ ;; + 5) pactl set-sink-volume @DEFAULT_SINK@ 1%- ;; + 3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted. +- Middle click to mute. +- Scroll to change." ;; + 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +vol="$(pactl get-sink-volume @DEFAULT_SINK@)" + +# If muted, print 🔇 and exit. +[ "$vol" != "${vol%\[MUTED\]}" ] && echo 🔇 && exit + +vol="${vol#Volume: }" + +split() { + # For ommiting the . without calling and external program. + IFS=$2 + set -- $1 + printf '%s' "$@" +} + +vol="$(printf "%.0f" "$(split "$vol" ".")")" + +case 1 in + $((vol >= 70)) ) icon="🔊" ;; + $((vol >= 30)) ) icon="🔉" ;; + $((vol >= 1)) ) icon="🔈" ;; + * ) echo 🔇 && exit ;; +esac + +echo "$icon$vol%" diff --git a/bin/.local/bin/scripts/status/volume-pulseaudio b/bin/.local/bin/scripts/status/volume-pulseaudio new file mode 100755 index 0000000..4cb6b9d --- /dev/null +++ b/bin/.local/bin/scripts/status/volume-pulseaudio @@ -0,0 +1,180 @@ +#!/usr/bin/env bash +# Displays the default device, volume, and mute status for i3blocks + +set -a + +AUDIO_HIGH_SYMBOL=${AUDIO_HIGH_SYMBOL:-'🔊'} + +AUDIO_MED_THRESH=${AUDIO_MED_THRESH:-50} +AUDIO_MED_SYMBOL=${AUDIO_MED_SYMBOL:-'🔉'} + +AUDIO_LOW_THRESH=${AUDIO_LOW_THRESH:-0} +AUDIO_LOW_SYMBOL=${AUDIO_LOW_SYMBOL:-'🔈'} + +AUDIO_MUTED_SYMBOL=${AUDIO_MUTED_SYMBOL:-'🔇'} + +AUDIO_DELTA=${AUDIO_DELTA:-5} + +DEFAULT_COLOR=${DEFAULT_COLOR:-"#000000"} +MUTED_COLOR=${MUTED_COLOR:-"#a0a0a0"} + +LONG_FORMAT=${LONG_FORMAT:-'${SYMB} ${VOL}% [${INDEX}:${NAME}]'} +SHORT_FORMAT=${SHORT_FORMAT:-'${SYMB} ${VOL}% [${INDEX}]'} +USE_ALSA_NAME=${USE_ALSA_NAME:-0} +USE_DESCRIPTION=${USE_DESCRIPTION:-0} + +SUBSCRIBE=${SUBSCRIBE:-0} + +MIXER=${MIXER:-""} +SCONTROL=${SCONTROL:-""} + +while getopts F:Sf:adH:M:L:X:T:t:C:c:i:m:s:h opt; do + case "$opt" in + S) SUBSCRIBE=1 ;; + F) LONG_FORMAT="$OPTARG" ;; + f) SHORT_FORMAT="$OPTARG" ;; + a) USE_ALSA_NAME=1 ;; + d) USE_DESCRIPTION=1 ;; + H) AUDIO_HIGH_SYMBOL="$OPTARG" ;; + M) AUDIO_MED_SYMBOL="$OPTARG" ;; + L) AUDIO_LOW_SYMBOL="$OPTARG" ;; + X) AUDIO_MUTED_SYMBOL="$OPTARG" ;; + T) AUDIO_MED_THRESH="$OPTARG" ;; + t) AUDIO_LOW_THRESH="$OPTARG" ;; + C) DEFAULT_COLOR="$OPTARG" ;; + c) MUTED_COLOR="$OPTARG" ;; + i) AUDIO_INTERVAL="$OPTARG" ;; + m) MIXER="$OPTARG" ;; + s) SCONTROL="$OPTARG" ;; + h) printf \ +"Usage: volume-pulseaudio [-S] [-F format] [-f format] [-p] [-a|-d] [-H symb] [-M symb] + [-L symb] [-X symb] [-T thresh] [-t thresh] [-C color] [-c color] [-i inter] + [-m mixer] [-s scontrol] [-j] [-h] +Options: +-F, -f\tOutput format (-F long format, -f short format) to use, with exposed variables: +\${SYMB}, \${VOL}, \${INDEX}, \${NAME} +-S\tSubscribe to volume events (requires persistent block, always uses long format) +-a\tUse ALSA name if possible +-d\tUse device description instead of name if possible +-H\tSymbol to use when audio level is high. Default: '$AUDIO_HIGH_SYMBOL' +-M\tSymbol to use when audio level is medium. Default: '$AUDIO_MED_SYMBOL' +-L\tSymbol to use when audio level is low. Default: '$AUDIO_LOW_SYMBOL' +-X\tSymbol to use when audio is muted. Default: '$AUDIO_MUTED_SYMBOL' +-T\tThreshold for medium audio level. Default: $AUDIO_MED_THRESH +-t\tThreshold for low audio level. Default: $AUDIO_LOW_THRESH +-C\tColor for non-muted audio. Default: $DEFAULT_COLOR +-c\tColor for muted audio. Default: $MUTED_COLOR +-i\tInterval size of volume increase/decrease. Default: $AUDIO_DELTA +-m\tUse the given mixer. +-s\tUse the given scontrol. +-h\tShow this help text +" && exit 0;; + esac +done + +if [[ -z "$MIXER" ]] ; then + MIXER="default" + if amixer -D pulse info >/dev/null 2>&1 ; then + MIXER="pulse" + fi +fi + +if [[ -z "$SCONTROL" ]] ; then + SCONTROL=$(amixer -D "$MIXER" scontrols | sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | head -n1) +fi + +CAPABILITY=$(amixer -D $MIXER get $SCONTROL | sed -n "s/ Capabilities:.*cvolume.*/Capture/p") + + +function move_sinks_to_new_default { + DEFAULT_SINK=$1 + pacmd list-sink-inputs | grep index: | grep -o '[0-9]\+' | while read SINK + do + pacmd move-sink-input $SINK $DEFAULT_SINK + done +} + +function set_default_playback_device_next { + inc=${1:-1} + num_devices=$(pacmd list-sinks | grep -c index:) + sink_arr=($(pacmd list-sinks | grep index: | grep -o '[0-9]\+')) + default_sink_index=$(( $(pacmd list-sinks | grep index: | grep -no '*' | grep -o '^[0-9]\+') - 1 )) + default_sink_index=$(( ($default_sink_index + $num_devices + $inc) % $num_devices )) + default_sink=${sink_arr[$default_sink_index]} + pacmd set-default-sink $default_sink + move_sinks_to_new_default $default_sink +} + +case "$BLOCK_BUTTON" in + 1) set_default_playback_device_next ;; + 2) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY toggle ;; + 3) set_default_playback_device_next -1 ;; + 4) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_DELTA%+ ;; + 5) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_DELTA%- ;; +esac + + +function print_format { + if [[ $markup == "pango" ]] ; then + output="<span color=\"$2\">$1</span>" + else + output=$1 + fi + + echo "$output" | envsubst '${SYMB}${VOL}${INDEX}${NAME}' +} + +function print_block { + ACTIVE=$(pacmd list-sinks | grep "state\: RUNNING" -B4 -A7 | grep "index:\|name:\|volume: \(front\|mono\)\|muted:") + [[ -z "$ACTIVE" ]] && ACTIVE=$(pacmd list-sinks | grep "index:\|name:\|volume: \(front\|mono\)\|muted:" | grep -A3 '*') + for name in INDEX NAME VOL MUTED; do + read $name + done < <(echo "$ACTIVE") + INDEX=$(echo "$INDEX" | grep -o '[0-9]\+') + VOL=$(echo "$VOL" | grep -o "[0-9]*%" | head -1 ) + VOL="${VOL%?}" + + NAME=$(echo "$NAME" | sed \ +'s/.*<.*\.\(.*\)>.*/\1/; t;'\ +'s/.*<\(.*\)>.*/\1/; t;'\ +'s/.*/unknown/') + + if [[ $USE_ALSA_NAME == 1 ]] ; then + ALSA_NAME=$(pacmd list-sinks |\ +awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\ +grep "alsa.name\|alsa.mixer_name" |\ +head -n1 |\ +sed 's/.*= "\(.*\)".*/\1/') + NAME=${ALSA_NAME:-$NAME} + elif [[ $USE_DESCRIPTION == 1 ]] ; then + DESCRIPTION=$(pacmd list-sinks |\ +awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\ +grep "device.description" |\ +head -n1 |\ +sed 's/.*= "\(.*\)".*/\1/') + NAME=${DESCRIPTION:-$NAME} + fi + + if [[ $MUTED =~ "no" ]] ; then + SYMB=$AUDIO_HIGH_SYMBOL + [[ $VOL -le $AUDIO_MED_THRESH ]] && SYMB=$AUDIO_MED_SYMBOL + [[ $VOL -le $AUDIO_LOW_THRESH ]] && SYMB=$AUDIO_LOW_SYMBOL + COLOR=$DEFAULT_COLOR + else + SYMB=$AUDIO_MUTED_SYMBOL + COLOR=$MUTED_COLOR + fi + + print_format "$LONG_FORMAT" $COLOR + if [[ $SUBSCRIBE != 1 ]] ; then + print_format "$SHORT_FORMAT" $COLOR + echo $COLOR + fi +} + +print_block +if [[ $SUBSCRIBE == 1 ]] ; then + while read -r EVENT; do + print_block + done < <(pactl subscribe | stdbuf -oL grep change) +fi diff --git a/bin/.local/bin/scripts/status/weather b/bin/.local/bin/scripts/status/weather new file mode 100755 index 0000000..ccf5847 --- /dev/null +++ b/bin/.local/bin/scripts/status/weather @@ -0,0 +1,54 @@ +#!/bin/sh + +# Displays today's precipication chance (☔), and daily low (🥶) and high (🌞). +# Usually intended for the statusbar. + +url="${WTTRURL:-wttr.in}" +weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport" + +# Get a weather report from 'wttr.in' and save it locally. +getforecast() { curl -sf "$url/$LOCATION?M" > "$weatherreport" || exit 1; } + +# Forecast should be updated only once a day. +checkforecast() { + [ -s "$weatherreport" ] && [ "$(stat -c %y "$weatherreport" 2>/dev/null | + cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] +} + +getprecipchance() { + echo "$weatherdata" | sed '16q;d' | # Extract line 16 from file + grep -wo "[0-9]*%" | # Find a sequence of digits followed by '%' + sort -rn | # Sort in descending order + head -1q # Extract first line +} + +getdailyhighlow() { + echo "$weatherdata" | sed '13q;d' | # Extract line 13 from file + grep -o "m\\([-+]\\)*[0-9]\\+" | # Find temperatures in the format "m<signed number>" + sed 's/[+m]//g' | # Remove '+' and 'm' + sort -g | # Sort in ascending order + sed -e 1b -e '$!d' # Extract the first and last lines +} + +readfile() { weatherdata="$(cat "$weatherreport")" ;} + +showweather() { + readfile + printf "☔%s 🥶%s°C 🌞%s°C\n" "$(getprecipchance)" $(getdailyhighlow) + # printf " %s %s°C %s°C\n" "$(getprecipchance)" $(getdailyhighlow) +} + +case $BLOCK_BUTTON in + 1) setsid -f "$TERMINAL" -e less -Sfr "$weatherreport" ;; + 2) getforecast && showweather ;; + 3) notify-send "🌈 Weather module" "\- Left click for full forecast. +- Middle click to update forecast. +☔: Chance of rain/snow +🥶: Daily low +🌞: Daily high" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +checkforecast || getforecast + +showweather diff --git a/bin/.local/bin/scripts/theme-switch.sh b/bin/.local/bin/scripts/theme-switch.sh new file mode 100755 index 0000000..2fe0c25 --- /dev/null +++ b/bin/.local/bin/scripts/theme-switch.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +# Define the available themes +themes=("modus vivendi" "modus operandi tinted" "ef spring" "melissa dark") + +# dmenu to prompt the user for i3 theme selection +selected_theme=$(printf "%s\n" "${themes[@]}" | dmenu -p "Select a theme:") + +# set the theme in the i3 configuration file +set_theme() { + sed -i "s/^set \$bg.*$/set \$bg $1/" ~/.config/i3/colors + sed -i "s/^set \$fg.*$/set \$fg $2/" ~/.config/i3/colors + sed -i "s/^set \$space.*$/set \$space $3/" ~/.config/i3/colors + sed -i "s/^set \$red.*$/set \$red $4/" ~/.config/i3/colors + sed -i "s/^set \$green.*$/set \$green $5/" ~/.config/i3/colors + sed -i "s/^set \$yellow.*$/set \$yellow $6/" ~/.config/i3/colors + sed -i "s/^set \$blue.*$/set \$blue $7/" ~/.config/i3/colors + sed -i "s/^set \$aqua.*$/set \$aqua $8/" ~/.config/i3/colors + sed -i "s/^set \$purple.*$/set \$purple $9/" ~/.config/i3/colors + sed -i "s/^set \$border.*$/set \$border ${10}/" ~/.config/i3/colors +} + +# paths for wallpapers per themes +melissa_wallpaper1="/home/bard/Pictures/wallpaper/Landscape/Favourite/yellowshinkansen.jpg " +melissa_wallpaper2="/home/bard/Pictures/wallpaper/Landscape/Favourite/teaworkers.jpg " +vivendi_wallpaper="/home/bard/Pictures/wallpaper/Stoic/dublinlibrary.jpg" +operandi_wallpaper="/home/bard/Pictures/wallpaper/Stoic/downton_abbey.jpg" +spring_wallpaper1="/home/bard/Pictures/wallpaper/Landscape/Favourite/chineselake.jpg" +spring_wallpaper2="/home/bard/Pictures/wallpaper/Art/TeahouseatKoishikawa.jpg" + +set_wallpaper() { + # Set wallpaper for monitor 1 + nitrogen --set-zoom-fill --head=0 --save $1 + + # Set wallpaper for monitor 2 + nitrogen --set-zoom-fill --head=1 --save $2 + + echo $1 + echo $2 +} + +# bg, fg. space. red. green, yellow, blue, aqua/cyan, purple, border +case $selected_theme in + "modus vivendi") + # set i3 theme + set_theme "#000000" "#ffffff" "#ffffff" "#ff5f59" "#44bc44" "#fec43f" "#2fafff" "#00d3d0" "#b6a0ff" "#ffffff" + # set xresources theme + xrdb -merge /home/bard/Xresources.vivendi + # set emacs theme + selected_emacs_theme="modus-vivendi" + emacsclient -e "(setq command-line-args-left (list \"$selected_emacs_theme\"))" -e "(load-file \"/home/bard/.local/bin/scripts/emacs-theme.el\")" + # set wallpaper + set_wallpaper $vivendi_wallpaper $vivendi_wallpaper + ;; + "modus operandi tinted") + # set i3 theme + set_theme "#fbf7f0" "#000000" "#000000" "#a60000" "#006800" "#6f5500" "#0031a9" "#721045" "#005e8b" "#721045" + # set xresources theme + xrdb -merge /home/bard/Xresources.operandi + # set emacs theme + selected_emacs_theme="modus-operandi-tinted" + emacsclient -e "(setq command-line-args-left (list \"$selected_emacs_theme\"))" -e "(load-file \"/home/bard/.local/bin/scripts/emacs-theme.el\")" + # set wallpaper + set_wallpaper $operandi_wallpaper $operandi_wallpaper + ;; + "ef spring") + # set i3 theme + set_theme "#34494a" "#f6fff9" "#f6fff9" "#c42d2f" "#1a870f" "#a45f22" "#375cc6" "#1f6fbf" "#9435b4" "#9d5e7a" + # set xresources theme + xrdb -merge /home/bard/Xresources.spring + # set emacs theme + selected_emacs_theme="ef-spring" + emacsclient -e "(setq command-line-args-left (list \"$selected_emacs_theme\"))" -e "(load-file \"/home/bard/.local/bin/scripts/emacs-theme.el\")" + # set wallpaper + set_wallpaper $spring_wallpaper1 $spring_wallpaper2 + ;; + "melissa dark") + # set i3 theme + set_theme "#352718" "#e8e4b1" "#e8e4b1" "#ff7f7f" "#6fd560" "#ffa21f" "#57aff6" "#6fcad0" "#f0aac5" "#ffa21f" + # set xresources theme + xrdb -merge /home/bard/Xresources.melissa-dark + # set emacs theme + selected_emacs_theme="ef-melissa-dark" + emacsclient -e "(setq command-line-args-left (list \"$selected_emacs_theme\"))" -e "(load-file \"/home/bard/.local/bin/scripts/emacs-theme.el\")" + # set wallpaper + set_wallpaper $melissa_wallpaper1 $melissa_wallpaper2 + ;; + *) + echo "Invalid theme selected." + ;; +esac + +# Reload i3 to apply the changes +i3-msg reload + +# restart compositor +killall picom +picom --experimental-backends --daemon diff --git a/bin/.local/bin/scripts/tmux-sessionizer b/bin/.local/bin/scripts/tmux-sessionizer new file mode 100755 index 0000000..f66aafb --- /dev/null +++ b/bin/.local/bin/scripts/tmux-sessionizer @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ "$#" -eq 1 ]; then + selected=$1 +else + selected=$(find ~/Notes/Org-Roam/ ~/Code/ ~/Documents/ -mindepth 1 -maxdepth 1 -type d | fzf) +fi + +if [ -z "$selected" ]; then + exit 0 +fi + +selected_name=$(basename "$selected" | tr . _) +tmux_running=$(pgrep tmux) + +if [ -z "$TMUX" ] && [ -z "$tmux_running" ]; then + tmux new-session -s "$selected_name" -c "$selected" + exit 0 +fi + +if ! tmux has-session -t="$selected_name" 2> /dev/null; then + tmux new-session -ds "$selected_name" -c "$selected" +fi + +# tmux switch-client -t "$selected" +tmux attach diff --git a/bin/.local/bin/scripts/wallpaper.sh b/bin/.local/bin/scripts/wallpaper.sh new file mode 100755 index 0000000..18e1f42 --- /dev/null +++ b/bin/.local/bin/scripts/wallpaper.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Path to the directory containing your wallpapers +WALLPAPER_DIRS="$HOME/Pictures/wallpaper/\n$HOME/Pictures/Anime-Wallpaper/" + +WALLPAPER_DIR=$(echo -e "$WALLPAPER_DIRS" | dmenu -p "Select directory: ") + +# Use nsxiv to mark an image +selected_wallpaper=$(nsxiv -t -r -o $WALLPAPER_DIR) + +# Options for display modes +OPTIONS="Tiled\nZoom Filled\nCentered" + +# Prompt user to select a display mode +selected_mode=$(echo -e "$OPTIONS" | dmenu -p "Select Display Mode:") + +# Command to set wallpaper based on selected mode +case "$selected_mode" in + "Tiled") + feh --bg-tile "$selected_wallpaper" + ;; + "Zoom Filled") + feh --bg-fill "$selected_wallpaper" + ;; + "Centered") + feh --bg-center "$selected_wallpaper" + ;; + *) + echo "Invalid option selected." + exit 1 + ;; +esac + +echo "Wallpaper set successfully." diff --git a/bin/.local/bin/scripts/webcam b/bin/.local/bin/scripts/webcam new file mode 100755 index 0000000..bd4a278 --- /dev/null +++ b/bin/.local/bin/scripts/webcam @@ -0,0 +1,3 @@ +#!/bin/sh + +ffplay -window_title Webcam -fast /dev/video0 diff --git a/bin/.local/bin/scripts/youtube.py b/bin/.local/bin/scripts/youtube.py new file mode 100644 index 0000000..54168e6 --- /dev/null +++ b/bin/.local/bin/scripts/youtube.py @@ -0,0 +1,22 @@ +import re + +# Define the regular expression pattern for matching links +pattern = r'https://youtube\.com/@\w+' + +# Initialize an empty list to store the matched links +links = [] + +# Open the file for reading +with open('trimmed.html', 'r') as file: + # Iterate through each line in the file + for line in file: + # Search for links that match the pattern in the current line + matches = re.findall(pattern, line) + + # If matches were found, add them to the links list + if matches: + links.extend(matches) + +# Print the list of matched links +for link in links: + print(link) diff --git a/bin/.local/bin/scripts/youtube.sh b/bin/.local/bin/scripts/youtube.sh new file mode 100755 index 0000000..d7e681a --- /dev/null +++ b/bin/.local/bin/scripts/youtube.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Define a function to extract RSS feed URL using curl and sed +extract_rss_url() { + youtube_channel_url="$1" + rss_url=$(curl -s "$youtube_channel_url" | sed -n 's/.*title="RSS"\s\+href="\([^"]\+\).*/\1/p') + echo "$rss_url" +} + +# Add YouTube channel URLs to this array +youtube_channel_urls=( + "https://www.youtube.com/@jvscholz" + "https://www.youtube.com/@yerbamatelab/videos" +) + +# Loop through the array and extract RSS feed URLs +for url in "${youtube_channel_urls[@]}"; do + rss_feed_url=$(extract_rss_url "$url") + if [ -n "$rss_feed_url" ]; then + echo "Channel: $url" + echo "RSS Feed: $rss_feed_url" + else + echo "No RSS feed found for $url" + fi +done |
