diff --git a/scripts/globalcontrol.sh b/scripts/globalcontrol.sh new file mode 100644 index 00000000..3638e9fe --- /dev/null +++ b/scripts/globalcontrol.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env sh + +# wallpaper var +EnableWallDcol=0 +ConfDir="${XDG_CONFIG_HOME:-$HOME/.config}" +CloneDir="$HOME/Hyprdots" +ThemeCtl="$ConfDir/hypr/theme.ctl" +cacheDir="$HOME/.cache/hyprdots" + +# theme var +gtkTheme=`gsettings get org.gnome.desktop.interface gtk-theme | sed "s/'//g"` +gtkMode=`gsettings get org.gnome.desktop.interface color-scheme | sed "s/'//g" | awk -F '-' '{print $2}'` + +# hypr var +hypr_border=`hyprctl -j getoption decoration:rounding | jq '.int'` +hypr_width=`hyprctl -j getoption general:border_size | jq '.int'` + +# notification var +#ncolor="-h string:bgcolor:#191724 -h string:fgcolor:#faf4ed -h string:frcolor:#56526e" +# +#if [ "${gtkMode}" == "light" ] ; then +# ncolor="-h string:bgcolor:#f4ede8 -h string:fgcolor:#9893a5 -h string:frcolor:#908caa" +#fi + +# pacman fns +pkg_installed() +{ + local PkgIn=$1 + + if pacman -Qi $PkgIn &> /dev/null + then + #echo "${PkgIn} is already installed..." + return 0 + else + #echo "${PkgIn} is not installed..." + return 1 + fi +} + +get_aurhlpr() +{ + if pkg_installed yay + then + aurhlpr="yay" + elif pkg_installed paru + then + aurhlpr="paru" + fi +} + +check(){ + local Pkg_Dep=$(for PkgIn in "$@"; do ! pkg_installed $PkgIn && echo "$PkgIn"; done) + +if [ -n "$Pkg_Dep" ]; then echo -e "$0 Dependencies:\n$Pkg_Dep" + read -p "ENTER to install (Other key: Cancel): " ans + if [ -z "$ans" ]; then get_aurhlpr ; $aurhlpr -S $Pkg_Dep + else echo "Skipping installation of packages" ;exit 1 + fi +fi +} diff --git a/scripts/screenshot.sh b/scripts/screenshot.sh new file mode 100644 index 00000000..4f043743 --- /dev/null +++ b/scripts/screenshot.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env sh + +if [ -z "$XDG_PICTURES_DIR" ] ; then + XDG_PICTURES_DIR="$HOME/Pictures" +fi + +ScrDir=`dirname "$(realpath "$0")"` +source $ScrDir/globalcontrol.sh +swpy_dir="${XDG_CONFIG_HOME:-$HOME/.config}/swappy" +save_dir="${2:-$XDG_PICTURES_DIR/Screenshots}" +save_file=$(date +'%y%m%d_%Hh%Mm%Ss_screenshot.png') +temp_screenshot="/tmp/screenshot.png" + +mkdir -p $save_dir +mkdir -p $swpy_dir +echo -e "[Default]\nsave_dir=$save_dir\nsave_filename_format=$save_file" > $swpy_dir/config + +function print_error +{ +cat << "EOF" + ./screenshot.sh + ...valid actions are... + p : print all screens + s : snip current screen + sf : snip current screen (frozen) + m : print focused monitor +EOF +} + +case $1 in +p) # print all outputs + grimblast copysave screen $temp_screenshot && swappy -f $temp_screenshot ;; +s) # drag to manually snip an area / click on a window to print it + grimblast copysave area $temp_screenshot && swappy -f $temp_screenshot ;; +sf) # frozen screen, drag to manually snip an area / click on a window to print it + grimblast --freeze copysave area $temp_screenshot && swappy -f $temp_screenshot ;; +m) # print focused monitor + grimblast copysave output $temp_screenshot && swappy -f $temp_screenshot ;; +*) # invalid option + print_error ;; +esac + +rm "$temp_screenshot" + +if [ -f "$save_dir/$save_file" ] ; then + dunstify "t1" -a "saved in $save_dir" -i "$save_dir/$save_file" -r 91190 -t 2200 +fi + diff --git a/scripts/spotifyvolumecontrol.sh b/scripts/spotifyvolumecontrol.sh new file mode 100644 index 00000000..094c05ab --- /dev/null +++ b/scripts/spotifyvolumecontrol.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# define the name of the player +PLAYER="spotify" + +# function to increase Spotify volume +increase_volume() { + playerctl --player="$PLAYER" volume 0.05+ + VOLUME=$(playerctl volume --player $PLAYER) + dunstify -a Spotify -r 2 -t 1500 -i /usr/share/icons/Tela-circle-black/scalable/apps/com.spotify.Client.svg "Volume increased" "$VOLUME" +} + +# function to decrease Spotify volume +decrease_volume() { + playerctl --player="$PLAYER" volume 0.05- + VOLUME=$(playerctl volume --player $PLAYER) + dunstify -a Spotify -r 2 -t 1500 -i /usr/share/icons/Tela-circle-black/scalable/apps/com.spotify.Client.svg "Volume decreased" "$VOLUME" +} + +# check for the argument and perform the corresponding action +case "$1" in + "up") + increase_volume + ;; + "down") + decrease_volume + ;; + *) + exit 1 + ;; +esac diff --git a/scripts/swww.sh b/scripts/swww.sh new file mode 100644 index 00000000..74b13176 --- /dev/null +++ b/scripts/swww.sh @@ -0,0 +1,40 @@ +#!/bin/bash +## /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## +# Pywal Colors for current wallpaper + +# Define the path to the swww cache directory +cache_dir="$HOME/.cache/swww/" + +# Get a list of monitor outputs +monitor_outputs=($(ls "$cache_dir")) + +# Initialize a flag to determine if the ln command was executed +ln_success=false + +# Loop through monitor outputs +for output in "${monitor_outputs[@]}"; do + # Construct the full path to the cache file + cache_file="$cache_dir$output" + + # Check if the cache file exists for the current monitor output + if [ -f "$cache_file" ]; then + # Get the wallpaper path from the cache file + wallpaper_path=$(cat "$cache_file") + + # Copy the wallpaper to the location Rofi can access + if ln -sf "$wallpaper_path" "$HOME/.config/rofi/.current_wallpaper"; then + ln_success=true # Set the flag to true upon successful execution + fi + + break # Exit the loop after processing the first found monitor output + fi +done + +# Check the flag before executing further commands +if [ "$ln_success" = true ]; then + # execute pywal + # wal -i "$wallpaper_path" + + # execute pywal skipping tty and terminal changes + wal -i "$wallpaper_path" -s -t & +fi diff --git a/scripts/volumecontrol.sh b/scripts/volumecontrol.sh new file mode 100644 index 00000000..8dd31b9c --- /dev/null +++ b/scripts/volumecontrol.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env sh + +ScrDir=`dirname "$(realpath "$0")"` +source $ScrDir/globalcontrol.sh + + +# define functions + +function print_error +{ +cat << "EOF" + ./volumecontrol.sh -[device] + ...valid device are... + i -- [i]nput decive + o -- [o]utput device + ...valid actions are... + i -- ncrease volume [+5] + d -- ecrease volume [-5] + m -- ute [x] +EOF +} + +function notify_vol +{ + vol=`pamixer $srce --get-volume | cat` + angle="$(( (($vol+2)/5) * 5 ))" + ico="${icodir}/vol-${angle}.svg" + bar=$(seq -s "." $(($vol / 15)) | sed 's/[0-9]//g') + dunstify "t2" -a "$vol$bar" "$nsink" -i $ico -r 91190 -t 800 +} + +function notify_mute +{ + mute=`pamixer $srce --get-mute | cat` + if [ "$mute" == "true" ] ; then + dunstify "t2" -a "muted" "$nsink" -i ${icodir}/muted-${dvce}.svg -r 91190 -t 800 + else + dunstify "t2" -a "unmuted" "$nsink" -i ${icodir}/unmuted-${dvce}.svg -r 91190 -t 800 + fi +} + + +# set device source + +while getopts io SetSrc +do + case $SetSrc in + i) nsink=$(pamixer --list-sources | grep "_input." | head -1 | awk -F '" "' '{print $NF}' | sed 's/"//') + srce="--default-source" + dvce="mic" ;; + o) nsink=$(pamixer --get-default-sink | grep "_output." | awk -F '" "' '{print $NF}' | sed 's/"//') + srce="" + dvce="speaker" ;; + esac +done + +if [ $OPTIND -eq 1 ] ; then + print_error +fi + + +# set device action + +shift $((OPTIND -1)) +step="${2:-5}" +icodir="~/.config/dunst/icons/vol" + +case $1 in + i) pamixer $srce -i ${step} + notify_vol ;; + d) pamixer $srce -d ${step} + notify_vol ;; + m) pamixer $srce -t + notify_mute ;; + *) print_error ;; +esac + diff --git a/scripts/wallpaper.sh b/scripts/wallpaper.sh new file mode 100644 index 00000000..cb711e15 --- /dev/null +++ b/scripts/wallpaper.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +DIR=~/.config/wallpapers +PICS=($(ls ${DIR})) + +RANDOMPICS=${PICS[ $RANDOM % ${#PICS[@]} ]} + +if [[ $(pidof swww) ]]; then + pkill swww +fi + +swww query || swww init + +#change-wallpaper using swww +swww img ${DIR}/${RANDOMPICS} --transition-fps 60 --transition-type any --transition-duration 2 + +wal -i ~/.config/rofi/.current_wallpaper + +~/.config/hypr/scripts/swww.sh + +_ps=(waybar) +for _prs in "${_ps[@]}"; do + if pidof "${_prs}" >/dev/null; then + pkill "${_prs}" + fi +done + +sleep 1 +# Relaunch waybar +waybar & + diff --git a/scripts/wallpaperselect.sh b/scripts/wallpaperselect.sh new file mode 100644 index 00000000..78d862c7 --- /dev/null +++ b/scripts/wallpaperselect.sh @@ -0,0 +1,99 @@ + +#!/bin/bash +## /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## +# This script for selecting wallpapers (SUPER W) + +scriptsDir="$HOME/.config/hypr/scripts" + +# WALLPAPERS PATH +wallDIR="/home/crux/.config/wallpapers" + +# Transition config +FPS=60 +TYPE="wipe" +DURATION=2 +BEZIER=".43,1.19,1,.4" +SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION" + +# Check if swaybg is running +if pidof swaybg > /dev/null; then + pkill swaybg +fi + +# Retrieve image files +PICS=($(ls "${wallDIR}" | grep -E ".jpg$|.jpeg$|.png$|.gif$")) +RANDOM_PIC="${PICS[$((RANDOM % ${#PICS[@]}))]}" +RANDOM_PIC_NAME="${#PICS[@]}. random" + +# Rofi command +rofi_command="rofi -show -dmenu -theme $HOME/.config/rofi/themes/wallpaper-select.rasi" + +menu() { + for i in "${!PICS[@]}"; do + # Displaying .gif to indicate animated images + if [[ -z $(echo "${PICS[$i]}" | grep .gif$) ]]; then + printf "$(echo "${PICS[$i]}" | cut -d. -f1)\x00icon\x1f${wallDIR}/${PICS[$i]}\n" + else + printf "${PICS[$i]}\n" + fi + done + + printf "$RANDOM_PIC_NAME\n" +} + +swww query || swww init + +main() { + choice=$(menu | ${rofi_command}) + + # No choice case + if [[ -z $choice ]]; then + exit 0 + fi + + # Random choice case + if [ "$choice" = "$RANDOM_PIC_NAME" ]; then + swww img "${wallDIR}/${RANDOM_PIC}" $SWWW_PARAMS + exit 0 + fi + + # Find the index of the selected file + pic_index=-1 + for i in "${!PICS[@]}"; do + filename=$(basename "${PICS[$i]}") + if [[ "$filename" == "$choice"* ]]; then + pic_index=$i + break + fi + done + + if [[ $pic_index -ne -1 ]]; then + swww img "${wallDIR}/${PICS[$pic_index]}" $SWWW_PARAMS + else + echo "Image not found." + exit 1 + fi +} + +# Check if rofi is already running +if pidof rofi > /dev/null; then + pkill rofi + exit 0 +fi + +main + +wal -i ~/.config/rofi/.current_wallpaper + +~/.config/hypr/scripts/swww.sh + +_ps=(waybar) +for _prs in "${_ps[@]}"; do + if pidof "${_prs}" >/dev/null; then + pkill "${_prs}" + fi +done + +sleep 1 +# Relaunch waybar +waybar &