updates
This commit is contained in:
1 parent
0c6c3c6835
commit
f5f74bbd9e
32 files changed
+2257
-938
No files matched your search
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
PREV_STATUS="Unknown" # Initialize previous status
|
||||
FULL_CHARGE_NOTIFIED=0
|
||||
LOW_BATTERY_NOTIFIED=0
|
||||
|
||||
while true; do
|
||||
STATUS=$(cat /sys/class/power_supply/AC/online 2>/dev/null) # Get charger status using power supply directory
|
||||
|
||||
if [ "$STATUS" != "$PREV_STATUS" ]; then # Check if the charger status has changed
|
||||
FULL_CHARGE_NOTIFIED=0 # Reset full charge notification state when charger status changes
|
||||
LOW_BATTERY_NOTIFIED=0 # Reset low battery notification state when charger status changes
|
||||
PREV_STATUS="$STATUS" # Update previous status
|
||||
fi
|
||||
|
||||
# Get battery percentage and remaining time using acpi
|
||||
BATTERY_INFO=$(acpi)
|
||||
PERCENT=$(echo "$BATTERY_INFO" | awk -F ',|%' '{print $2}')
|
||||
|
||||
if [ "$STATUS" == "1" ] && [ "$PERCENT" -eq 100 ] && [ "$FULL_CHARGE_NOTIFIED" -eq 0 ]; then # Check if the battery is charging and the percentage is 100%
|
||||
notify-send -u low "🔌 Battery Fully Charged" "You can unplug the charger" # Send a notification when the battery is fully charged
|
||||
FULL_CHARGE_NOTIFIED=1 # Set the state to indicate that the full charge notification has been sent
|
||||
fi
|
||||
|
||||
if [ "$PERCENT" -le 40 ] && [ "$LOW_BATTERY_NOTIFIED" -eq 0 ]; then # Check if the battery percentage is less than or equal to 20% and low battery notification has not been sent
|
||||
notify-send -u critical "🪫 Low Battery" "Plug in the charger" # Send low battery notification
|
||||
LOW_BATTERY_NOTIFIED=1 # Set the state to indicate that the low battery notification has been sent
|
||||
fi
|
||||
sleep 0.1 # Sleep for some time before checking again
|
||||
done
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Source the configuration file.
|
||||
CONFIG_FILE=~/dotfiles/hypr/scripts/Ref.sh
|
||||
source "$CONFIG_FILE"
|
||||
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Toggle wifi state #
|
||||
# #
|
||||
######################################
|
||||
|
||||
toggle_wifi() {
|
||||
wifi_status=$(nmcli radio wifi)
|
||||
if [ "$wifi_status" == "enabled" ]; then
|
||||
nmcli radio wifi off
|
||||
notify-send -u low -i "$notif" 'Airplane mode: OFF'
|
||||
else
|
||||
nmcli radio wifi on
|
||||
notify-send -u low -i "$notif" 'Airplane mode: ON'
|
||||
fi
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Toggle bluetooth state #
|
||||
# #
|
||||
######################################
|
||||
|
||||
toggle_bluetooth() {
|
||||
if [ "$bluetooth_status" == "no" ]; then
|
||||
bluetoothctl power on
|
||||
notify-send -u low -i "$notif" 'Bluetooth ON'
|
||||
else
|
||||
bluetoothctl power off
|
||||
notify-send -u low -i "$notif" 'Bluetooth OFF'
|
||||
fi
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Enable/Disable Monitor #
|
||||
# #
|
||||
######################################
|
||||
|
||||
disable_edp1() {
|
||||
enable_edp1
|
||||
sleep 1
|
||||
hyprctl keyword monitor eDP-1,disable
|
||||
}
|
||||
enable_edp1() {
|
||||
hyprctl keyword monitor eDP-1,preferred,auto,1
|
||||
}
|
||||
|
||||
@@ -48,8 +48,12 @@ yad --width=$dynamic_width --height=$dynamic_height \
|
||||
" W" "Choose wallpaper" "(Wallpaper Menu)" \
|
||||
" Shift W" "Choose wallpaper effects" "(imagemagick + swww)" \
|
||||
"SHIFT ALT W" "Random wallpaper" "(via swww)" \
|
||||
" H" "Hide/UnHide Waybar" "waybar" \
|
||||
" ALT R" "Reload Waybar swaync Rofi" "CHECK NOTIFICATION FIRST!!!" \
|
||||
" Print" "screenshot" "(grim)" \
|
||||
" Z" "screenshot region" "(grim + slurp)" \
|
||||
"CTRL ALT P" "power-menu" "(wlogout)" \
|
||||
"CTRL ALT L" "screen lock" "(hyprlock)" \
|
||||
"CTRL ALT Del" "Hyprland Exit" "(SAVE YOUR WORK!!!)" \
|
||||
" SHIFT Space" "Fullscreen" "Toggles to full screen" \
|
||||
" Space" "Toggle Dwindle | Master Layout" "Hyprland Layout" \
|
||||
|
||||
@@ -61,15 +61,7 @@ play_local_music() {
|
||||
notification "$choice"
|
||||
|
||||
# For some reason wont start playlist at 0
|
||||
if [[ $i -eq 0 ]]; then
|
||||
# Play the selected local music file using mpv
|
||||
mpv --loop-playlist --vid=no "$mDIR"
|
||||
|
||||
else
|
||||
file=$i
|
||||
# Play the selected local music file using mpv
|
||||
mpv --playlist-start="$file" --loop-playlist --vid=no "$mDIR"
|
||||
fi
|
||||
mpv --playlist-start="$i" --loop-playlist --vid=no "${local_music[@]}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This is for polkits, it will start from top and will stop if the top is executed
|
||||
|
||||
# Polkit possible paths files to check
|
||||
polkit=(
|
||||
"/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1"
|
||||
"/usr/lib/polkit-kde-authentication-agent-1"
|
||||
"/usr/lib/polkit-gnome-authentication-agent-1"
|
||||
"/usr/libexec/polkit-gnome-authentication-agent-1"
|
||||
"/usr/lib/x86_64-linux-gnu/libexec/polkit-kde-authentication-agent-1"
|
||||
"/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1"
|
||||
)
|
||||
|
||||
executed=false # Flag to track if a file has been executed
|
||||
|
||||
# Loop through the list of files
|
||||
for file in "${polkit[@]}"; do
|
||||
if [ -e "$file" ]; then
|
||||
echo "File $file found, executing command..."
|
||||
exec "$file"
|
||||
executed=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# If none of the files were found, you can add a fallback command here
|
||||
if [ "$executed" == false ]; then
|
||||
echo "None of the specified files were found. Install a Polkit"
|
||||
fi
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# For Notification icon
|
||||
notif="$HOME/dotfiles/hypr/assets/bell.png"
|
||||
reload="$HOME/dotfiles/hypr/assets/reload.svg"
|
||||
|
||||
# Scripts DIR
|
||||
SCRIPTSDIR="$HOME/dotfiles/hypr/scripts"
|
||||
UserSCRIPTSDIR="$HOME/dotfiles/hypr/UserScripts"
|
||||
|
||||
|
||||
# For Random Wallpaper
|
||||
wallDIR="$HOME/Pictures/wallpapers"
|
||||
FPS=60
|
||||
TYPE="random"
|
||||
DURATION=1
|
||||
BEZIER=".43,1.19,1,.4"
|
||||
SWWW_PARAMS="--transition-fps ${FPS} --transition-type ${TYPE} --transition-duration ${DURATION} --transition-bezier ${BEZIER}"
|
||||
|
||||
# For Select Wallpaper
|
||||
FPS1=30
|
||||
TYPE1="wipe"
|
||||
DURATION1=1
|
||||
BEZIER1=".43,1.19,1,.4"
|
||||
SWWW_PARAMS1="--transition-fps $FPS1 --transition-type $TYPE1 --transition-duration $DURATION1 --transition-bezier ${BEZIER1}"
|
||||
|
||||
|
||||
# For Keyboard Layout Switcher
|
||||
layout_f="$HOME/.cache/kb_layout"
|
||||
settings_file="$HOME/dotfiles/hypr/UserConfigs/UserSettings.conf"
|
||||
|
||||
|
||||
# For Quickedit
|
||||
configs="$HOME/dotfiles/hypr/configs"
|
||||
UserConfigs="$HOME/dotfiles/hypr/UserConfigs"
|
||||
|
||||
iDIR="$HOME/dotfiles/hypr/assets"
|
||||
|
||||
RunCMD="$SCRIPTSDIR/RunCMD.sh"
|
||||
Executable
+1860
File diff suppressed because it is too large.
Load diff
@@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
# Source the configuration file.
|
||||
CONFIG_FILE=~/dotfiles/hypr/scripts/Ref.sh
|
||||
source "$CONFIG_FILE"
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Quick Edit #
|
||||
# #
|
||||
######################################
|
||||
|
||||
edit() {
|
||||
menu() {
|
||||
options=("Env-variables" "Window-Rules" "Startup_Apps" "User-Keybinds" "Monitors" "Laptop-Keybinds" "User-Settings" )
|
||||
for ((i = 0; i < ${#options[@]}; i++)); do
|
||||
printf "%d. view %s\n" "$((i + 1))" "${options[i]}"
|
||||
done
|
||||
}
|
||||
main() {
|
||||
options=("ENVariables.conf" "WindowRules.conf" "Startup_Apps.conf" "UserKeybinds.conf" "Monitors.conf" "Laptops.conf" "UserSettings.conf" )
|
||||
choice=$(menu | rofi -dmenu -i -p " View / Edit Hyprland Configs:" | cut -d. -f1)
|
||||
[[ $choice =~ ^[1-7]$ ]] && kitty -e nvim "$UserConfigs/${options[choice - 1]}"
|
||||
}
|
||||
main
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Keybinds #
|
||||
# #
|
||||
######################################
|
||||
|
||||
keybind() {
|
||||
CONFIG=$(fd --base-directory "$HOME/dotfiles/keyb/bindings" --type f . | rofi -dmenu -p "Keybinds" -config ~/dotfiles/rofi/config-long.rasi)
|
||||
|
||||
hyprctl dispatch exec "[float;size 45% 80%;center 1] kitty keyb -k '$HOME/dotfiles/keyb/bindings/$CONFIG'"
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Emoji #
|
||||
# #
|
||||
######################################
|
||||
|
||||
emoji() {
|
||||
A="$(rofi -dmenu -p "Emoji:" -config ~/dotfiles/rofi/config-long.rasi < "$HOME/dotfiles/hypr/configs/emojis" | cut -d ' ' -f 1 | tr -d '\n')"
|
||||
[[ -n "$A" ]] && wl-copy -- "$A"
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ~/dotfiles/hypr/scripts/Ui_cmd.sh
|
||||
source ~/dotfiles/hypr/scripts/Device_cmd.sh
|
||||
source ~/dotfiles/hypr/scripts/Rofi_cmd.sh
|
||||
source ~/dotfiles/hypr/scripts/System_cmd.sh
|
||||
source ~/dotfiles/hypr/scripts/Music_cmd.sh
|
||||
source ~/dotfiles/hypr/scripts/Util.sh
|
||||
|
||||
|
||||
help() {
|
||||
declare -F
|
||||
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Screenshots scripts
|
||||
iDIR="$HOME/dotfiles/hypr/assets"
|
||||
|
||||
notify_cmd_shot="notify-send -h string:x-canonical-private-synchronous:shot-notify -u low -i ${iDIR}/screenshot.svg"
|
||||
dir="$(xdg-user-dir PICTURES)/Screenshots"
|
||||
[[ ! -d "$dir" ]] && mkdir -p "$dir"
|
||||
|
||||
notify_view() {
|
||||
local msg="Screenshot Saved."
|
||||
if [[ "$1" == "active" && ! -e "$active_window_path" ]]; then
|
||||
msg="Screenshot NOT Saved."
|
||||
fi
|
||||
$notify_cmd_shot "$msg"
|
||||
}
|
||||
|
||||
countdown() {
|
||||
for ((sec=$1; sec>0; sec--)); do
|
||||
notify-send -h string:x-canonical-private-synchronous:shot-notify -t 1000 -i "$iDIR/timer.png" "Taking shot in: $sec"
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
take_shot() {
|
||||
local time=$(date "+%d-%b_%H-%M-%S")
|
||||
local file="Screenshot_${time}_${RANDOM}.png"
|
||||
cd "$dir" && grim - | tee "$file" | wl-copy
|
||||
sleep 2
|
||||
notify_view "$1"
|
||||
}
|
||||
|
||||
shot_timer() {
|
||||
local time=$(date "+%d-%b_%H-%M-%S")
|
||||
local file="Screenshot_${time}_${RANDOM}.png"
|
||||
countdown "$1"
|
||||
sleep 1
|
||||
take_shot "$2"
|
||||
}
|
||||
|
||||
shotarea() {
|
||||
local time=$(date "+%d-%b_%H-%M-%S")
|
||||
local tmpfile=$(mktemp)
|
||||
local area=$(slurp)
|
||||
if [[ -z "$area" ]]; then
|
||||
notify-send -u low -i "$iDIR/picture.png" 'No area selected'
|
||||
rm "$tmpfile"
|
||||
return
|
||||
fi
|
||||
grim -g "$area" - > "$tmpfile" && [[ -s "$tmpfile" ]] && {
|
||||
wl-copy < "$tmpfile"
|
||||
mv "$tmpfile" "$dir/Screenshot_${time}_${RANDOM}.png"
|
||||
notify_view
|
||||
}
|
||||
rm "$tmpfile"
|
||||
}
|
||||
|
||||
shotactive() {
|
||||
local time=$(date "+%d-%b_%H-%M-%S")
|
||||
local active_window_path="${dir}/Screenshot_${time}_$(hyprctl -j activewindow | jq -r '.class').png"
|
||||
hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | grim -g - "$active_window_path"
|
||||
sleep 1
|
||||
notify_view "active"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
--now) take_shot ;;
|
||||
--in5) shot_timer 5 ;;
|
||||
--in10) shot_timer 10 ;;
|
||||
--area) shotarea ;;
|
||||
--active) shotactive ;;
|
||||
*) echo "Available Options: --now --in5 --in10 --area --active" ;;
|
||||
esac
|
||||
@@ -1,288 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
# Source the configuration file.
|
||||
CONFIG_FILE=~/dotfiles/hypr/scripts/Ref.sh
|
||||
source "$CONFIG_FILE"
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Rofi Option for Xmenu #
|
||||
# #
|
||||
######################################
|
||||
|
||||
_confirm_rofi() {
|
||||
rofi -theme-str 'window {location: center; anchor: center; fullscreen: false; width: 250px;}' \
|
||||
-theme-str 'mainbox {children: [ "message", "listview" ];}' \
|
||||
-theme-str 'listview {columns: 2; lines: 1;}' \
|
||||
-theme-str 'element-text {horizontal-align: 0.5;}' \
|
||||
-theme-str 'textbox {horizontal-align: 0.5;}' \
|
||||
-kb-accept-entry 'Return,space' \
|
||||
-dmenu \
|
||||
-mesg "$1"
|
||||
|
||||
}
|
||||
_need_confirm() {
|
||||
local _result="$(echo -e "No\nYes" | _confirm_rofi "$1")"
|
||||
if [[ "$_result" == "Yes" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Power & Reboot #
|
||||
# #
|
||||
######################################
|
||||
|
||||
sys_reboot() {
|
||||
if _need_confirm "Reboot system?"; then
|
||||
reboot
|
||||
fi
|
||||
}
|
||||
sys_poweroff() {
|
||||
if _need_confirm "Shutdown system?"; then
|
||||
poweroff
|
||||
fi
|
||||
}
|
||||
sys_lock() {
|
||||
if _need_confirm "Lock screen?"; then
|
||||
pidof hyprlock || hyprlock -q
|
||||
fi
|
||||
}
|
||||
sys_logout() {
|
||||
if _need_confirm "Logout?"; then
|
||||
loginctl kill-session $XDG_SESSION_ID
|
||||
fi
|
||||
}
|
||||
sys_suspend() {
|
||||
if _need_confirm "Suspend system?"; then
|
||||
systemctl suspend
|
||||
fi
|
||||
}
|
||||
sys_hibernate() {
|
||||
if _need_confirm "Hibernate system?"; then
|
||||
systemctl hibernate
|
||||
fi
|
||||
}
|
||||
|
||||
#######################################################
|
||||
# #
|
||||
# Reload ags rofi #
|
||||
# #
|
||||
#######################################################
|
||||
# (SHIFT ALT R)
|
||||
reload_all() {
|
||||
file_exists() {
|
||||
[ -e "$1" ]
|
||||
}
|
||||
|
||||
processes=("ags" "rofi")
|
||||
|
||||
for process in "${processes[@]}"; do
|
||||
pid=$(pidof "$process")
|
||||
if [ -n "$pid" ]; then
|
||||
pkill "$process"
|
||||
fi
|
||||
done
|
||||
# quit ags
|
||||
ags -q
|
||||
sleep 0.3
|
||||
ags &
|
||||
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Reload Hyprland #
|
||||
# #
|
||||
######################################
|
||||
|
||||
reload_hypr() {
|
||||
hyprctl reload
|
||||
notify-send -u low -i $reload 'Reload Hyprland'
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Battery Notifer #
|
||||
# #
|
||||
######################################
|
||||
|
||||
battery_notify() {
|
||||
PREV_STATUS="Unknown" # Initialize previous status
|
||||
FULL_CHARGE_NOTIFIED=0
|
||||
LOW_BATTERY_NOTIFIED=0
|
||||
|
||||
while true; do
|
||||
STATUS=$(cat /sys/class/power_supply/AC/online 2>/dev/null) # Get charger status using power supply directory
|
||||
|
||||
if [ "$STATUS" != "$PREV_STATUS" ]; then # Check if the charger status has changed
|
||||
FULL_CHARGE_NOTIFIED=0 # Reset full charge notification state when charger status changes
|
||||
LOW_BATTERY_NOTIFIED=0 # Reset low battery notification state when charger status changes
|
||||
PREV_STATUS="$STATUS" # Update previous status
|
||||
fi
|
||||
|
||||
# Get battery percentage and remaining time using acpi
|
||||
BATTERY_INFO=$(acpi)
|
||||
PERCENT=$(echo "$BATTERY_INFO" | awk -F ',|%' '{print $2}')
|
||||
|
||||
if [ "$STATUS" == "1" ] && [ "$PERCENT" -eq 100 ] && [ "$FULL_CHARGE_NOTIFIED" -eq 0 ]; then # Check if the battery is charging and the percentage is 100%
|
||||
notify-send -u low "🔌 Battery Fully Charged" "You can unplug the charger" # Send a notification when the battery is fully charged
|
||||
FULL_CHARGE_NOTIFIED=1 # Set the state to indicate that the full charge notification has been sent
|
||||
fi
|
||||
|
||||
if [ "$PERCENT" -le 40 ] && [ "$LOW_BATTERY_NOTIFIED" -eq 0 ]; then # Check if the battery percentage is less than or equal to 20% and low battery notification has not been sent
|
||||
notify-send -u critical "🪫 Low Battery" "Plug in the charger" # Send low battery notification
|
||||
LOW_BATTERY_NOTIFIED=1 # Set the state to indicate that the low battery notification has been sent
|
||||
fi
|
||||
sleep 0.1 # Sleep for some time before checking again
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Polkit #
|
||||
# #
|
||||
######################################
|
||||
|
||||
polkit_(){
|
||||
polkit=(
|
||||
"/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1"
|
||||
"/usr/lib/polkit-kde-authentication-agent-1"
|
||||
"/usr/lib/polkit-gnome-authentication-agent-1"
|
||||
"/usr/libexec/polkit-gnome-authentication-agent-1"
|
||||
"/usr/lib/x86_64-linux-gnu/libexec/polkit-kde-authentication-agent-1"
|
||||
"/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1"
|
||||
)
|
||||
executed=false # Flag to track if a file has been executed
|
||||
# Loop through the list of files
|
||||
for file in "${polkit[@]}"; do
|
||||
if [ -e "$file" ]; then
|
||||
echo "File $file found, executing command..."
|
||||
exec "$file"
|
||||
executed=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
# If none of the files were found, you can add a fallback command here
|
||||
if [ "$executed" == false ]; then
|
||||
echo "None of the specified files were found. Install a Polkit"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
######################################
|
||||
# #
|
||||
# SymLink #
|
||||
# #
|
||||
######################################
|
||||
|
||||
symlink() {
|
||||
# Define cache directory
|
||||
cache_dir="$HOME/.cache/swww/"
|
||||
|
||||
# Get a list of monitor outputs
|
||||
monitor_outputs=($(ls "$cache_dir"))
|
||||
|
||||
# Initialize variables
|
||||
ln_success=false
|
||||
current_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}')
|
||||
echo $current_monitor
|
||||
cache_file="$cache_dir$current_monitor"
|
||||
echo $cache_file
|
||||
|
||||
if [ -f "$cache_file" ]; then
|
||||
# Read wallpaper path from cache file
|
||||
wallpaper_path=$(cat "$cache_file")
|
||||
echo $wallpaper_path
|
||||
|
||||
# Symlink wallpaper to the location accessible by Rofi
|
||||
if ln -sf "$wallpaper_path" "$HOME/dotfiles/hypr/wallpaper_effects/.wallpaper_current"; then
|
||||
ln_success=true # Set the flag to true upon successful execution
|
||||
fi
|
||||
|
||||
# Copy the wallpaper for wallpaper effects (optional)
|
||||
# cp -r "$wallpaper_path" "$HOME/.config/hypr/wallpaper_effects/.wallpaper_current"
|
||||
fi
|
||||
|
||||
# Check if symlink was successful
|
||||
if [ "$ln_success" = true ]; then
|
||||
echo 'Symlink successful'
|
||||
fi
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Wallpaper Effect #
|
||||
# #
|
||||
######################################
|
||||
|
||||
|
||||
apply_wallpaper_effects() {
|
||||
current_wallpaper="$HOME/dotfiles/hypr/wallpaper_effects/.wallpaper_current"
|
||||
wallpaper_output="$HOME/dotfiles/hypr/wallpaper_effects/.wallpaper_modified"
|
||||
focused_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}')
|
||||
iDIR="$HOME/dotfiles/hypr/assets/"
|
||||
SWWW_PARAMS="--transition-fps 60 --transition-type wipe --transition-duration 2"
|
||||
|
||||
declare -A effects=(
|
||||
["Black & White"]="magick $current_wallpaper -colorspace gray -sigmoidal-contrast 10,40% $wallpaper_output"
|
||||
["Blurred"]="magick $current_wallpaper -blur 0x5 $wallpaper_output"
|
||||
["Solarize"]="magick $current_wallpaper -solarize 80% $wallpaper_output"
|
||||
["Sepia Tone"]="magick $current_wallpaper -sepia-tone 65% $wallpaper_output"
|
||||
["Negate"]="magick $current_wallpaper -negate $wallpaper_output"
|
||||
["Charcoal"]="magick $current_wallpaper -charcoal 0x5 $wallpaper_output"
|
||||
["Edge Detect"]="magick $current_wallpaper -edge 1 $wallpaper_output"
|
||||
["Emboss"]="magick $current_wallpaper -emboss 0x5 $wallpaper_output"
|
||||
["Sharpen"]="magick $current_wallpaper -sharpen 0x5 $wallpaper_output"
|
||||
["Oil Paint"]="magick $current_wallpaper -paint 4 $wallpaper_output"
|
||||
["Vignette"]="magick $current_wallpaper -vignette 0x5 $wallpaper_output"
|
||||
["Posterize"]="magick $current_wallpaper -posterize 4 $wallpaper_output"
|
||||
["Polaroid"]="magick $current_wallpaper -polaroid 0 $wallpaper_output"
|
||||
["No Effects"]="no-effects"
|
||||
)
|
||||
|
||||
no_effects() {
|
||||
swww img -o "$focused_monitor" "$current_wallpaper" $SWWW_PARAMS &
|
||||
wait $!
|
||||
notify-send -u low -i "$iDIR/bell.png" "No wallpaper effects"
|
||||
cp $current_wallpaper $wallpaper_output
|
||||
}
|
||||
|
||||
main() {
|
||||
options="No Effects"
|
||||
for effect in "${!effects[@]}"; do
|
||||
if [ "$effect" != "No Effects" ]; then
|
||||
options+="\n$effect"
|
||||
fi
|
||||
done
|
||||
|
||||
choice=$(echo -e "$options" | rofi -i -dmenu)
|
||||
if [[ -n "$choice" && "${effects[$choice]+exists}" ]]; then
|
||||
if [ "$choice" == "No Effects" ]; then
|
||||
no_effects
|
||||
else
|
||||
notify-send -u normal -i "$iDIR/bell.png" "Applying $choice effects"
|
||||
eval "${effects[$choice]}"
|
||||
sleep 1
|
||||
swww img -o "$focused_monitor" "$wallpaper_output" $SWWW_PARAMS &
|
||||
wait $!
|
||||
notify-send -u low -i "$iDIR/bell.png" "$choice effects applied"
|
||||
fi
|
||||
else
|
||||
echo "Effects not recognized."
|
||||
fi
|
||||
}
|
||||
|
||||
if pidof rofi > /dev/null; then
|
||||
pkill rofi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
main
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Source the configuration file.
|
||||
CONFIG_FILE=~/dotfiles/hypr/scripts/Ref.sh
|
||||
source "$CONFIG_FILE"
|
||||
notif="$HOME/dotfiles/hypr/assets/bell.png"
|
||||
|
||||
|
||||
|
||||
# For Keyboard Layout Switcher
|
||||
|
||||
|
||||
######################################
|
||||
@@ -43,22 +45,6 @@ toggle_animation() {
|
||||
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Rainbow Border #
|
||||
# #
|
||||
######################################
|
||||
|
||||
rainbow_border() {
|
||||
function random_hex() {
|
||||
random_hex=("0xff$(openssl rand -hex 3)")
|
||||
echo $random_hex
|
||||
}
|
||||
hyprctl keyword general:col.active_border $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) 270deg
|
||||
|
||||
hyprctl keyword general:col.inactive_border $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) $(random_hex) 270deg
|
||||
}
|
||||
|
||||
################################################
|
||||
# #
|
||||
# Change Layout Master to Dwindle #
|
||||
@@ -91,23 +77,6 @@ change_layout() {
|
||||
}
|
||||
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Random Wallpaper #
|
||||
# #
|
||||
######################################
|
||||
|
||||
random_wall() {
|
||||
focused_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}')
|
||||
|
||||
PICS=($(find ${wallDIR} -type f \( -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" -o -name "*.gif" \)))
|
||||
RANDOMPICS=${PICS[ $RANDOM % ${#PICS[@]} ]}
|
||||
|
||||
swww query || swww-daemon --format xrgb && swww img -o $focused_monitor ${RANDOMPICS} $SWWW_PARAMS
|
||||
$RunCMD symlink
|
||||
}
|
||||
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Auto Wallpaper Changer #
|
||||
@@ -115,6 +84,12 @@ $RunCMD symlink
|
||||
######################################
|
||||
|
||||
auto_wall() {
|
||||
wallDIR="$HOME/Pictures/wallpapers"
|
||||
FPS=60
|
||||
TYPE="random"
|
||||
DURATION=1
|
||||
BEZIER=".43,1.19,1,.4"
|
||||
SWWW_PARAMS="--transition-fps ${FPS} --transition-type ${TYPE} --transition-duration ${DURATION} --transition-bezier ${BEZIER}"
|
||||
focused_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}')
|
||||
INTERVAL=1800 # This controls (in seconds) when to switch to the next image
|
||||
while true; do
|
||||
@@ -126,38 +101,6 @@ auto_wall() {
|
||||
done
|
||||
}
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Wallpaper Selector #
|
||||
# #
|
||||
######################################
|
||||
|
||||
select_wall() {
|
||||
focused_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}')
|
||||
build_theme() {
|
||||
rows="$1"
|
||||
cols="$2"
|
||||
icon_size="$2"
|
||||
echo "element{orientation:vertical;}element-text{horizontal-align:0.5;}element-icon{size:${icon_size}.0000em;}listview{lines:${rows};columns:${cols};}"
|
||||
}
|
||||
if [ ! -d "$wallDIR" ]; then
|
||||
echo "Error: Wallpaper directory not found." >&2
|
||||
exit 1
|
||||
fi
|
||||
images=$(find "$wallDIR" -maxdepth 1 -type f -printf "%f\x00icon\x1f$wallDIR/%f\n" | sort -n)
|
||||
choice=$(echo -en "$images\nRandom Choice" | rofi -dmenu -i -show-icons -theme-str "$(build_theme 3 5 6)" -p " Wallpaper")
|
||||
if [ -n "$choice" ]; then
|
||||
if [ "$choice" = "Random Choice" ]; then
|
||||
choice=$(find "$wallDIR" -type f -maxdepth 1 -printf "%f\n" | shuf -n1)
|
||||
fi
|
||||
wallpaper="$wallDIR/${choice#*icon\x1f}"
|
||||
swww img -o $focused_monitor $SWWW_PARAMS1 "$wallpaper"
|
||||
$RunCMD symlink
|
||||
else
|
||||
echo "No wallpaper selected. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
######################################
|
||||
@@ -199,6 +142,8 @@ disable_opaque() {
|
||||
######################################
|
||||
|
||||
kb_changer() {
|
||||
layout_f="$HOME/.cache/kb_layout"
|
||||
settings_file="$HOME/dotfiles/hypr/UserConfigs/UserSettings.conf"
|
||||
current_layout=$(cat "$layout_f")
|
||||
|
||||
[ -f "$settings_file" ] && IFS=',' read -ra layout_mapping <<< "$(grep 'kb_layout=' "$settings_file" | cut -d '=' -f 2)"
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Source the configuration file.
|
||||
CONFIG_FILE=~/dotfiles/hypr/scripts/Ref.sh
|
||||
source "$CONFIG_FILE"
|
||||
|
||||
brightness() {
|
||||
local notification_timeout=1000
|
||||
|
||||
get_backlight() {
|
||||
brightnessctl -m | cut -d, -f4
|
||||
}
|
||||
|
||||
get_icon() {
|
||||
local current=$(get_backlight | sed 's/%//')
|
||||
echo "$iDIR/brightness.svg"
|
||||
}
|
||||
|
||||
notify_user() {
|
||||
local current=$(get_backlight | sed 's/%//')
|
||||
local icon=$(get_icon)
|
||||
notify-send -e -h string:x-canonical-private-synchronous:brightness_notif -h int:value:$current -u low -i "$icon" "Brightness : $current%"
|
||||
}
|
||||
|
||||
change_backlight() {
|
||||
brightnessctl set "$1" && notify_user
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
--get) get_backlight ;;
|
||||
--inc) change_backlight "+5%" ;;
|
||||
--dec) change_backlight "5%-" ;;
|
||||
*) get_backlight ;;
|
||||
esac
|
||||
}
|
||||
|
||||
volume() {
|
||||
get_volume() {
|
||||
local volume=$(pamixer --get-volume)
|
||||
[[ "$volume" -eq "0" ]] && echo "Muted" || echo "$volume%"
|
||||
}
|
||||
|
||||
get_icon() {
|
||||
local current=$(get_volume)
|
||||
if [[ "$current" == "Muted" ]]; then
|
||||
echo "$iDIR/volume-mute.png"
|
||||
elif [[ "${current%\%}" -le 30 ]]; then
|
||||
echo "$iDIR/volume-low.png"
|
||||
elif [[ "${current%\%}" -le 60 ]]; then
|
||||
echo "$iDIR/volume-mid.png"
|
||||
else
|
||||
echo "$iDIR/volume-high.png"
|
||||
fi
|
||||
}
|
||||
|
||||
notify_user() {
|
||||
local volume=$(get_volume)
|
||||
local icon=$(get_icon)
|
||||
if [[ "$volume" == "Muted" ]]; then
|
||||
notify-send -e -h string:x-canonical-private-synchronous:volume_notif -u low -i "$icon" "Volume: Muted"
|
||||
else
|
||||
notify-send -e -h int:value:"${volume%\%}" -h string:x-canonical-private-synchronous:volume_notif -u low -i "$icon" "Volume: $volume"
|
||||
fi
|
||||
}
|
||||
|
||||
change_volume() {
|
||||
pamixer "$1" "$2" && notify_user
|
||||
}
|
||||
|
||||
toggle_mute() {
|
||||
if [ "$(pamixer --get-mute)" == "false" ]; then
|
||||
pamixer -m && notify-send -e -u low -i "$iDIR/volume-mute.png" "Volume Switched OFF"
|
||||
elif [ "$(pamixer --get-mute)" == "true" ]; then
|
||||
pamixer -u && notify-send -e -u low -i "$(get_icon)" "Volume Switched ON"
|
||||
fi
|
||||
}
|
||||
|
||||
toggle_mic() {
|
||||
if [ "$(pamixer --default-source --get-mute)" == "false" ]; then
|
||||
pamixer --default-source -m && notify-send -e -u low -i "$iDIR/microphone-mute.png" "Microphone Switched OFF"
|
||||
elif [ "$(pamixer --default-source --get-mute)" == "true" ]; then
|
||||
pamixer -u --default-source u && notify-send -e -u low -i "$iDIR/microphone.png" "Microphone Switched ON"
|
||||
fi
|
||||
}
|
||||
|
||||
notify_mic_user() {
|
||||
local volume=$(pamixer --default-source --get-volume)
|
||||
local icon=$(pamixer --default-source --get-mute && echo "$iDIR/microphone-mute.png" || echo "$iDIR/microphone.png")
|
||||
notify-send -e -h int:value:"$volume" -h string:x-canonical-private-synchronous:volume_notif -u low -i "$icon" "Mic-Level: $volume%"
|
||||
}
|
||||
|
||||
change_mic_volume() {
|
||||
pamixer --default-source "$1" "$2" && notify_mic_user
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
--get) get_volume ;;
|
||||
--inc) change_volume -i 5 ;;
|
||||
--dec) change_volume -d 5 ;;
|
||||
--toggle) toggle_mute ;;
|
||||
--toggle-mic) toggle_mic ;;
|
||||
--mic-inc) change_mic_volume -i 5 ;;
|
||||
--mic-dec) change_mic_volume -d 5 ;;
|
||||
*) get_volume ;;
|
||||
esac
|
||||
}
|
||||
|
||||
screenshot() {
|
||||
local notify_cmd_shot="notify-send -h string:x-canonical-private-synchronous:shot-notify -u low -i ${iDIR}/screenshot.svg"
|
||||
local time=$(date "+%d-%b_%H-%M-%S")
|
||||
local dir="$(xdg-user-dir)/Pictures/Screenshots"
|
||||
local file="Screenshot_${time}_${RANDOM}.png"
|
||||
local active_window_path="${dir}/Screenshot_${time}_$(hyprctl -j activewindow | jq -r '.class').png"
|
||||
|
||||
notify_view() {
|
||||
local msg="Screenshot Saved."
|
||||
[[ "$1" == "active" && ! -e "$active_window_path" ]] && msg="Screenshot NOT Saved."
|
||||
$notify_cmd_shot "$msg"
|
||||
}
|
||||
|
||||
countdown() {
|
||||
for ((sec=$1; sec>0; sec--)); do
|
||||
notify-send -h string:x-canonical-private-synchronous:shot-notify -t 1000 -i "$iDIR/timer.png" "Taking shot in: $sec"
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
take_shot() {
|
||||
cd "$dir" && grim - | tee "$file" | wl-copy
|
||||
sleep 2
|
||||
notify_view "$1"
|
||||
}
|
||||
|
||||
shot_timer() {
|
||||
countdown "$1"
|
||||
sleep 1
|
||||
take_shot "$2"
|
||||
}
|
||||
|
||||
shotarea() {
|
||||
local tmpfile=$(mktemp)
|
||||
local area=$(slurp)
|
||||
[[ -z "$area" ]] && { notify-send -u low -i "$iDIR/picture.png" 'No area selected'; rm "$tmpfile"; return; }
|
||||
grim -g "$area" - > "$tmpfile" && [[ -s "$tmpfile" ]] && {
|
||||
wl-copy < "$tmpfile"
|
||||
mv "$tmpfile" "$dir/Screenshot_$(date '+%d-%b_%H-%M-%S')_${RANDOM}.png"
|
||||
notify_view
|
||||
}
|
||||
rm "$tmpfile"
|
||||
}
|
||||
|
||||
shotactive() {
|
||||
hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | grim -g - "$active_window_path"
|
||||
sleep 1
|
||||
notify_view "active"
|
||||
}
|
||||
|
||||
[[ ! -d "$dir" ]] && mkdir -p "$dir"
|
||||
|
||||
case "$1" in
|
||||
--now) take_shot ;;
|
||||
--in5) shot_timer 5 ;;
|
||||
--in10) shot_timer 10 ;;
|
||||
--area) shotarea ;;
|
||||
--active) shotactive ;;
|
||||
*) echo "Available Options: --now --in5 --in10 --area --active" ;;
|
||||
esac
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Source the configuration file.
|
||||
CONFIG_FILE=~/dotfiles/hypr/scripts/Ref.sh
|
||||
source "$CONFIG_FILE"
|
||||
|
||||
# Note: You can add more options below with the following format:
|
||||
# ["TITLE"]="link"
|
||||
|
||||
# Define menu options as an associative array
|
||||
declare -A menu_options=(
|
||||
|
||||
#hypr
|
||||
["hpr Reload hyprland"]="$RunCMD reload_hypr"
|
||||
["rld Reload All"]="$RunCMD reload_all"
|
||||
["cl ChangeLayout"]="$RunCMD change_layout"
|
||||
["gm GameMode"]="$RunCMD gamemode"
|
||||
["bl ChangeBlur"]="$RunCMD toggle_blur"
|
||||
["flt Float all window"]="hyprctl dispatch workspaceopt allfloat"
|
||||
["hpa Toggle hyprland animation"]="$RunCMD toggle_animation"
|
||||
["op1 enable_opaque"]="$RunCMD enable_opaque"
|
||||
["op0 disable_opaque"]="$RunCMD disable_opaque"
|
||||
#wallpaper
|
||||
["ws Wallpaper Select"]="$RunCMD select_wall"
|
||||
["wc Random Wallpaper"]="$RunCMD random_wall"
|
||||
#RunCMD
|
||||
["; Launcher"]="rofi -show drun -modi drun,filebrowser,run,window"
|
||||
["cb Clipboard"]="pkill rofi || true && ags -t cliphist"
|
||||
["rm Music"]="$RunCMD music -m"
|
||||
["emj Emoji"]="$RunCMD emoji"
|
||||
["kb Kebinds"]="$SCRIPTSDIR/KeyHints.sh"
|
||||
["qe QuickEdits"]="$RunCMD edit"
|
||||
#System
|
||||
["qq Shutdown"]="$RunCMD sys_poweroff"
|
||||
["rr Reboot"]="$RunCMD sys_reboot"
|
||||
["lk Lock"]="$RunCMD sys_lock"
|
||||
["lo LogOut"]="$RunCMD sys_logout"
|
||||
["sp Suspend"]="$RunCMD sys_suspend"
|
||||
["hb Hibernate"]="$RunCMD sys_hibernate"
|
||||
["dm0 disable monitor"]="$RunCMD disable_edp1"
|
||||
["dm1 enable monitor"]="$RunCMD enable_edp1"
|
||||
["tbt Bluetooth"]="$RunCMD toggle_bluetooth"
|
||||
["tw Wifi"]="$RunCMD totggle_wifi"
|
||||
["kb Keyboard switcher"]="$RunCMD kb_changer"
|
||||
#Misc
|
||||
["ff Firefox"]="firefox"
|
||||
["ffp Firefox"]="firefox --private-window"
|
||||
["vi Nvim"]="pypr toggle nvim"
|
||||
["yz Yazi"]="pypr toggle yazi"
|
||||
["tg Telegram"]="telegram-desktop"
|
||||
)
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
choice=$(
|
||||
printf "%s\n" "${!menu_options[@]}" |
|
||||
rofi -dmenu \
|
||||
-p "Rofi" \
|
||||
-mesg "Hello" \
|
||||
-max-history-size 0 \
|
||||
-auto-select
|
||||
|
||||
|
||||
)
|
||||
|
||||
if [ -z "$choice" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
link="${menu_options[$choice]}"
|
||||
$link
|
||||
}
|
||||
|
||||
main
|
||||
@@ -0,0 +1,156 @@
|
||||
import os
|
||||
import sys
|
||||
import importlib.util
|
||||
import argparse
|
||||
import fcntl
|
||||
import subprocess
|
||||
import asyncio
|
||||
import random as _random
|
||||
|
||||
|
||||
lock_file_path = '/tmp/wallpaper.lock'
|
||||
|
||||
|
||||
def acquire_lock():
|
||||
global lock_file
|
||||
lock_file = open(lock_file_path, 'w')
|
||||
try:
|
||||
fcntl.flock(lock_file, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
lock_file.write(str(os.getpid()))
|
||||
lock_file.flush()
|
||||
except IOError:
|
||||
print("Another instance of the script is already running.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def release_lock():
|
||||
fcntl.flock(lock_file, fcntl.LOCK_UN)
|
||||
lock_file.close()
|
||||
os.remove(lock_file_path)
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
group = parser.add_mutually_exclusive_group(required=True)
|
||||
group.add_argument('-I', '--image', type=str, help="Image")
|
||||
group.add_argument('-R', '--random', help="Random image from folder", action='store_true')
|
||||
parser.add_argument('-n', '--notify', help="Send notifications", action='store_true')
|
||||
parser.add_argument('--status', type=str, help="Status file", default="/tmp/wallpaper.status")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
random = args.random
|
||||
image = args.image
|
||||
notify = args.notify
|
||||
status = args.status
|
||||
|
||||
HOME = os.path.expanduser("~")
|
||||
|
||||
|
||||
cache_file = f"{HOME}/.cache/current_wallpaper"
|
||||
square = f"{HOME}/.cache/square_wallpaper.png"
|
||||
|
||||
|
||||
def current_state(state_str: str):
|
||||
with open(status, 'w') as f:
|
||||
f.write(state_str)
|
||||
|
||||
|
||||
def send_notify(label: str, desc: str):
|
||||
if not notify:
|
||||
return
|
||||
subprocess.run(["notify-send", label, desc])
|
||||
|
||||
|
||||
def state(name: str | None, label: str | None, desc: str | None):
|
||||
if name is not None:
|
||||
current_state(name)
|
||||
if label is not None:
|
||||
send_notify(label, desc or "")
|
||||
|
||||
|
||||
def join(*args):
|
||||
return os.path.join(*args)
|
||||
|
||||
|
||||
async def main():
|
||||
state("init", None, None)
|
||||
|
||||
new_wallpaper = f"{HOME}/Pictures/wallpapers/wall-01.jpg"
|
||||
|
||||
if random:
|
||||
files = [f for f in os.listdir(f"{HOME}/Pictures/wallpapers") if f.endswith(('.png', '.jpg', '.jpeg'))]
|
||||
if files:
|
||||
new_wallpaper = join(f"{HOME}/Pictures/wallpapers", _random.choice(files))
|
||||
...
|
||||
elif image is not None:
|
||||
new_wallpaper = os.path.abspath(image)
|
||||
|
||||
print(f":: Wallpaper {new_wallpaper}")
|
||||
|
||||
with open(cache_file, 'w') as f:
|
||||
f.write(new_wallpaper)
|
||||
|
||||
with_image = f"with image {new_wallpaper}"
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Set the new wallpaper
|
||||
# -----------------------------------------------------
|
||||
|
||||
transition_type = "wipe"
|
||||
# transition_type = "outer"
|
||||
# transition_type = "random"
|
||||
|
||||
wallpaper_engine = "swww" # Default wallpaper engine
|
||||
|
||||
state("changing", "Changing wallpaper...", with_image)
|
||||
print(":: Changing wallpaper...")
|
||||
if wallpaper_engine == "swww":
|
||||
print(":: Using swww")
|
||||
|
||||
cursor_pos = subprocess.getoutput('hyprctl cursorpos')
|
||||
|
||||
subprocess.run([
|
||||
'swww', 'img', new_wallpaper,
|
||||
'--transition-bezier', '.43,1.19,1,.4',
|
||||
'--transition-fps', '60',
|
||||
'--transition-type', transition_type,
|
||||
'--transition-duration', '0.7',
|
||||
'--transition-pos', cursor_pos
|
||||
])
|
||||
else:
|
||||
print(":: Wallpaper Engine disabled")
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Square image
|
||||
# -----------------------------------------------------
|
||||
square_task = asyncio.create_task(square_image(new_wallpaper))
|
||||
|
||||
state("tasks", None, None)
|
||||
await asyncio.gather(square_task)
|
||||
state("finish", "Wallpaper procedure complete!", with_image)
|
||||
|
||||
|
||||
async def square_image(wallpaper):
|
||||
with_image = f"with image {wallpaper}"
|
||||
state(None, "Creating square version...", with_image)
|
||||
print(":: Creating square version")
|
||||
cmd = f"magick {wallpaper} -gravity Center -extent 1:1 {square}"
|
||||
process = await asyncio.create_subprocess_shell(
|
||||
cmd,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE
|
||||
)
|
||||
stdout, stderr = await process.communicate()
|
||||
|
||||
if process.returncode != 0:
|
||||
print(f":: Error while processing image: {stderr.decode()}")
|
||||
else:
|
||||
print(":: Square image created!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
acquire_lock()
|
||||
try:
|
||||
asyncio.run(main())
|
||||
finally:
|
||||
release_lock()
|
||||
Reference in new issue
Block a user