A collection of scripts

avoid using rm and small fixes

yemou 33d6bbe9 8a580e2a

Changed files
+7 -8
thm
+7 -8
thm
··· 10 hex2rgb() { 11 hex=$1 12 hex_r=${hex%????} 13 - hex_g=${hex#??} 14 - hex_g=${hex_g%??} 15 hex_b=${hex#????} 16 printf '%d,%d,%d' "0x$hex_r" "0x$hex_g" "0x$hex_b" 17 } ··· 21 && conf_dir="$THM_CONFIG_DIR" \ 22 || conf_dir="${XDG_CONFIG_HOME:-$HOME/.config}/thm" 23 [ "$THM_DEST_DIR" ] \ 24 - && conf_dir="$THM_DEST_DIR" \ 25 || dest_dir="${XDG_CACHE_HOME:-$HOME/.cache}/thm" 26 27 err() { ··· 59 color14_rgb="$(hex2rgb "$color14")" 60 color15_rgb="$(hex2rgb "$color15")" 61 62 - # Make sure the dest_dir exist 63 - [ -d "$dest_dir" ] || { mkdir -p "$dest_dir" || err "failed to create $dest_dir"; } 64 65 - # Ensure the dest_dir is empty before populating it 66 - rm "$dest_dir/"* 67 68 # Make a file with the name of the new theme 69 printf '%s\n' "$theme_file" > "$dest_dir/current_thm" ··· 115 done 116 117 # Run extra user scripts 118 - [ -d "$conf_dir/scripts" ] || return 0 119 for i in "$conf_dir/scripts/"* 120 do 121 [ -x "$i" ] && $i > /dev/null 2>&1 &
··· 10 hex2rgb() { 11 hex=$1 12 hex_r=${hex%????} 13 + hex_g=${hex#??}; hex_g=${hex_g%??} 14 hex_b=${hex#????} 15 printf '%d,%d,%d' "0x$hex_r" "0x$hex_g" "0x$hex_b" 16 } ··· 20 && conf_dir="$THM_CONFIG_DIR" \ 21 || conf_dir="${XDG_CONFIG_HOME:-$HOME/.config}/thm" 22 [ "$THM_DEST_DIR" ] \ 23 + && dest_dir="$THM_DEST_DIR" \ 24 || dest_dir="${XDG_CACHE_HOME:-$HOME/.cache}/thm" 25 26 err() { ··· 58 color14_rgb="$(hex2rgb "$color14")" 59 color15_rgb="$(hex2rgb "$color15")" 60 61 + # Make sure the dest_dir and dest_dir/thm_old exist 62 + [ -d "$dest_dir/thm_old" ] || { mkdir -p "$dest_dir/thm_old" || err "failed to create $dest_dir/thm_old"; } 63 64 + # Try and empty the dest_dir before populating it 65 + mv "$dest_dir/"* "$dest_dir/thm_old" 2> /dev/null 66 67 # Make a file with the name of the new theme 68 printf '%s\n' "$theme_file" > "$dest_dir/current_thm" ··· 114 done 115 116 # Run extra user scripts 117 + [ -d "$conf_dir/scripts" ] || exit 0 118 for i in "$conf_dir/scripts/"* 119 do 120 [ -x "$i" ] && $i > /dev/null 2>&1 &