From 64dcba16b7d74e03c68370e283b35f4673acdee2 Mon Sep 17 00:00:00 2001 From: alice Date: Thu, 21 May 2026 17:22:49 +0900 Subject: [PATCH 1/3] move to YSH --- .config/hypr/config/binds.lua | 8 ++++---- .config/hypr/config/init.lua | 4 ++-- .config/hypr/hyprlock.conf | 8 ++++---- .config/niri/config.kdl | 12 ++++++------ .config/sampler/config.yml | 2 +- .config/sampler/config_1.yml | 2 +- .config/systemd/user/cycle_wallpaper.service | 2 +- .config/waybar/config.hypr.jsonc | 2 +- .config/waybar/config.niri.jsonc | 2 +- commands/cmd_p.py | 8 ++++---- script/{__new_bk.sh => __new_bk.ysh} | 2 +- ...iiquarium-sampler.sh => asciiquarium-sampler.ysh} | 2 +- script/{audio_swicher.sh => audio_swicher.ysh} | 2 +- script/cmd_pallet.py | 8 ++++---- script/{dyn_put.sh => dyn_put.ysh} | 2 +- script/{figsep.sh => figsep.ysh} | 2 +- script/{launch-waybar.sh => launch-waybar.ysh} | 2 +- script/{monitor_man.sh => monitor_man.ysh} | 2 +- script/{mpris.sh => mpris.ysh} | 2 +- script/{safe_wallpaper.sh => safe_wallpaper.ysh} | 2 +- script/{search_apps.sh => search_apps.ysh} | 2 +- script/{status_of_slide.sh => status_of_slide.ysh} | 2 +- .../{tlp-waybar-status.sh => tlp-waybar-status.ysh} | 2 +- script/{toggle_theme.sh => toggle_theme.ysh} | 2 +- 24 files changed, 42 insertions(+), 42 deletions(-) rename script/{__new_bk.sh => __new_bk.ysh} (73%) rename script/{asciiquarium-sampler.sh => asciiquarium-sampler.ysh} (98%) rename script/{audio_swicher.sh => audio_swicher.ysh} (97%) rename script/{dyn_put.sh => dyn_put.ysh} (78%) rename script/{figsep.sh => figsep.ysh} (97%) rename script/{launch-waybar.sh => launch-waybar.ysh} (95%) rename script/{monitor_man.sh => monitor_man.ysh} (95%) rename script/{mpris.sh => mpris.ysh} (99%) rename script/{safe_wallpaper.sh => safe_wallpaper.ysh} (86%) rename script/{search_apps.sh => search_apps.ysh} (97%) rename script/{status_of_slide.sh => status_of_slide.ysh} (91%) rename script/{tlp-waybar-status.sh => tlp-waybar-status.ysh} (90%) rename script/{toggle_theme.sh => toggle_theme.ysh} (95%) diff --git a/.config/hypr/config/binds.lua b/.config/hypr/config/binds.lua index 4909ee9..7d5f805 100644 --- a/.config/hypr/config/binds.lua +++ b/.config/hypr/config/binds.lua @@ -70,12 +70,12 @@ hl.bind("SUPER + backslash", hl.dsp.workspace.toggle_special("SCR")) hl.bind("SUPER + SHIFT + backslash", hl.dsp.window.move({ workspace = "special:SCR" })) -- wallpapers -hl.bind("SUPER + W", hl.dsp.exec_cmd("sh ~/dotfiles/script/cycle_wallpaper.sh 'seq'")) -hl.bind("SUPER + SHIFT + W", hl.dsp.exec_cmd("sh ~/dotfiles/script/cycle_wallpaper.sh 'rev'")) +hl.bind("SUPER + W", hl.dsp.exec_cmd("ysh ~/dotfiles/script/cycle_wallpaper.ysh 'seq'")) +hl.bind("SUPER + SHIFT + W", hl.dsp.exec_cmd("ysh ~/dotfiles/script/cycle_wallpaper.ysh 'rev'")) -- video wallpaper -hl.bind("ALT + W", hl.dsp.exec_cmd("sh ~/dotfiles/script/cycle_wallpaper.sh 'vdo'")) +hl.bind("ALT + W", hl.dsp.exec_cmd("ysh ~/dotfiles/script/cycle_wallpaper.ysh 'vdo'")) -- safe wallpaper -hl.bind("SUPER + ALT + W", hl.dsp.exec_cmd("sh ~/dotfiles/script/safe_wallpaper.sh")) +hl.bind("SUPER + ALT + W", hl.dsp.exec_cmd("ysh ~/dotfiles/script/safe_wallpaper.ysh")) -- Immediately lock -- bind = SUPER SHIFT, E, exec, ~/dotfiles/commands/logout.py diff --git a/.config/hypr/config/init.lua b/.config/hypr/config/init.lua index 010dd3f..1207f1a 100644 --- a/.config/hypr/config/init.lua +++ b/.config/hypr/config/init.lua @@ -9,6 +9,6 @@ hl.on("hyprland.start", function() hl.exec_cmd("swaync") hl.exec_cmd("hyprctl setcursor Bibata-Modern-Ice 24") hl.exec_cmd("awww-daemon") - hl.exec_cmd("sh ~/dotfiles/script/cycle_wallpaper.sh") - hl.exec_cmd("sh ~/dotfiles/script/launch-waybar.sh") + hl.exec_cmd("ysh ~/dotfiles/script/cycle_wallpaper.ysh") + hl.exec_cmd("ysh ~/dotfiles/script/launch-waybar.ysh") end) diff --git a/.config/hypr/hyprlock.conf b/.config/hypr/hyprlock.conf index c0080fa..00be5f0 100644 --- a/.config/hypr/hyprlock.conf +++ b/.config/hypr/hyprlock.conf @@ -110,7 +110,7 @@ shape { # play status label { monitor = - text = cmd[update:2000] ~/dotfiles/script/mpris.sh status + text = cmd[update:2000] ~/dotfiles/script/mpris.ysh status color = rgba(203, 166, 247, 0.8) font_size = 11 font_family = 0xProto Nerd Font @@ -123,7 +123,7 @@ label { # title label { monitor = - text = cmd[update:2000] ~/dotfiles/script/mpris.sh title + text = cmd[update:2000] ~/dotfiles/script/mpris.ysh title color = rgb(205, 214, 244) font_size = 15 font_family = 0xProto Nerd Font Bold @@ -136,7 +136,7 @@ label { # artist label { monitor = - text = cmd[update:2000] ~/dotfiles/script/mpris.sh artist + text = cmd[update:2000] ~/dotfiles/script/mpris.ysh artist color = rgba(166, 173, 200, 0.75) font_size = 12 font_family = 0xProto Nerd Font @@ -149,7 +149,7 @@ label { # progress bar label { monitor = - text = cmd[update:2000] ~/dotfiles/script/mpris.sh progress + text = cmd[update:2000] ~/dotfiles/script/mpris.ysh progress color = rgba(203, 166, 247, 0.6) font_size = 10 font_family = 0xProto Nerd Font Mono diff --git a/.config/niri/config.kdl b/.config/niri/config.kdl index 96aa67b..60cabce 100644 --- a/.config/niri/config.kdl +++ b/.config/niri/config.kdl @@ -28,8 +28,8 @@ spawn-at-startup "sh" "-c" "dbus-update-activation-environment --systemd WAYLAND spawn-at-startup "sh" "-c" "systemctl --user stop xdg-desktop-portal xdg-desktop-portal-hyprland xdg-desktop-portal-wlr xdg-desktop-portal-gtk; systemctl --user start xdg-desktop-portal" spawn-at-startup "awww-daemon" -spawn-at-startup "sh" "$HOME/dotfiles/script/cycle_wallpaper.sh" -spawn-at-startup "sh" "$HOME/dotfiles/script/launch-waybar.sh" +spawn-at-startup "ysh" "$HOME/dotfiles/script/cycle_wallpaper.ysh" +spawn-at-startup "ysh" "$HOME/dotfiles/script/launch-waybar.ysh" spawn-at-startup "swaync" spawn-at-startup "fcitx5" spawn-at-startup "wl-paste" "--type" "text" "--watch" "cliphist" "store" @@ -228,10 +228,10 @@ binds { Alt+L hotkey-overlay-title="Lock the Screen: Swaylock" { spawn "swaylock"; } - Mod+W { spawn "~/dotfiles/script/cycle_wallpaper.sh" "seq"; } - Mod+Shift+W { spawn "~/dotfiles/script/cycle_wallpaper.sh" "rev"; } - Ctrl+Alt+W { spawn "~/dotfiles/script/cycle_wallpaper.sh" "rnd"; } - Mod+Alt+W { spawn "~/dotfiles/script/safe_wallpaper.sh"; } + Mod+W { spawn "ysh" "/home/alice/dotfiles/script/cycle_wallpaper.ysh" "seq"; } + Mod+Shift+W { spawn "ysh" "/home/alice/dotfiles/script/cycle_wallpaper.ysh" "rev"; } + Ctrl+Alt+W { spawn "ysh" "/home/alice/dotfiles/script/cycle_wallpaper.ysh" "rnd"; } + Mod+Alt+W { spawn "ysh" "/home/alice/dotfiles/script/safe_wallpaper.ysh"; } Super+Print { screenshot; } Print { screenshot-window; } diff --git a/.config/sampler/config.yml b/.config/sampler/config.yml index 2f9e630..9e31aee 100644 --- a/.config/sampler/config.yml +++ b/.config/sampler/config.yml @@ -105,7 +105,7 @@ textboxes: rate-ms: 500 color: 45 sample: | - sh -c '$HOME/dotfiles/script/asciiquarium-sampler.sh 40 15' + ysh -c '$HOME/dotfiles/script/asciiquarium-sampler.ysh 40 15' border: true asciiboxes: - title: Clock diff --git a/.config/sampler/config_1.yml b/.config/sampler/config_1.yml index 6a5882f..ddef70b 100644 --- a/.config/sampler/config_1.yml +++ b/.config/sampler/config_1.yml @@ -105,7 +105,7 @@ textboxes: rate-ms: 500 color: 45 sample: | - sh -c '$HOME/dotfiles/script/asciiquarium-sampler.sh 100 18' + ysh -c '$HOME/dotfiles/script/asciiquarium-sampler.ysh 100 18' border: true asciiboxes: diff --git a/.config/systemd/user/cycle_wallpaper.service b/.config/systemd/user/cycle_wallpaper.service index 7e86dff..521b638 100644 --- a/.config/systemd/user/cycle_wallpaper.service +++ b/.config/systemd/user/cycle_wallpaper.service @@ -3,7 +3,7 @@ Description=wallpaper cycle by awww [Service] Type=oneshot -ExecStart=%h/dotfiles/script/cycle_wallpaper.sh rnd +ExecStart=/usr/bin/env ysh %h/dotfiles/script/cycle_wallpaper.ysh rnd StandardOutput=journal StandardError=journal diff --git a/.config/waybar/config.hypr.jsonc b/.config/waybar/config.hypr.jsonc index 8f75d83..302fb4a 100644 --- a/.config/waybar/config.hypr.jsonc +++ b/.config/waybar/config.hypr.jsonc @@ -119,7 +119,7 @@ "on-click": "kitty --class='dev-float' -e jolt" }, "custom/tlp": { - "exec": "~/dotfiles/script/tlp-waybar-status.sh", + "exec": "~/dotfiles/script/tlp-waybar-status.ysh", "interval": 30, "format": "󰌪 {}" }, diff --git a/.config/waybar/config.niri.jsonc b/.config/waybar/config.niri.jsonc index 8abe979..3abab4d 100644 --- a/.config/waybar/config.niri.jsonc +++ b/.config/waybar/config.niri.jsonc @@ -116,7 +116,7 @@ }, "custom/tlp": { - "exec": "~/dotfiles/script/tlp-waybar-status.sh", + "exec": "~/dotfiles/script/tlp-waybar-status.ysh", "interval": 30, "format": "󰌪 {}" }, diff --git a/commands/cmd_p.py b/commands/cmd_p.py index 02ac3f9..357e50e 100755 --- a/commands/cmd_p.py +++ b/commands/cmd_p.py @@ -10,14 +10,14 @@ cmds = { "󰸉 Toggle WP slideshow": ["sh", script + "cycle_wallpaper.sh", "pse"], - "󰔎 Toggle theme L-D": ["sh", script + "toggle_theme.sh"], + "󰔎 Toggle theme L-D": ["ysh", script + "toggle_theme.ysh"], " Random WP": ["sh", script + "cycle_wallpaper.sh", "rnd"], - "󰴰 Change to pub WP": ["sh", script + "safe_wallpaper.sh"], - " Show status of WP slide": ["sh", script + "status_of_slide.sh"], + "󰴰 Change to pub WP": ["ysh", script + "safe_wallpaper.ysh"], + " Show status of WP slide": ["ysh", script + "status_of_slide.ysh"], "󱎐 Launch white in kitty": ["kitty", "--config", home + "/dotfiles/.config/kitty/light.conf"], "󰹑 Screenshot active monitor": ["hyprshot", "-m", "output", "-m", "active", "--freeze"], "󱂬 Screenshot active window": ["hyprshot", "-m", "window", "-m", "active", "--freeze"], - " Toggle visual effects": ["sh", script + "toggle_visual.sh"], + " Toggle visual effects": ["ysh", script + "toggle_visual.ysh"], "󰑓 Reload Hyprland config": ["hyprctl", "reload"], } diff --git a/script/__new_bk.sh b/script/__new_bk.ysh similarity index 73% rename from script/__new_bk.sh rename to script/__new_bk.ysh index 29a6aa6..6af3692 100755 --- a/script/__new_bk.sh +++ b/script/__new_bk.ysh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env ysh mount_p="$(mount | grep bk | awk '{print $3}')" if diff --git a/script/asciiquarium-sampler.sh b/script/asciiquarium-sampler.ysh similarity index 98% rename from script/asciiquarium-sampler.sh rename to script/asciiquarium-sampler.ysh index c04fe57..ccc7c6b 100755 --- a/script/asciiquarium-sampler.sh +++ b/script/asciiquarium-sampler.ysh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env ysh # Render Asciiquarium inside sampler by running it in a tmux session # and capturing the pane contents. diff --git a/script/audio_swicher.sh b/script/audio_swicher.ysh similarity index 97% rename from script/audio_swicher.sh rename to script/audio_swicher.ysh index 03a8896..ba4512a 100755 --- a/script/audio_swicher.sh +++ b/script/audio_swicher.ysh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env ysh # 1. Sinks(出力)セクションから次のセクション(Sources)までの間だけを抜き出す # 2. その中からIDと名前の行を取得 diff --git a/script/cmd_pallet.py b/script/cmd_pallet.py index 3564527..c73d4e0 100755 --- a/script/cmd_pallet.py +++ b/script/cmd_pallet.py @@ -10,15 +10,15 @@ cmds = { "󰸉 Toggle slideshow of wallpapers": ["sh", script + "cycle_wallpaper.sh", "pse"], - "󰔎 Toggle light-dark theme": ["sh", script + "toggle_theme.sh"], + "󰔎 Toggle light-dark theme": ["ysh", script + "toggle_theme.ysh"], " Random wallpaper": ["sh", script + "cycle_wallpaper.sh", "rnd"], - "󰴰 Change to pub wall": ["sh", script + "safe_wallpaper.sh"], - "Show status of wallpaper slide": ["sh", script + "status_of_slide.sh"], + "󰴰 Change to pub wall": ["ysh", script + "safe_wallpaper.ysh"], + "Show status of wallpaper slide": ["ysh", script + "status_of_slide.ysh"], "Launch slide in kitty": ["kitty", "--config", home + "/dotfiles/.config/kitty/slide.conf", "--directory", slide_dev], "Launch white in kitty": ["kitty", "--config", home + "/dotfiles/.config/kitty/light.conf"], "󰹑 Screenshot active monitor": ["hyprshot", "-m", "output", "-m", "active", "--freeze"], "󱂬 Screenshot active window": ["hyprshot", "-m", "window", "-m", "active", "--freeze"], - "Toggle visual effects": ["sh", script + "toggle_visual.sh"], + "Toggle visual effects": ["ysh", script + "toggle_visual.ysh"], "Reload Hyprland config": ["hyprctl", "reload"], } diff --git a/script/dyn_put.sh b/script/dyn_put.ysh similarity index 78% rename from script/dyn_put.sh rename to script/dyn_put.ysh index 6170e47..18b3e4c 100755 --- a/script/dyn_put.sh +++ b/script/dyn_put.ysh @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/usr/bin/env ysh if command -v bat >/dev/null 2>&1; then bat "$@" diff --git a/script/figsep.sh b/script/figsep.ysh similarity index 97% rename from script/figsep.sh rename to script/figsep.ysh index fea85a4..6c62eb3 100755 --- a/script/figsep.sh +++ b/script/figsep.ysh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env ysh export NVM_DIR="$HOME/.config/nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" diff --git a/script/launch-waybar.sh b/script/launch-waybar.ysh similarity index 95% rename from script/launch-waybar.sh rename to script/launch-waybar.ysh index 577292a..e1a222d 100755 --- a/script/launch-waybar.sh +++ b/script/launch-waybar.ysh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env ysh # script/launch-waybar.sh diff --git a/script/monitor_man.sh b/script/monitor_man.ysh similarity index 95% rename from script/monitor_man.sh rename to script/monitor_man.ysh index 1ed5d4b..cb6fa12 100755 --- a/script/monitor_man.sh +++ b/script/monitor_man.ysh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env ysh base_path="$HOME/dotfiles/.config/hypr/monitor" moni_path="$HOME/dotfiles/.config/hypr/monitor/monitor.conf" diff --git a/script/mpris.sh b/script/mpris.ysh similarity index 99% rename from script/mpris.sh rename to script/mpris.ysh index f9f4664..116d66d 100755 --- a/script/mpris.sh +++ b/script/mpris.ysh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env ysh # mpris.sh diff --git a/script/safe_wallpaper.sh b/script/safe_wallpaper.ysh similarity index 86% rename from script/safe_wallpaper.sh rename to script/safe_wallpaper.ysh index b5fb6e4..9cbb645 100755 --- a/script/safe_wallpaper.sh +++ b/script/safe_wallpaper.ysh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env ysh WALLPAPER="$HOME/Pictures/safe_wallpaper/snow.jpg" awww img "$WALLPAPER" --transition-type center --transition-duration 0.5 diff --git a/script/search_apps.sh b/script/search_apps.ysh similarity index 97% rename from script/search_apps.sh rename to script/search_apps.ysh index c237ff9..f043314 100755 --- a/script/search_apps.sh +++ b/script/search_apps.ysh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env ysh TARGET=$1 diff --git a/script/status_of_slide.sh b/script/status_of_slide.ysh similarity index 91% rename from script/status_of_slide.sh rename to script/status_of_slide.ysh index f6547fb..b69f8e2 100755 --- a/script/status_of_slide.sh +++ b/script/status_of_slide.ysh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env ysh systemctl --user status cycle_wallpaper.timer | grep "Active" diff --git a/script/tlp-waybar-status.sh b/script/tlp-waybar-status.ysh similarity index 90% rename from script/tlp-waybar-status.sh rename to script/tlp-waybar-status.ysh index 617ef06..ba90e69 100755 --- a/script/tlp-waybar-status.sh +++ b/script/tlp-waybar-status.ysh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env ysh tlp-stat -s | grep -Ei 'Power profile|TLP Profile' | awk '{print $4}' | awk -F'/' '{m=$1=="performance"?"PRF":$1=="balanced"?"BAL":$1=="powersave"?"SAV":$1; print NF==2?m"/"$2:m}' diff --git a/script/toggle_theme.sh b/script/toggle_theme.ysh similarity index 95% rename from script/toggle_theme.sh rename to script/toggle_theme.ysh index cb71edb..350c9d4 100755 --- a/script/toggle_theme.sh +++ b/script/toggle_theme.ysh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env ysh CURRENT=$(gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null) From 976ebf7fbdd5190d2d041b8ea29f4b93cf71a380 Mon Sep 17 00:00:00 2001 From: alice Date: Thu, 21 May 2026 18:00:56 +0900 Subject: [PATCH 2/3] refactor: migrate shell scripts to YSH syntax --- script/cycle_wallpaper.ysh | 192 ++++++++++++++++++++----------------- script/launch-waybar.ysh | 39 ++++---- script/monitor_man.ysh | 28 ++++-- script/mpris.ysh | 166 +++++++++++++++++--------------- script/safe_wallpaper.ysh | 4 +- script/toggle_theme.ysh | 8 +- 6 files changed, 241 insertions(+), 196 deletions(-) diff --git a/script/cycle_wallpaper.ysh b/script/cycle_wallpaper.ysh index 83e15cb..de6d9ff 100755 --- a/script/cycle_wallpaper.ysh +++ b/script/cycle_wallpaper.ysh @@ -1,126 +1,138 @@ #!/usr/bin/env ysh -forward_mode=0 -reverse_mode=1 -current_paper_path="$HOME/dotfiles/.config/hypr/env/CURRENT_PAPER" -wallpaper_dir="$HOME/Pictures/wallpapers/" -wallvideo_path="$HOME/Pictures/wallvideo/ok_geek_eyes_24.mp4" -mpvpaper_args="--hwdec=auto-safe --vo=gpu" - -get_all() { - find "$1" -maxdepth 1 -type f | sort -} +var HOME = ENV.HOME + +var forward_mode = 0 +var reverse_mode = 1 +var current_paper_path = "${HOME}/dotfiles/.config/hypr/env/CURRENT_PAPER" +var wallpaper_dir = "${HOME}/Pictures/wallpapers/" +var wallvideo_path = "${HOME}/Pictures/wallvideo/ok_geek_eyes_24.mp4" +var mpvpaper_args = "--hwdec=auto-safe --vo=gpu" -get_first_path() { - get_all "$1" | head -n 1 +proc get_all(dir) { + find "$dir" -maxdepth 1 -type f | sort } -get_next_path() { - local current_path="$1" - local listed_paths="$2" - local rev_mode="$3" - local matched +proc get_first_path(dir) { + get_all "$dir" | head -n 1 +} - if (( rev_mode == forward_mode )); then - matched="$(printf '%s\n' "$listed_paths" | grep -Fx "$current_path" -A 1)" - else - matched="$(printf '%s\n' "$listed_paths" | grep -Fx "$current_path" -B 1)" - fi +proc get_next_path(current_path, listed_paths, rev_mode) { + var matched = "" + if (rev_mode === forward_mode) { + setvar matched = $(printf '%s\n' "$listed_paths" | grep -Fx "$current_path" -A 1) + } else { + setvar matched = $(printf '%s\n' "$listed_paths" | grep -Fx "$current_path" -B 1) + } - local matched_lines - matched_lines="$(printf '%s\n' "$matched" | wc -l | tr -d ' ')" + var matched_lines = $(printf '%s\n' "$matched" | wc -l | tr -d ' ') - if (( matched_lines != 2 )); then - if (( rev_mode == forward_mode )); then + if (matched_lines !== "2") { + if (rev_mode === forward_mode) { printf '%s\n' "$listed_paths" | head -n 1 - else + } else { printf '%s\n' "$listed_paths" | tail -n 1 - fi - else - if (( rev_mode == forward_mode )); then + } + } else { + if (rev_mode === forward_mode) { printf '%s\n' "$matched" | tail -n 1 - else + } else { printf '%s\n' "$matched" | head -n 1 - fi - fi + } + } } -seq_or_rev() { - local rev_mode="$1" - local wallpaper_dir="$2" - local next - - if [[ -s "$current_paper_path" ]]; then - local current_paper - current_paper="$(cat "$current_paper_path")" - if [[ -f "$current_paper" ]]; then - local list - list="$(get_all "$wallpaper_dir")" - next="$(get_next_path "$current_paper" "$list" "$rev_mode")" - else - next="$(get_first_path "$wallpaper_dir")" - fi - else - next="$(get_first_path "$wallpaper_dir")" - fi - - printf '%s\n' "$next" >"$current_paper_path" +proc seq_or_rev(rev_mode, wallpaper_dir) { + var next = "" + if test -s "$current_paper_path" { + var current_paper = $(cat "$current_paper_path") + if test -f "$current_paper" { + var list = $(get_all "$wallpaper_dir") + setvar next = $(get_next_path "$current_paper" "$list" "$rev_mode") + } else { + setvar next = $(get_first_path "$wallpaper_dir") + } + } else { + setvar next = $(get_first_path "$wallpaper_dir") + } + + printf '%s\n' "$next" > "$current_paper_path" printf '%s\n' "$next" } -random_paper() { - local wallpaper_dir="$1" - local randomed_path - - randomed_path="$(find "$wallpaper_dir" -type f | shuf -n 1)" - printf '%s\n' "$randomed_path" >"$current_paper_path" +proc random_paper(wallpaper_dir) { + var randomed_path = $(find "$wallpaper_dir" -type f | shuf -n 1) + printf '%s\n' "$randomed_path" > "$current_paper_path" printf '%s\n' "$randomed_path" } -toggle_systemtimer() { - if systemctl --user is-active --quiet cycle_wallpaper.timer; then - if systemctl --user stop cycle_wallpaper.timer; then +proc toggle_systemtimer() { + if systemctl --user is-active --quiet cycle_wallpaper.timer { + if systemctl --user stop cycle_wallpaper.timer { notify-send "Stop slideshow" - else + } else { notify-send "Failed stop slideshow" - fi - else - if systemctl --user start cycle_wallpaper.timer; then + } + } else { + if systemctl --user start cycle_wallpaper.timer { notify-send "Start slideshow" - else + } else { notify-send "Failed start slideshow" - fi - fi + } + } } -toggle_video() { - local v_pid - v_pid="$(pgrep mpvpaper || true)" +proc toggle_video() { + var v_pid = $(pgrep mpvpaper || true) - if [[ -n "$v_pid" ]]; then - if pkill mpvpaper; then + if (v_pid !== "") { + if pkill mpvpaper { notify-send "Stop wallvideo" - else + } else { notify-send "Failed stop wallvideo" - fi - else - if mpvpaper '*' "$wallvideo_path" -o "no-audio loop" --fork --mpv-args="$mpvpaper_args"; then + } + } else { + if mpvpaper '*' "$wallvideo_path" -o "no-audio loop" --fork --mpv-args="$mpvpaper_args" { notify-send "Start wallvideo" - else + } else { notify-send "Failed start wallvideo" - fi - fi + } + } } -case "${1:-}" in - seq) wall_path="$(seq_or_rev "$forward_mode" "$wallpaper_dir")" ;; - rev) wall_path="$(seq_or_rev "$reverse_mode" "$wallpaper_dir")" ;; - rnd) wall_path="$(random_paper "$wallpaper_dir")" ;; - vdo) toggle_video && exit 0 || exit 1 ;; - pse) toggle_systemtimer && exit 0 || exit 1 ;; - *) wall_path="${2:-}" ;; +var wall_path = "" +var arg1 = "" +if (len(ARGV) > 0) { + setvar arg1 = ARGV[0] +} + +case "$arg1" in + seq) + setvar wall_path = $(seq_or_rev "$forward_mode" "$wallpaper_dir") + ;; + rev) + setvar wall_path = $(seq_or_rev "$reverse_mode" "$wallpaper_dir") + ;; + rnd) + setvar wall_path = $(random_paper "$wallpaper_dir") + ;; + vdo) + toggle_video + exit 0 + ;; + pse) + toggle_systemtimer + exit 0 + ;; + *) + if (len(ARGV) > 1) { + setvar wall_path = ARGV[1] + } + ;; esac -mkdir -p "$HOME/dotfiles/.config/hypr/env" +mkdir -p "${HOME}/dotfiles/.config/hypr/env" -awww img "$wall_path" --transition-type center --transition-duration 0.5 +if (wall_path !== "") { + awww img "$wall_path" --transition-type center --transition-duration 0.5 +} diff --git a/script/launch-waybar.ysh b/script/launch-waybar.ysh index e1a222d..75f1a55 100755 --- a/script/launch-waybar.ysh +++ b/script/launch-waybar.ysh @@ -1,28 +1,35 @@ #!/usr/bin/env ysh -# script/launch-waybar.sh +# script/launch-waybar.ysh # $1: style file -killall waybar || true +var HOME = ENV.HOME +var XDG_CURRENT_DESKTOP = ENV.XDG_CURRENT_DESKTOP + pkill waybar || true sleep 0.5 -STYLE="$HOME/dotfiles/.config/waybar/style.css" -BASE="$HOME/dotfiles/.config/waybar" +var STYLE = "${HOME}/dotfiles/.config/waybar/style.css" +var BASE = "${HOME}/dotfiles/.config/waybar" + +var arg1 = "" +if (len(ARGV) > 0) { + setvar arg1 = ARGV[0] +} -if [[ -e "$1" ]]; then - STYLE="$1" -fi +if test -e "$arg1" { + setvar STYLE = arg1 +} case "$XDG_CURRENT_DESKTOP" in -Hyprland) - waybar -c "$BASE/config.hypr.jsonc" -s "$STYLE" & - ;; -niri) - waybar -c "$BASE/config.niri.jsonc" -s "$STYLE" & - ;; -sway:wlroots) - waybar -c "$BASE/config.sway.jsonc" -s "$STYLE" & - ;; + Hyprland) + waybar -c "$BASE/config.hypr.jsonc" -s "$STYLE" & + ;; + niri) + waybar -c "$BASE/config.niri.jsonc" -s "$STYLE" & + ;; + sway:wlroots) + waybar -c "$BASE/config.sway.jsonc" -s "$STYLE" & + ;; esac diff --git a/script/monitor_man.ysh b/script/monitor_man.ysh index cb6fa12..89fb9cb 100755 --- a/script/monitor_man.ysh +++ b/script/monitor_man.ysh @@ -1,17 +1,29 @@ #!/usr/bin/env ysh -base_path="$HOME/dotfiles/.config/hypr/monitor" -moni_path="$HOME/dotfiles/.config/hypr/monitor/monitor.conf" +var HOME = ENV.HOME -help_msg="dsgl: thinkpad + ~~4k~~ +var base_path = "${HOME}/dotfiles/.config/hypr/monitor" +var moni_path = "${HOME}/dotfiles/.config/hypr/monitor/monitor.conf" + +var help_msg = "dsgl: thinkpad + ~~4k~~ lsgl: thinkpad dual: thinkpad + 4k" -case "$1" in -dsgl) path="${base_path}/home.conf" ;; -lsgl) path="${base_path}/laptop.conf" ;; -dual) path="${base_path}/home_dual.conf" ;; -*) path=$2 ;; +var arg1 = "" +if (len(ARGV) > 0) { + setvar arg1 = ARGV[0] +} + +var path = "" +case "$arg1" in + dsgl) setvar path = "${base_path}/home.conf" ;; + lsgl) setvar path = "${base_path}/laptop.conf" ;; + dual) setvar path = "${base_path}/home_dual.conf" ;; + *) + if (len(ARGV) > 1) { + setvar path = ARGV[1] + } + ;; esac ln -fs "$path" "$moni_path" diff --git a/script/mpris.ysh b/script/mpris.ysh index 116d66d..803e611 100755 --- a/script/mpris.ysh +++ b/script/mpris.ysh @@ -1,36 +1,38 @@ #!/usr/bin/env ysh -# mpris.sh +# mpris.ysh + +var HOME = ENV.HOME +var XDG_CACHE_HOME = ENV.XDG_CACHE_HOME || "${HOME}/.cache" +var CACHE_DIR = "${XDG_CACHE_HOME}/hyprlock" -CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/hyprlock" mkdir -p "$CACHE_DIR" -_player() { +proc _player() { playerctl --list-all 2>/dev/null | head -1 } -_is_active() { - local player="$1" - local status - status=$(playerctl --player="$player" status 2>/dev/null) - [ "$status" = "Playing" ] || [ "$status" = "Paused" ] +proc _is_active(player) { + var status = $(playerctl --player="$player" status 2>/dev/null) + if (status === "Playing" || status === "Paused") { + return 0 + } + return 1 } -mpris_status() { - local player - player=$(_player) - [ -z "$player" ] && return +proc mpris_status() { + var player = $(_player) + if (player === "") { return } - local status - status=$(playerctl --player="$player" status 2>/dev/null) + var status = $(playerctl --player="$player" status 2>/dev/null) case "$status" in Playing) - local icon + var icon = "" case "$player" in - *spotify*) icon="" ;; - *mpd*|*mopidy*) icon="󰎆" ;; - *firefox*|*chrom*) icon="󰈹" ;; - *) icon="󰝚" ;; + *spotify*) setvar icon = "" ;; + *mpd*|*mopidy*) setvar icon = "󰎆" ;; + *firefox*|*chrom*) setvar icon = "󰈹" ;; + *) setvar icon = "󰝚" ;; esac echo "$icon Now Playing" ;; @@ -40,95 +42,107 @@ mpris_status() { esac } -mpris_title() { - local player - player=$(_player) - [ -z "$player" ] && return - _is_active "$player" || return +proc mpris_title() { + var player = $(_player) + if (player === "") { return } + if _is_active "$player" { + # continue + } else { + return + } - local title - title=$(playerctl --player="$player" metadata title 2>/dev/null) - [ -z "$title" ] && return + var title = $(playerctl --player="$player" metadata title 2>/dev/null) + if (title === "") { return } - if [ ${#title} -gt 28 ]; then + if (len(title) > 28) { echo "${title:0:26}…" else echo "$title" - fi + } } -mpris_artist() { - local player - player=$(_player) - [ -z "$player" ] && return - _is_active "$player" || return +proc mpris_artist() { + var player = $(_player) + if (player === "") { return } + if _is_active "$player" { + # continue + } else { + return + } - local artist - artist=$(playerctl --player="$player" metadata artist 2>/dev/null) - [ -z "$artist" ] && return + var artist = $(playerctl --player="$player" metadata artist 2>/dev/null) + if (artist === "") { return } - if [ ${#artist} -gt 32 ]; then + if (len(artist) > 32) { echo "${artist:0:30}…" else echo "$artist" - fi + } } -mpris_progress() { - local player - player=$(_player) - [ -z "$player" ] && return - _is_active "$player" || return +proc mpris_progress() { + var player = $(_player) + if (player === "") { return } + if _is_active "$player" { + # continue + } else { + return + } - local pos length - pos=$(playerctl --player="$player" position 2>/dev/null | cut -d. -f1) - length=$(playerctl --player="$player" metadata mpris:length 2>/dev/null) - [ -z "$pos" ] || [ -z "$length" ] && return + var pos = $(playerctl --player="$player" position 2>/dev/null | cut -d. -f1) + var length = $(playerctl --player="$player" metadata mpris:length 2>/dev/null) + if (pos === "" || length === "") { return } - local len_sec=$((length / 1000000)) - [ $len_sec -le 0 ] && return + var len_sec = $(echo $((length / 1000000))) + if (len_sec === "0") { return } - local pos_min=$((pos / 60)) - local pos_sec=$((pos % 60)) - local len_min=$((len_sec / 60)) - local len_sec_r=$((len_sec % 60)) + var pos_min = $(echo $((pos / 60))) + var pos_sec = $(echo $((pos % 60))) + var len_min = $(echo $((len_sec / 60))) + var len_sec_r = $(echo $((len_sec % 60))) - local filled=$((pos * 16 / len_sec)) - [ $filled -gt 16 ] && filled=16 + var filled = $(echo $((pos * 16 / len_sec))) + if (int(filled) > 16) { setvar filled = "16" } - local bar="" - for i in $(seq 1 $filled); do bar="${bar}━"; done - for i in $(seq $((filled+1)) 16); do bar="${bar}─"; done + var bar = "" + for i in $(seq 1 $filled) { setvar bar = "${bar}━" } + for i in $(seq $((int(filled)+1)) 16) { setvar bar = "${bar}─" } printf "%d:%02d %s %d:%02d\n" $pos_min $pos_sec "$bar" $len_min $len_sec_r } -mpris_art() { - local player - player=$(_player) - [ -z "$player" ] && return - _is_active "$player" || return +proc mpris_art() { + var player = $(_player) + if (player === "") { return } + if _is_active "$player" { + # continue + } else { + return + } - local url - url=$(playerctl --player="$player" metadata mpris:artUrl 2>/dev/null) - [ -z "$url" ] && return + var url = $(playerctl --player="$player" metadata mpris:artUrl 2>/dev/null) + if (url === "") { return } - if [[ "$url" == file://* ]]; then + if (url.startsWith("file://")) { echo "${url#file://}" else - local trackid - trackid=$(playerctl --player="$player" metadata mpris:trackid 2>/dev/null | tr -dc 'a-zA-Z0-9' | tail -c 40) - local cached="$CACHE_DIR/art_${trackid}.jpg" - if [ ! -f "$cached" ]; then + var trackid = $(playerctl --player="$player" metadata mpris:trackid 2>/dev/null | tr -dc 'a-zA-Z0-9' | tail -c 40) + var cached = "${CACHE_DIR}/art_${trackid}.jpg" + if test ! -f "$cached" { rm -f "$CACHE_DIR"/art_*.jpg 2>/dev/null curl -sL "$url" -o "$cached" 2>/dev/null - fi - [ -f "$cached" ] && echo "$cached" - fi + } + if test -f "$cached" { echo "$cached" } + } } # エントリポイント -case "$1" in +var arg1 = "" +if (len(ARGV) > 0) { + setvar arg1 = ARGV[0] +} + +case "$arg1" in status) mpris_status ;; title) mpris_title ;; artist) mpris_artist ;; diff --git a/script/safe_wallpaper.ysh b/script/safe_wallpaper.ysh index 9cbb645..a040075 100755 --- a/script/safe_wallpaper.ysh +++ b/script/safe_wallpaper.ysh @@ -1,5 +1,5 @@ #!/usr/bin/env ysh -WALLPAPER="$HOME/Pictures/safe_wallpaper/snow.jpg" +var HOME = ENV.HOME +var WALLPAPER = "${HOME}/Pictures/safe_wallpaper/snow.jpg" awww img "$WALLPAPER" --transition-type center --transition-duration 0.5 - diff --git a/script/toggle_theme.ysh b/script/toggle_theme.ysh index 350c9d4..6c07d31 100755 --- a/script/toggle_theme.ysh +++ b/script/toggle_theme.ysh @@ -1,11 +1,11 @@ #!/usr/bin/env ysh -CURRENT=$(gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null) +var CURRENT = $(gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null) -if [[ "$CURRENT" == *"dark"* ]]; then +if (CURRENT.contains("dark")) { gsettings set org.gnome.desktop.interface color-scheme 'prefer-light' notify-send -i weather-clear "Theme" "Switched to Light Mode" -else +} else { gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' notify-send -i weather-clear-night "Theme" "Switched to Dark Mode" -fi +} From 9925d56067b57ae249c5c26d67b9821ba0ff2146 Mon Sep 17 00:00:00 2001 From: alice Date: Thu, 21 May 2026 18:28:17 +0900 Subject: [PATCH 3/3] ysh: fix almost issues --- script/cycle_wallpaper.ysh | 4 ++-- script/launch-waybar.ysh | 6 +++--- script/tlp-waybar-status.ysh | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/script/cycle_wallpaper.ysh b/script/cycle_wallpaper.ysh index de6d9ff..b5323b3 100755 --- a/script/cycle_wallpaper.ysh +++ b/script/cycle_wallpaper.ysh @@ -7,7 +7,7 @@ var reverse_mode = 1 var current_paper_path = "${HOME}/dotfiles/.config/hypr/env/CURRENT_PAPER" var wallpaper_dir = "${HOME}/Pictures/wallpapers/" var wallvideo_path = "${HOME}/Pictures/wallvideo/ok_geek_eyes_24.mp4" -var mpvpaper_args = "--hwdec=auto-safe --vo=gpu" +var mpvpaper_args = "--hwdec=auto-safe --panscan=1.0" proc get_all(dir) { find "$dir" -maxdepth 1 -type f | sort @@ -92,7 +92,7 @@ proc toggle_video() { notify-send "Failed stop wallvideo" } } else { - if mpvpaper '*' "$wallvideo_path" -o "no-audio loop" --fork --mpv-args="$mpvpaper_args" { + if mpvpaper '*' "$wallvideo_path" -o "no-audio loop" --fork -o "no-audio loop --panscan=1.0" --mpv-args="$mpvpaper_args" { notify-send "Start wallvideo" } else { notify-send "Failed start wallvideo" diff --git a/script/launch-waybar.ysh b/script/launch-waybar.ysh index 75f1a55..760531d 100755 --- a/script/launch-waybar.ysh +++ b/script/launch-waybar.ysh @@ -24,12 +24,12 @@ if test -e "$arg1" { case "$XDG_CURRENT_DESKTOP" in Hyprland) - waybar -c "$BASE/config.hypr.jsonc" -s "$STYLE" & + fork { waybar -c "$BASE/config.hypr.jsonc" -s "$STYLE" } ;; niri) - waybar -c "$BASE/config.niri.jsonc" -s "$STYLE" & + fork { waybar -c "$BASE/config.niri.jsonc" -s "$STYLE" } ;; sway:wlroots) - waybar -c "$BASE/config.sway.jsonc" -s "$STYLE" & + fork { waybar -c "$BASE/config.sway.jsonc" -s "$STYLE" } ;; esac diff --git a/script/tlp-waybar-status.ysh b/script/tlp-waybar-status.ysh index ba90e69..9e356b1 100755 --- a/script/tlp-waybar-status.ysh +++ b/script/tlp-waybar-status.ysh @@ -1,4 +1,6 @@ #!/usr/bin/env ysh +var awk_prog = '{m=$1=="performance"?"PRF":$1=="balanced"?"BAL":$1=="powersave"?"SAV":$1; print NF==2?m"/"$2:m}' + tlp-stat -s | grep -Ei 'Power profile|TLP Profile' | awk '{print $4}' | - awk -F'/' '{m=$1=="performance"?"PRF":$1=="balanced"?"BAL":$1=="powersave"?"SAV":$1; print NF==2?m"/"$2:m}' + awk -F / $awk_prog