diff --git a/home/hyprland/default.nix b/home/hyprland/default.nix index bdb7e40b..88df3021 100644 --- a/home/hyprland/default.nix +++ b/home/hyprland/default.nix @@ -9,8 +9,8 @@ # copy the scripts directory recursively recursive = true; }; - home.file.".config/hypr/wallpapers/lockscreen.webp".source = ../wallpapers/lockscreen.webp; - home.file.".config/hypr/wallpapers/wallpaper.webp".source = ../wallpapers/wallpaper.webp; + home.file.".config/hypr/wallpapers/lockscreen.png".source = ../wallpapers/lockscreen.png; + home.file.".config/hypr/wallpapers/wallpaper.png".source = ../wallpapers/wallpaper.png; # allow fontconfig to discover fonts and configurations installed through home.packages fonts.fontconfig.enable = true; diff --git a/home/hyprland/hypr-conf/scripts/lockscreen b/home/hyprland/hypr-conf/scripts/lockscreen index 2ca73db1..46fc2195 100755 --- a/home/hyprland/hypr-conf/scripts/lockscreen +++ b/home/hyprland/hypr-conf/scripts/lockscreen @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Background Image -IMAGE="$HOME/.config/hypr/wallpapers/lockscreen.webp" +IMAGE="$HOME/.config/hypr/wallpapers/lockscreen.png" # Colors bg='1e1e2e' bgl='313244' fg='d9e0ee' diff --git a/home/hyprland/hypr-conf/scripts/startup b/home/hyprland/hypr-conf/scripts/startup index ed290cfb..b5178059 100755 --- a/home/hyprland/hypr-conf/scripts/startup +++ b/home/hyprland/hypr-conf/scripts/startup @@ -14,7 +14,7 @@ done /usr/lib/xfce-polkit/xfce-polkit & # Set wallpaper -swaybg --output '*' --mode fill --image ~/.config/hypr/wallpapers/wallpaper.webp & +swaybg --output '*' --mode fill --image ~/.config/hypr/wallpapers/wallpaper.png & # Apply themes ~/.config/hypr/scripts/gtkthemes & diff --git a/home/i3/config b/home/i3/config index 2c63c153..6c6b2e4e 100644 --- a/home/i3/config +++ b/home/i3/config @@ -346,7 +346,7 @@ exec --no-startup-id dex --autostart --environment i3 # set wallpaper # exec --no-startup-id sleep 2 && nitrogen --restore -exec --no-startup-id sleep 1 && feh --bg-fill ~/.config/i3/wallpaper.webp +exec --no-startup-id sleep 1 && feh --bg-fill ~/.config/i3/wallpaper.png # set powersavings for display: exec --no-startup-id xset s 480 dpms 600 600 600 diff --git a/home/i3/default.nix b/home/i3/default.nix index 89b62315..51f301bb 100644 --- a/home/i3/default.nix +++ b/home/i3/default.nix @@ -7,7 +7,7 @@ # 直接从当前文件夹中读取配置文件作为配置内容 # wallpaper, binary file - home.file.".config/i3/wallpaper.webp".source = ../wallpapers/wallpaper.webp; + home.file.".config/i3/wallpaper.png".source = ../wallpapers/wallpaper.png; home.file.".config/i3/config".source = ./config; home.file.".config/i3/i3blocks.conf".source = ./i3blocks.conf; home.file.".config/i3/keybindings".source = ./keybindings; diff --git a/home/wallpapers/convert_to_png.nu b/home/wallpapers/convert_to_png.nu new file mode 100644 index 00000000..57bca9b6 --- /dev/null +++ b/home/wallpapers/convert_to_png.nu @@ -0,0 +1,22 @@ +# convert all images to png + +def to_png [old_path: string, old_format: string] { + # 将后缀改为 .png 得到新图片的 path + let webp_path = ($old_path | split row $old_format | append ".png" | str join) + # 使用 ffmpeg 进行格式转换 + ffmpeg -y -i $old_path $webp_path + # 删除旧图片 + rm $old_path +} + +def convert_format [old_format: string] { + # 递归找出所有大于 10kib 的图片 + let old_paths = (ls $"**/*($old_format)" | where size > 10kb | each {|it| $it.name}) + $old_paths | to md + + # 1. 执行图片格式转换与压缩,同时删除原图片 + $old_paths | each { |it| to_png $it $old_format } +} + +convert_format ".webp" +# convert_format ".jpg" \ No newline at end of file diff --git a/home/wallpapers/convert_to_webp.nu b/home/wallpapers/convert_to_webp.nu deleted file mode 100644 index d6d5b1dd..00000000 --- a/home/wallpapers/convert_to_webp.nu +++ /dev/null @@ -1,37 +0,0 @@ -# convert all png/jpeg images to webp - -def to_webp [old_path: string, old_format: string] { - # 将后缀改为 .webp 得到新图片的 path - let webp_path = ($old_path | split row $old_format | append ".webp" | str collect) - # 使用 ffmpeg 进行格式转换 - ffmpeg -y -i $old_path -c:v libwebp $webp_path - # 删除旧图片 - rm $old_path -} - -def replace_with_webp [old_path: string, old_format: string] { - # 将后缀改为 .webp 得到新图片的 path - let webp_path = ($old_path | split row $old_format | append ".webp" | str collect) - # 图片的旧名称与新名称 - let old_name = ($old_path | path basename) - let webp_name = ($webp_path | path basename) - # 批量将 .md 文件中的所有图片名称,改为对应的 webp 图片名称 - # 注:MacOS 需要首先安装好 gsed,Linux 请将下面的 gsed 替换为 sed - let cmd = $"gsed -ri 's/($old_name)/($webp_name)/g' `find . -name "*.md"`" - echo $cmd - bash -c $cmd -} - -def convert_format(old_format: string) { - # 递归找出所有大于 10kib 的图片 - let old_paths = (ls $"**/*($old_format)" | where size > 10kb | each {|it| $it.name}) - $old_paths | to md | save --raw ./old_paths.txt - - # 1. 执行图片格式转换与压缩,同时删除原图片 - $old_paths | each { |it| to_webp $it $old_format } - # 2. 执行 .md 文档中的图片名称替换 - $old_paths | each { |it| replace_with_webp $it $old_format } -} - -convert_format ".png" -convert_format ".jpg" \ No newline at end of file diff --git a/home/wallpapers/lockscreen.png b/home/wallpapers/lockscreen.png new file mode 100644 index 00000000..8804c9d4 Binary files /dev/null and b/home/wallpapers/lockscreen.png differ diff --git a/home/wallpapers/lockscreen.webp b/home/wallpapers/lockscreen.webp deleted file mode 100644 index f2d1b05f..00000000 Binary files a/home/wallpapers/lockscreen.webp and /dev/null differ diff --git a/home/wallpapers/wallpaper-1.webp b/home/wallpapers/wallpaper-1.webp deleted file mode 100644 index d73bfee3..00000000 Binary files a/home/wallpapers/wallpaper-1.webp and /dev/null differ diff --git a/home/wallpapers/wallpaper-2.png b/home/wallpapers/wallpaper-2.png new file mode 100644 index 00000000..b1140344 Binary files /dev/null and b/home/wallpapers/wallpaper-2.png differ diff --git a/home/wallpapers/wallpaper.png b/home/wallpapers/wallpaper.png new file mode 100644 index 00000000..c5dd3396 Binary files /dev/null and b/home/wallpapers/wallpaper.png differ diff --git a/home/wallpapers/wallpaper.webp b/home/wallpapers/wallpaper.webp deleted file mode 100644 index eb5d2a6f..00000000 Binary files a/home/wallpapers/wallpaper.webp and /dev/null differ