mirror of
https://github.com/ksyasuda/dotfiles.git
synced 2025-12-10 22:48:00 -08:00
update
This commit is contained in:
@@ -6,8 +6,9 @@ THEME="$HOME/.config/rofi/launchers/type-3/style-4.rasi"
|
|||||||
DIR="$HOME/Pictures/wallpapers/favorites"
|
DIR="$HOME/Pictures/wallpapers/favorites"
|
||||||
SELECTED_WALL=$(cd "$DIR" && for a in *.jpg *.png; do echo -en "$a\0icon\x1f$a\n"; done | rofi -dmenu -i -no-custom -theme "$THEME" -p "Select a wallpaper" -theme-str 'configuration {icon-size: 128; dpi: 96;} window {width: 45%; height: 45%;}')
|
SELECTED_WALL=$(cd "$DIR" && for a in *.jpg *.png; do echo -en "$a\0icon\x1f$a\n"; done | rofi -dmenu -i -no-custom -theme "$THEME" -p "Select a wallpaper" -theme-str 'configuration {icon-size: 128; dpi: 96;} window {width: 45%; height: 45%;}')
|
||||||
PTH="$(printf "%s" "$DIR/$SELECTED_WALL" | tr -s '/')"
|
PTH="$(printf "%s" "$DIR/$SELECTED_WALL" | tr -s '/')"
|
||||||
notify-send -a "rofi-wallpaper" "Wallpaper set to" -i "$PTH" "$PTH"
|
|
||||||
hyprctl hyprpaper preload "$PTH"
|
hyprctl hyprpaper preload "$PTH"
|
||||||
hyprctl hyprpaper wallpaper "DP-1,$PTH"
|
hyprctl hyprpaper wallpaper "$PTH"
|
||||||
hyprctl hyprpaper unload "$(cat "$HOME/.wallpaper")"
|
hyprctl hyprpaper unload "$(cat "$HOME/.wallpaper")"
|
||||||
|
# hyprctl hyprpaper wallpaper "DP-1, $PTH"
|
||||||
|
notify-send -a "rofi-wallpaper" "Wallpaper set to" -i "$PTH" "$PTH"
|
||||||
echo "$PTH" >"$HOME/.wallpaper"
|
echo "$PTH" >"$HOME/.wallpaper"
|
||||||
|
|||||||
@@ -10,7 +10,12 @@ PICTURE_FIELD="${PICTURE_FIELD:-Picture}"
|
|||||||
QUALITY="${QUALITY:-90}"
|
QUALITY="${QUALITY:-90}"
|
||||||
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/screenshot-anki"
|
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/screenshot-anki"
|
||||||
ANKI_URL="http://localhost:${ANKI_CONNECT_PORT}"
|
ANKI_URL="http://localhost:${ANKI_CONNECT_PORT}"
|
||||||
REQUIREMENTS=(slurp grim wl-copy xdotool curl jq)
|
HOSTNAME_SHORT="$(hostname -s 2>/dev/null || hostname)"
|
||||||
|
HYPRLAND_GEOMETRY_FILTER='"\\(.at[0]),\\(.at[1]) \\(.size[0])x\\(.size[1])"'
|
||||||
|
REQUIREMENTS=(slurp grim wl-copy xdotool curl jq rofi)
|
||||||
|
ROFI_THEME_STR='listview {columns: 2; lines: 3;} window {width: 45%;}'
|
||||||
|
ROFI_THEME="$HOME/.config/rofi/launchers/type-2/style-2.rasi"
|
||||||
|
CAPTURE_MODE=""
|
||||||
|
|
||||||
notify() {
|
notify() {
|
||||||
if command -v notify-send >/dev/null 2>&1; then
|
if command -v notify-send >/dev/null 2>&1; then
|
||||||
@@ -31,6 +36,13 @@ wiggle_mouse() {
|
|||||||
xdotool mousemove_relative -- -1 -1
|
xdotool mousemove_relative -- -1 -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drain_enter_key() {
|
||||||
|
# Release lingering Enter press from launching via rofi so it
|
||||||
|
# doesn't reach the next focused window (e.g., a game).
|
||||||
|
xdotool keyup Return 2>/dev/null || true
|
||||||
|
xdotool keyup KP_Enter 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
capture_region() {
|
capture_region() {
|
||||||
local fmt="$1" quality="$2" output="$3"
|
local fmt="$1" quality="$2" output="$3"
|
||||||
local geometry
|
local geometry
|
||||||
@@ -46,6 +58,59 @@ capture_region() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
capture_current_window() {
|
||||||
|
local fmt="$1" quality="$2" output="$3" geometry
|
||||||
|
|
||||||
|
if [[ "$HOSTNAME_SHORT" != "luna" && "$HOSTNAME_SHORT" != "lapis" ]]; then
|
||||||
|
notify "Window capture unavailable" "Falling back to region selection"
|
||||||
|
capture_region "$fmt" "$quality" "$output"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
geometry=$(hyprctl -j activewindow 2>/dev/null | jq -r "$HYPRLAND_GEOMETRY_FILTER" 2>/dev/null || true)
|
||||||
|
if [[ -z "$geometry" || "$geometry" == "null" ]]; then
|
||||||
|
notify "Window capture failed" "Falling back to region selection"
|
||||||
|
capture_region "$fmt" "$quality" "$output"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$fmt" == "jpeg" ]]; then
|
||||||
|
grim -g "$geometry" -t jpeg -q "$quality" "$output"
|
||||||
|
else
|
||||||
|
grim -g "$geometry" -t png "$output"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
choose_capture_mode() {
|
||||||
|
local selection
|
||||||
|
selection=$(printf "%s\n%s\n" "Region (slurp)" "Current window (Hyprland)" |
|
||||||
|
rofi -dmenu -i \
|
||||||
|
-p "Capture mode" \
|
||||||
|
-mesg "Select capture target" \
|
||||||
|
-no-custom \
|
||||||
|
-no-lazy-grab \
|
||||||
|
-location 0 -yoffset 30 -xoffset 30 \
|
||||||
|
-theme "$ROFI_THEME" \
|
||||||
|
-theme-str "$ROFI_THEME_STR" \
|
||||||
|
-window-title "screenshot-anki")
|
||||||
|
|
||||||
|
if [[ -z "$selection" ]]; then
|
||||||
|
notify "Screenshot cancelled" "No capture mode selected"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$selection" == "Current window (Hyprland)" ]]; then
|
||||||
|
if [[ "$HOSTNAME_SHORT" != "luna" && "$HOSTNAME_SHORT" != "lapis" ]]; then
|
||||||
|
notify "Window capture unavailable" "Using region instead (host: $HOSTNAME_SHORT)"
|
||||||
|
CAPTURE_MODE="region"
|
||||||
|
else
|
||||||
|
CAPTURE_MODE="window"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
CAPTURE_MODE="region"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
copy_to_clipboard() {
|
copy_to_clipboard() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
if ! wl-copy <"$file"; then
|
if ! wl-copy <"$file"; then
|
||||||
@@ -81,7 +146,8 @@ open_note_in_browser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
for cmd in "${REQUIREMENTS[@]}"; do
|
local requirements=("${REQUIREMENTS[@]}")
|
||||||
|
for cmd in "${requirements[@]}"; do
|
||||||
require_cmd "$cmd"
|
require_cmd "$cmd"
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -90,19 +156,31 @@ main() {
|
|||||||
timestamp=$(date +%s)
|
timestamp=$(date +%s)
|
||||||
base="$CACHE_DIR/$timestamp"
|
base="$CACHE_DIR/$timestamp"
|
||||||
|
|
||||||
|
drain_enter_key
|
||||||
|
choose_capture_mode
|
||||||
|
|
||||||
|
if [[ "$CAPTURE_MODE" == "window" ]]; then
|
||||||
|
require_cmd hyprctl
|
||||||
|
fi
|
||||||
|
|
||||||
wiggle_mouse
|
wiggle_mouse
|
||||||
newest_note=$(get_newest_note_id)
|
newest_note=$(get_newest_note_id)
|
||||||
|
|
||||||
|
local capture_fn="capture_region"
|
||||||
|
if [[ "$CAPTURE_MODE" == "window" ]]; then
|
||||||
|
capture_fn="capture_current_window"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n "$newest_note" ]]; then
|
if [[ -n "$newest_note" ]]; then
|
||||||
image_path="$base.jpg"
|
image_path="$base.jpg"
|
||||||
capture_region "jpeg" "$QUALITY" "$image_path"
|
"$capture_fn" "jpeg" "$QUALITY" "$image_path"
|
||||||
update_note_with_image "$newest_note" "$image_path" "paste-$timestamp.jpg"
|
update_note_with_image "$newest_note" "$image_path" "paste-$timestamp.jpg"
|
||||||
open_note_in_browser "$newest_note"
|
open_note_in_browser "$newest_note"
|
||||||
notify -i "$image_path" "Screenshot Taken" "Added to Anki note"
|
notify -i "$image_path" "Screenshot Taken" "Added to Anki note"
|
||||||
rm -f "$image_path"
|
rm -f "$image_path"
|
||||||
else
|
else
|
||||||
image_path="$base.png"
|
image_path="$base.png"
|
||||||
capture_region "png" "" "$image_path"
|
"$capture_fn" "png" "" "$image_path"
|
||||||
copy_to_clipboard "$image_path"
|
copy_to_clipboard "$image_path"
|
||||||
notify -i "$image_path" "Screenshot Taken" "Copied to clipboard"
|
notify -i "$image_path" "Screenshot Taken" "Copied to clipboard"
|
||||||
rm -f "$image_path"
|
rm -f "$image_path"
|
||||||
|
|||||||
10
projects/scripts/songinfo.sh
Executable file
10
projects/scripts/songinfo.sh
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
music_dir="/jellyfin/music"
|
||||||
|
previewdir="$XDG_CONFIG_HOME/ncmpcpp/previews"
|
||||||
|
filename="$(mpc --format "$music_dir"/%file% current)"
|
||||||
|
previewname="$previewdir/$(mpc --format %album% current | base64).png"
|
||||||
|
|
||||||
|
[ -e "$previewname" ] || ffmpeg -y -i "$filename" -an -vf scale=128:128 "$previewname" > /dev/null 2>&1
|
||||||
|
|
||||||
|
notify-send -a "ncmpcpp" "Now Playing" "$(mpc --format '%title% \n%artist% - %album%' current)" -i "$previewname"
|
||||||
Reference in New Issue
Block a user