From 596a773dd2fd0d082c782690bcd0c3a11a88cbad Mon Sep 17 00:00:00 2001 From: "Matthieu Fortin (CPC/CCP)" Date: Thu, 21 Nov 2024 15:20:16 -0500 Subject: [PATCH] Final commit, ready for tagging --- bash/.bashrc | 4 +- geany/.config/geany/geany.conf | 2 +- geany/.config/geany/session.conf | 5 +- hypr/.config/hypr/hyprland.conf | 2 + scripts/.local/bin/autoscript | 4 +- scripts/.local/bin/autoscriptmenu | 2 +- scripts/.local/bin/getpid | 6 ++ scripts/.local/bin/menu' | 3 + scripts/.local/bin/rmscript | 11 +++ scripts/.local/bin/rmscriptmenu | 8 ++ scripts/.local/bin/rofi-emoji | 137 ++++++++++++++++++++++++++++++ 11 files changed, 176 insertions(+), 8 deletions(-) create mode 100755 scripts/.local/bin/menu' create mode 100755 scripts/.local/bin/rmscript create mode 100755 scripts/.local/bin/rmscriptmenu create mode 100755 scripts/.local/bin/rofi-emoji diff --git a/bash/.bashrc b/bash/.bashrc index 6d93a6f..4a833c1 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -322,9 +322,9 @@ up() { cd () { if [ -n "$1" ]; then - builtin cd "$@" && ls + builtin cd "$@" && la else - builtin cd ~ && ls + builtin cd ~ && la fi } diff --git a/geany/.config/geany/geany.conf b/geany/.config/geany/geany.conf index 305ba19..bd5286b 100644 --- a/geany/.config/geany/geany.conf +++ b/geany/.config/geany/geany.conf @@ -22,7 +22,7 @@ tab_pos_msgwin=0 tab_label_length=1000 show_indent_guide=false show_white_space=false -show_line_endings=false +show_line_endings=true show_line_endings_only_when_differ=false show_markers_margin=true show_linenumber_margin=true diff --git a/geany/.config/geany/session.conf b/geany/.config/geany/session.conf index 80d5a84..eb8990d 100644 --- a/geany/.config/geany/session.conf +++ b/geany/.config/geany/session.conf @@ -1,14 +1,15 @@ [files] -recent_files= +recent_files=/home/matt/TCLI-Data-Repo/CMPFOR/Course-Documentation/CDD_COMFOR_Final_2016.txt; recent_projects= current_page=0 +FILE_NAME_0=16572;None;0;EUTF-8;1;1;0;%2Fhome%2Fmatt%2FTCLI-Data-Repo%2FCMPFOR%2FCourse-Documentation%2FCDD_COMFOR_Final_2016.txt;0;4 [project] session_file= project_file_path=/home/matt/Projects [geany] -treeview_position=241 +treeview_position=0 msgwindow_position=794 geometry=0;0;1906;1026;1; sidebar_page=0 diff --git a/hypr/.config/hypr/hyprland.conf b/hypr/.config/hypr/hyprland.conf index 06aa358..08a960b 100644 --- a/hypr/.config/hypr/hyprland.conf +++ b/hypr/.config/hypr/hyprland.conf @@ -17,6 +17,7 @@ monitor=,preferred,auto,1 # Set programs that you use $terminal = kitty $fileManager = dolphin +$emoji = rofi -mode emoji -show emoji -kb-secondary-copy '' -kb-custom-1 Ctrl+c $menu = ~/.config/rofi/launcher.sh #$menu = ~/.config/rofi/launchers/type-2/launcher.sh #$menu = wofi --show drun @@ -228,6 +229,7 @@ bind = $mainMod, O, layoutmsg, swapwithmaster bind = $mainMod, P, pseudo, # dwindle bind = $mainMod, J, togglesplit, # dwindle +bindd = $mainMod, period, Emoji selector, exec, $emoji bindd = $mainMod, I, Switch between master/dwingle, exec, $HOME/.config/hypr/switchlayout.sh bindd = $mainMod, S, Launch menu to modify/create script, exec, autoscriptmenu diff --git a/scripts/.local/bin/autoscript b/scripts/.local/bin/autoscript index 1420999..8c3a6d4 100755 --- a/scripts/.local/bin/autoscript +++ b/scripts/.local/bin/autoscript @@ -15,7 +15,7 @@ set -euo pipefail EOM - chmod +x $SCRIPT_FILE + chmod +x "$SCRIPT_FILE" fi -$EDITOR $SCRIPT_FILE +$EDITOR "$SCRIPT_FILE" diff --git a/scripts/.local/bin/autoscriptmenu b/scripts/.local/bin/autoscriptmenu index e1ea397..83f1e21 100755 --- a/scripts/.local/bin/autoscriptmenu +++ b/scripts/.local/bin/autoscriptmenu @@ -2,5 +2,5 @@ set -euo pipefail #selected=$(ls "$HOME/.local/bin" | tofi --prompt-text "Select script") -selected=$(find "$HOME/.local/bin" -maxdepth 1 -type f -exec basename {} \; | sort | wofi --dmenu --sort-order=alphabetical -p "Select Script: ") +selected=$(find -L "$HOME/.local/bin" -maxdepth 1 -type f -exec basename {} \; | sort | rofi -dmenu "Select Script: ") autoscript "$selected" diff --git a/scripts/.local/bin/getpid b/scripts/.local/bin/getpid index 69a8a0f..6bbf602 100755 --- a/scripts/.local/bin/getpid +++ b/scripts/.local/bin/getpid @@ -1,6 +1,12 @@ #!/bin/bash set -euo pipefail +if [ $# -eq 0 ]; then + echo "Error: No arguments provided." + echo "Usage: getpid " + exit 1 +fi + srch="$1" ps -ef | awk -v this="$0" -v search="$srch" '{ diff --git a/scripts/.local/bin/menu' b/scripts/.local/bin/menu' new file mode 100755 index 0000000..febba30 --- /dev/null +++ b/scripts/.local/bin/menu' @@ -0,0 +1,3 @@ +#!/bin/bash +set -euo pipefail + diff --git a/scripts/.local/bin/rmscript b/scripts/.local/bin/rmscript new file mode 100755 index 0000000..aecefa8 --- /dev/null +++ b/scripts/.local/bin/rmscript @@ -0,0 +1,11 @@ +#!/bin/bash +set -euo pipefail + +# Check if at least one argument is provided +if [ $# -eq 0 ] || [ ! -e "$HOME/.local/bin/$1" ]; then + echo "Error: No script file provided or script does not exist." + echo "Usage: rmscript " + exit 1 # Exit with a non-zero status indicating an error +fi + +rm -f "$HOME/.local/bin/$1" && echo "$1 erased." diff --git a/scripts/.local/bin/rmscriptmenu b/scripts/.local/bin/rmscriptmenu new file mode 100755 index 0000000..69ad88f --- /dev/null +++ b/scripts/.local/bin/rmscriptmenu @@ -0,0 +1,8 @@ +#!/bin/bash +set -euo pipefail + +selected=$(find -L "$HOME/.local/bin" -type f -exec basename {} \; | sort | rofi -dmenu -p "Select Script to delete: ") + +[[ -z "$selected" ]] && exit + +rmscript "$selected" diff --git a/scripts/.local/bin/rofi-emoji b/scripts/.local/bin/rofi-emoji new file mode 100755 index 0000000..367d986 --- /dev/null +++ b/scripts/.local/bin/rofi-emoji @@ -0,0 +1,137 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Source: https://gist.github.com/Tadly/0741821d3694deaec1ee454a95c591fa +# +# Use rofi to pick emoji because that's what this +# century is about apparently... +# +# Requirements: +# rofi, xsel, xdotool, curl, xmllint +# +# Usage: +# 1. Download all emoji +# $ rofi-emoji --download +# +# 2. Run it! +# $ rofi-emoji +# +# Notes: +# * You'll need a emoji font like "Noto Emoji" or "EmojiOne". +# * Confirming an item will automatically paste it WITHOUT +# writing it to your clipboard. +# * Ctrl+C will copy it to your clipboard WITHOUT pasting it. +# + +# Where to save the emojis file. +EMOJI_FILE="$HOME/.cache/emojis.txt" + +# Urls of emoji to download. +# You can remove what you don't need. +URLS=( +'https://emojipedia.org/people/' +'https://emojipedia.org/nature/' +'https://emojipedia.org/food-drink/' +'https://emojipedia.org/activity/' +'https://emojipedia.org/travel-places/' +'https://emojipedia.org/objects/' +'https://emojipedia.org/symbols/' +'https://emojipedia.org/flags/' +) + + +function notify() { + if [ "$(command -v notify-send)" ]; then + notify-send "$1" "$2" + fi +} + + +function download() { + notify "$(basename "$0")" 'Downloading all emoji for your pleasure' + + echo "" > "$EMOJI_FILE" + + for url in "${URLS[@]}"; do + echo "Downloading: $url" + + # Download the list of emoji and remove all the junk around it + emojis=$(curl -s "$url" | \ + xmllint --html \ + --xpath '//ul[@class="emoji-list"]' - 2>/dev/null) + + # Get rid of starting/closing ul tags + emojis=$(echo "$emojis" | head -n -1 | tail -n +1) + + # Extract the emoji and its description + emojis=$(echo "$emojis" | \ + sed -rn 's/.*(.*)<\/span> (.*)<\/a><\/li>/\1 \2/p') + + echo "$emojis" >> "$EMOJI_FILE" + done + + notify "$(basename "$0")" "We're all set!" +} + +function rofi_menu() { # {{{ + rofi -width 25 -lines 7 -dmenu -i -p 'emoji: ' \ + -kb-row-tab '' \ + -kb-row-select Tab \ + -kb-custom-1 Ctrl+c +} +# }}} + +function repeat() { # {{{ + local rplc str="$1" count="$2" + rplc="$(printf "%${count}s")" + echo "${rplc// /"$str"}" +} +# }}} + +function toclipboard() { # {{{ + xclip -i -selection primary + xclip -o -selection primary | xclip -i -selection clipboard +} +# }}} + +function display() { + local emoji line exit_code quantifier + + emoji=$(cat "$EMOJI_FILE" | grep -v '#' | grep -v '^[[:space:]]*$') + line="$(echo "$emoji" | rofi_menu)" + exit_code=$? + + line=($line) + last=${line[${#line[@]}-1]} + quantifier="${last:${#last}-1:1}" + if [[ ! "$quantifier" =~ [0-9] ]]; then + quantifier=1 + fi + emoijs="$(repeat "${line[0]}" "$quantifier")" + + if [ $exit_code == 0 ]; then + xdotool type --clearmodifiers "$emoijs" + echo -n "$emoijs" | toclipboard + elif [ $exit_code == 10 ]; then + echo -n "$emoijs" | toclipboard + fi +} + + +# Some simple argparsing +if [[ "$1" =~ -D|--download ]]; then + download + exit 0 +elif [[ "$1" =~ -h|--help ]]; then + echo "usage: $0 [-D|--download]" + exit 0 +fi + +# Download all emoji if they don't exist yet +if [ ! -f "$EMOJI_FILE" ]; then + download +fi + +# display displays :) +display +