From 0d6d830c6db26795568cab8b92320272e1d59768 Mon Sep 17 00:00:00 2001 From: nnduc Date: Mon, 29 Jun 2026 21:25:36 +0700 Subject: [PATCH] up --- .zshrc | 37 ------------------------------- i3/scripts/wallpaper-rotate | 44 +++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 39 deletions(-) delete mode 100644 .zshrc diff --git a/.zshrc b/.zshrc deleted file mode 100644 index 727bb9e..0000000 --- a/.zshrc +++ /dev/null @@ -1,37 +0,0 @@ -# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. -# Initialization code that may require console input (password prompts, [y/n] -# confirmations, etc.) must go above this block; everything else may go below. -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -fi - -HISTFILE=~/.histfile -HISTSIZE=2000 -SAVEHIST=2000 -bindkey -v - -# End of lines configured by zsh-newuser-install -# The following lines were added by compinstall -bindkey "\e[3~" delete-char -autoload -Uz compinit && compinit -zstyle ':completion:*' menu select -# End of lines added by compinstall - - -source /home/nnduc/git/powerlevel10k/powerlevel10k.zsh-theme -source /home/nnduc/git/zsh-autosuggestions/zsh-autosuggestions.zsh - -zshaddhistory() { - whence ${${(z)1}[1]} >/dev/null || return 2 -} - -# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. -[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh - -export EDITOR=nvim -export TERM='xterm-256color' -export PATH="$HOME/.local/bin:$PATH" - -alias ls='ls --color=auto' -alias doc='docker-compose' - diff --git a/i3/scripts/wallpaper-rotate b/i3/scripts/wallpaper-rotate index 938eea9..78a84a1 100755 --- a/i3/scripts/wallpaper-rotate +++ b/i3/scripts/wallpaper-rotate @@ -1,4 +1,44 @@ #!/bin/bash wall_dir="${1:?wallpaper directory required}" -img=$(find "$wall_dir" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | shuf -n1) -[ -n "$img" ] && feh --bg-fill "$img" +interval="${2:-1800}" + +pick_wall() { + find "$wall_dir" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | shuf -n1 +} + +set_wall() { [ -n "$1" ] && xwallpaper --zoom "$1"; } + +has_fullscreen() { + python3 - <<'EOF' +import json, subprocess, sys + +def is_fullscreen(node): + if node.get('fullscreen_mode', 0) > 0: return True + return any(is_fullscreen(c) for c in node.get('nodes', []) + node.get('floating_nodes', [])) + +def find_ws(node, name): + if node.get('type') == 'workspace' and node.get('name') == name: return node + for c in node.get('nodes', []) + node.get('floating_nodes', []): + r = find_ws(c, name) + if r: return r + +try: + wss = json.loads(subprocess.check_output(['i3-msg', '-t', 'get_workspaces'], stderr=subprocess.DEVNULL)) + tree = json.loads(subprocess.check_output(['i3-msg', '-t', 'get_tree'], stderr=subprocess.DEVNULL)) + for ws in wss: + if ws.get('visible'): + node = find_ws(tree, ws['name']) + if node and is_fullscreen(node): + sys.exit(0) +except Exception: + pass +sys.exit(1) +EOF +} + +# Initial wallpaper +set_wall "$(pick_wall)" + +while sleep "$interval"; do + has_fullscreen || set_wall "$(pick_wall)" +done