Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a script to to toggle between current wallpaper and live wallpaper using mpvpaper #460

Closed
wants to merge 4 commits into from

Conversation

devnchill
Copy link
Contributor

@devnchill devnchill commented Sep 26, 2024

… wallpaper

Pull Request

Description

Please read these instructions and remove unnecessary text.

  • Try to include a summary of the changes and which issue is fixed.

Used mpvpaper to apply live wallpapers . Made a custom script and added super alt 2 to toggle between current wallpaper and live wallpaper . Path for live wallpaper is in wallpapers/livewallpaper/

  • Also include relevant motivation and context (if applicable).

They look nice

  • List any dependencies that are required for this change. (e.g., packages or other PRs)

It needs mpvpaper for it . I installed it using ninja . I followed these steps

Clone

git clone --single-branch https://github.com/GhostNaN/mpvpaper

Build

cd mpvpaper
meson setup build --prefix=/usr/local
ninja -C build

Install

ninja -C build install

  • Provide a link if there is an issue related to this pull request. e.g., Fixes # (issue)
  • Please add Reviewers, Assignees, Labels, Projects, and Milestones to the PR. (if applicable)

Type of change

Please put an x in the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • [ X] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (non-breaking change; modified files are limited to the documentations)
  • Technical debt (a code change that does not fix a bug or add a feature but makes something clearer for devs)
  • Other (provide details below)

Checklist

Please put an x in the boxes that apply:

  • [X ] I have read the CONTRIBUTING document.
  • [X ] My code follows the code style of this project.
  • [ X] My commit message follows the commit guidelines.
  • My change requires a change to the documentation.
  • I want to add something in Hyprland-Dots wiki.
  • I have added tests to cover my changes.
  • [ X] I have tested my code locally and it works as expected.
  • All new and existing tests passed.

Screenshots

(if appropriate)

Additional context

Add any other context about the problem here.

@JaKooLit JaKooLit changed the base branch from main to development September 27, 2024 04:30
@JaKooLit
Copy link
Owner

mpv paper is just using wayyy too much resources.. no issues for high powered or high ram system..

but a dual core 2gb will just crawl

@devnchill
Copy link
Contributor Author

even if it's not being used ? like if you don't apply it will it still consume resources in background ?if yes then we can close it otherwise i don't see any harm in it as users can easily toggle it

@JaKooLit
Copy link
Owner

not sure... reason why I cant merge yet is I have to check and test properly. I cant now since im fully occupied with work.

I may have time to check next month

@devnchill
Copy link
Contributor Author

Sure

@wax-dred
Copy link

Bonjour,

J'ai éditer un script pour mpvpaper dans la suite de JaKooLit je suis novice mais j'espère que ça peux vous aidez.

`#!/bin/bash

WALLPAPERS PATH

wallDIR="$HOME/Pictures/wallpapers/Video"
SCRIPTSDIR="$HOME/.config/hypr/scripts"
THUMBNAIL_DIR="/tmp/video_thumbnails"
mkdir -p "$THUMBNAIL_DIR"

variables

focused_monitor=$(hyprctl monitors | awk '/^Monitor/{name=$2} /focused: yes/{print name}')

Fonction pour générer des miniatures

generate_thumbnail() {
local video_path="$1"
local thumbnail_path="${THUMBNAIL_DIR}/$(basename "$video_path").png"

Ne générer la miniature que si elle n'existe pas déjà

if [[ ! -f "$thumbnail_path" ]]; then
ffmpegthumbnailer -i "$video_path" -o "$thumbnail_path" -s 256
fi

echo "$thumbnail_path"
}

Check if swaybg is running

if pidof swaybg >/dev/null; then
pkill swaybg
fi

Retrieve video files using null delimiter to handle spaces in filenames

mapfile -d '' PICS < <(find "${wallDIR}" -type f ( -iname "*.mp4" ) -print0)

RANDOM_PIC="${PICS[$((RANDOM % ${#PICS[@]}))]}"
RANDOM_PIC_NAME=". random"

Rofi command

rofi_command="rofi -i -show -dmenu -config ~/.config/rofi/config-wallpaper.rasi"

Sorting Wallpapers

menu() {

Sort the PICS array

IFS=$'\n' sorted_options=($(sort &lt;&lt;&lt;"${PICS[*]}"))

Place ". random" at the beginning with the random picture as an icon

random_thumbnail=$(generate_thumbnail "$RANDOM_PIC")
printf "%s\x00icon\x1f%s\n" "$RANDOM_PIC_NAME" "$random_thumbnail"

for pic_path in "${sorted_options[@]}"; do
pic_name=$(basename "$pic_path")
thumbnail=$(generate_thumbnail "$pic_path")

# Displaying .gif to indicate animated images
if [[ ! "$pic_name" =~ \.gif$ ]]; then
  printf "%s\x00icon\x1f%s\n" "$(echo "$pic_name" | cut -d. -f1)" "$thumbnail"
else
  printf "%s\n" "$pic_name"
fi

done
}

Choice of wallpapers

main() {
choice=$(menu | $rofi_command)

Trim any potential whitespace or hidden characters

choice=$(echo "$choice" | xargs)
RANDOM_PIC_NAME=$(echo "$RANDOM_PIC_NAME" | xargs)

No choice case

if [[ -z "$choice" ]]; then
echo "No choice selected. Exiting."
exit 0
fi

Random choice case

if [[ "$choice" == "$RANDOM_PIC_NAME" ]]; then
if pidof mpvpaper >/dev/null; then
pkill -x mpvpaper
fi
mpvpaper -o "--video-crop=3440x1440 --loop
--cache=no
--demuxer-max-bytes=16M
--demuxer-max-back-bytes=8M
--cache-pause-initial=yes
--cache-pause-wait=1
--hwdec=auto
--video-sync=audio
--interpolation=no
--vf=lavfi=[scale=3440:1440:flags=fast_bilinear]"
"$focused_monitor" "${PICS[$pic_index]}"
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
if pidof mpvpaper >/dev/null; then
pkill -x mpvpaper
fi
mpvpaper -o "--video-crop=3440x1440 --loop
--cache=no
--demuxer-max-bytes=16M
--demuxer-max-back-bytes=8M
--cache-pause-initial=yes
--cache-pause-wait=1
--hwdec=auto
--video-sync=audio
--interpolation=no
--vf=lavfi=[scale=3440:1440:flags=fast_bilinear]"
"$focused_monitor" "${PICS[$pic_index]}"
else
echo "Image not found."
exit 1
fi
}
`

@dwilliam62
Copy link
Collaborator

J'ai éditer un script pour mpvpaper dans la suite de JaKooLit je suis novice mais j'espère que ça peux vous aidez.

english please.

Jak will look at it when he is back home from work. Which with the holidays will likely be next year before he can evaluate if he wants to add this or not. he also has the issue of feature parity with all the distros he is currently supporting. it's hard enough with different versions of Hyprland for ubuntu/debian.

@dwilliam62
Copy link
Collaborator

even if it's not being used ? like if you don't apply it will it still consume resources in background ?if yes then we can close it otherwise i don't see any harm in it as users can easily toggle it

it's also something we have to support for all the distros. Means more testing on every update. My suggestion is post this as something people can add if they want to but not something not included in Jak's dotfiles.

I don't see a large benefit to most users. I've seen resource issues when large images are loaded.

@wax-dred
Copy link

I agree with the previous opinion: this script would be more appropriate as a customizable option rather than as a default feature in JaKooLit dotfiles.

@devnchill
Copy link
Contributor Author

during installation just like how user is asked if he wan'ts to disable rainbow borders , maybe we can add a similar prompt asking if they want live wallpaper feature .

@JaKooLit JaKooLit deleted the branch JaKooLit:development December 28, 2024 18:30
@JaKooLit JaKooLit closed this Dec 28, 2024
@devnchill devnchill deleted the livewallpaper branch December 29, 2024 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants