···2222}
23232424# Parse arguments
2525-for flag in "$@"
2525+for flag
2626do
2727 # Make sure flag begins with '-' and are atleast two characters long
2828 case $flag in
···34343535 # Split the flags into individual arguments and set variables
3636 flag=${flag#-}
3737+3738 while [ "$flag" ]
3839 do
3939- a=${flag%${flag#?}}
4040+ a=${flag%"${flag#?}"}
4141+4042 case $a in
4143 c ) copy_to_clipboard=true ;;
4244 h ) usage; exit 0 ;;
···4749 * ) printf '%s\n' "${0##*/}: -$a invalid argument" 1>&2
4850 usage 1>&2; exit 1 ;;
4951 esac
5252+5053 flag=${flag#?}
5154 done
5255done
53565457# Make sure this directory exist before continuing
5555-[ -d "/tmp/${0##*/}" ] || {
5656- mkdir -p "/tmp/${0##*/}" || \
5757- printf '%s\n' "${0##*/}: failed to create directory: /tmp/${0##*/}" 1>&2 \
5858- exit 1
5959-}
5858+[ -d "/tmp/${0##*/}" ] || { mkdir -p "/tmp/${0##*/}" || exit 1; }
60596160# Set color_type if not already set
6261[ $color_type ] || color_type="hex"
···66656766case $color_type in
6867 hex ) color=$(convert "/tmp/${0##*/}/temp.png" -format "%[hex:p]\n" info:) ;;
6969- rgb ) color=$(convert "/tmp/${0##*/}/temp.png" -format "%[pixel:p]\n" info:)
7070- color=${color#*(}; color=${color%)*} ;;
6868+ rgb )
6969+ color=$(convert "/tmp/${0##*/}/temp.png" -format "%[pixel:p]\n" info:)
7070+ color=${color#*(}; color=${color%)*}
7171+ ;;
7172 * ) printf '%s\n' "${0##*/}: invalid color_type: $color_type" 1>&2; exit 1 ;;
7273esac
7374echo "$color"
···8384 [ -f "/tmp/${0##*/}/o$color.png" ] || {
8485 case $color_type in
8586 hex ) ocolor="#$color" ;;
8686- rgb ) ocolor="rgb($color)";;
8787+ rgb ) ocolor="rgb($color)" ;;
8788 esac
8989+8890 convert -size 150x150 xc:"$ocolor" +size -gravity center \
8991 \( -background white pango:"<span font_family=\"monospace\"
9092 font_weight=\"bold\"> $color </span>" \) \
9193 -composite "/tmp/${0##*/}/o$color.png"
9294 }
9595+9396 xdg-open "/tmp/${0##*/}/o$color.png" > "/tmp/${0##*/}/xdg-open.log" 2>&1 &
9497}
9598···98101 [ -f "/tmp/${0##*/}/n$color.png" ] || {
99102 case $color_type in
100103 hex ) ncolor="#$color"; color_prefix="hex:";;
101101- rgb ) ncolor="rgb($color)"
102102- color_r="${color%%,*}"
103103- color_g="${color#*,}"; color_g="${color_g%,*}"
104104- color_b="${color##*,}"
105105- color_rgb="$color_r$color_g$color_b"
106106- color_prefix="rgb:";;
104104+ rgb )
105105+ ncolor="rgb($color)"
106106+ color_r="${color%%,*}"
107107+ color_g="${color#*,}"; color_g="${color_g%,*}"
108108+ color_b="${color##*,}"
109109+ color_rgb="$color_r$color_g$color_b"
110110+ color_prefix="rgb:";;
107111 esac
112112+108113 convert -size 64x64 xc:"$ncolor" "/tmp/${0##*/}/n$color_rgb.png"
109114 }
115115+110116 notify-send -a "${0##*/}" -i "/tmp/${0##*/}/n$color_rgb.png" "$color_prefix $color"
111117}
+6-4
scritps/ds4-leds
···1313 hex_r=${hex%????}
1414 hex_g=${hex#??}; hex_g=${hex_g%??}
1515 hex_b=${hex#????}
1616+1617 printf '%d,%d,%d' "0x$hex_r" "0x$hex_g" "0x$hex_b"
1718}
1819···2526 "$led_path/"*"$vendorid:0BA0"*":global" ) productid="0BA0" ;;
2627 esac
27282828- IFS=, read -r rgb_r rgb_g rgb_b <<-EOF
2929+ IFS=, read -r r g b <<-EOF
2930 $1
3031 EOF
3131- printf '%s' "$rgb_r" | tee "$led_path/"*"$vendorid:$productid"*":red/brightness" > /dev/null
3232- printf '%s' "$rgb_g" | tee "$led_path/"*"$vendorid:$productid"*":green/brightness" > /dev/null
3333- printf '%s' "$rgb_b" | tee "$led_path/"*"$vendorid:$productid"*":blue/brightness" > /dev/null
3232+3333+ printf '%s' "$r" | tee "$led_path/"*"$vendorid:$productid"*":red/brightness" > /dev/null
3434+ printf '%s' "$g" | tee "$led_path/"*"$vendorid:$productid"*":green/brightness" > /dev/null
3535+ printf '%s' "$b" | tee "$led_path/"*"$vendorid:$productid"*":blue/brightness" > /dev/null
3436}
35373638case $1 in
+40-25
scritps/prefon
···3333 w ) prefix=WARNING ;;
3434 e ) prefix=ERROR ;;
3535 * ) printf '%s\n' "sus!" 1>&2; exit 1 ;;
3636- esac
3737- shift
3636+ esac; shift
38373938 printf "${0##*/}: $prefix: %b\n" "$*" 1>&2
4039}
···5857 -* ) flag=${1#-}; shift ;;
5958 * ) shift; continue ;;
6059 esac
6060+6161 while [ "$flag" ]
6262 do
6363 arg=${flag%${flag#?}}
6464+6465 case $arg in
6566 F ) PREFON_ACTION="file"; PREFON_FILE=$1; shift ;;
6667 S ) PREFON_ACTION=stdin; PREFON_FILE=/dev/stdin ;;
···7273 o ) PREFON_OUTPUT=$1; shift ;;
7374 s ) PREFON_SIZE=$1; shift ;;
7475 t ) PREFON_ACTION=text; PREFON_TEXT=$1; shift ;;
7575- * ) printf '%s\n' "${0##*/}: -$arg: invalid argument" 1>&2; usage 1>&2; exit 1 ;;
7676+ * ) printf '%s\n' "${0##*/}: -$arg: invalid argument" 1>&2
7777+ usage 1>&2; exit 1 ;;
7678 esac
7979+7780 flag=${flag#?}
7881 done
7982done
80838181-generate_image() {
8282- _gen_img() {
8383- convert -background "#$2" -bordercolor "#$2" -border "$PREFON_BORDER_SIZE" \
8484- pango:"<span foreground=\"#$1\" font_desc=\"$PREFON_FONT $PREFON_SIZE\">$4</span>" "$3"
8585- }
8484+_gen_img() {
8585+ convert -background "#$2" -bordercolor "#$2" -border "$PREFON_BORDER_SIZE" \
8686+ pango:"<span foreground=\"#$1\" font_desc=\"$PREFON_FONT $PREFON_SIZE\">$4</span>" "$3"
8787+}
8888+8989+_output_file() {
9090+ while IFS= read -r line
9191+ do printf '%s\n' "$line"
9292+ done < "$PREFON_FILE"
9393+}
86949595+generate_image() {
8796 fgcolor=${PREFON_COLORS%,*}
8897 bgcolor=${PREFON_COLORS#*,}
89989090- _gen_img "$fgcolor" "$bgcolor" "$PREFON_OUTPUT" "$1" || { info e failed to generate image; exit 1; }
9999+ _gen_img "$fgcolor" "$bgcolor" "$PREFON_OUTPUT" "$1" || {
100100+ info e failed to generate image
101101+ exit 1
102102+ }
9110392104 [ "$PREFON_INVERSE" != "none" ] && {
93105 inverse="${PREFON_OUTPUT%.*}"
94106 inverse="${inverse}-inverse.${PREFON_OUTPUT##*.}"
951079696- _gen_img "$bgcolor" "$fgcolor" "$inverse" "$1" || { info e failed to generate image; exit 1; }
108108+ _gen_img "$bgcolor" "$fgcolor" "$inverse" "$1" || {
109109+ info e failed to generate image
110110+ exit 1
111111+ }
9711298113 case $PREFON_INVERSE in
99114 horizontal ) convert "$PREFON_OUTPUT" "$inverse" +append "$PREFON_OUTPUT" \
100115 || { info e failed to generate image; exit 1; } ;;
101116 vertical ) convert "$PREFON_OUTPUT" "$inverse" -append "$PREFON_OUTPUT" \
102117 || { info e failed to generate image; exit 1; } ;;
103103- * ) info e "${PREFON_INVERSE}: is not a valid value for PREFON_INVERSE"; exit 1 ;;
118118+ * ) info e "${PREFON_INVERSE}: is not a valid value for PREFON_INVERSE"
119119+ exit 1 ;;
104120 esac
105121106122 rm "$inverse" || info w failed to remove temporary file: "${inverse}"
···110126}
111127112128read_input() {
113113- _output_file() {
114114- while IFS= read -r line
115115- do
116116- printf '%s\n' "$line"
117117- done < "$PREFON_FILE"
118118- }
119119-120129 input="$(_output_file)"
121130 generate_image "$input"
122131}
123132124133case $PREFON_ACTION in
125125- file ) [ -e "$PREFON_FILE" ] || { info e "'$PREFON_FILE' does not exist"; exit 1; }
126126- read_input ;;
127127- stdin ) [ -e /dev/stdin ] || { info e "/dev/stdin does not exist"; exit 1; }
128128- read_input ;;
129129- text ) [ "$PREFON_TEXT" ] || { info e "string not provided"; exit 1; }
130130- generate_image "$PREFON_TEXT" ;;
131131- * ) info e invalid action: $PREFON_ACTION; exit 1 ;;
134134+ file )
135135+ [ -e "$PREFON_FILE" ] || { info e "'$PREFON_FILE' does not exist"; exit 1; }
136136+ read_input
137137+ ;;
138138+ stdin )
139139+ [ -e /dev/stdin ] || { info e "/dev/stdin does not exist"; exit 1; }
140140+ read_input
141141+ ;;
142142+ text )
143143+ [ "$PREFON_TEXT" ] || { info e "string not provided"; exit 1; }
144144+ generate_image "$PREFON_TEXT"
145145+ ;;
146146+ * ) info e invalid action: $PREFON_ACTION; exit 1 ;;
132147esac
+3
scritps/scr
···69697070 # Split arguments to be 1 character long and determine options to use
7171 args=${flag#-}
7272+7273 while [ "$args" ]
7374 do
7475 a=${args%${args#?}}
7676+7577 case $a in
7678 a ) desktop_audio=true ;;
7779 c ) copy_clipboard=true ;;
···8486 * ) printf '%s\n' "${0##*/}: -$a: invalid argument" 1>&2
8587 usage 1>&2; exit 1 ;;
8688 esac
8989+8790 args=${args#?}
8891 done
8992done
+4-3
scritps/thm
···1212 hex_r=${hex%????}
1313 hex_g=${hex#??}; hex_g=${hex_g%??}
1414 hex_b=${hex#????}
1515+1516 printf '%d,%d,%d' "0x$hex_r" "0x$hex_g" "0x$hex_b"
1617}
1718···1920[ "$THM_CONFIG_DIR" ] \
2021 && conf_dir="$THM_CONFIG_DIR" \
2122 || conf_dir="${XDG_CONFIG_HOME:-$HOME/.config}/thm"
2323+2224[ "$THM_DEST_DIR" ] \
2325 && dest_dir="$THM_DEST_DIR" \
2426 || dest_dir="${XDG_CACHE_HOME:-$HOME/.cache}/thm"
···5961color15_rgb="$(hex2rgb "$color15")"
60626163# Make sure the dest_dir and dest_dir/thm_old exist
6262-[ -d "$dest_dir/thm_old" ] || { mkdir -p "$dest_dir/thm_old" || err "failed to create $dest_dir/thm_old"; }
6464+[ -d "$dest_dir/thm_old" ] || mkdir -p "$dest_dir/thm_old"
63656466# Try and empty the dest_dir before populating it
6567mv "$dest_dir/"* "$dest_dir/thm_old" 2> /dev/null
···168170# Run extra user scripts
169171[ -d "$conf_dir/scripts" ] || exit 0
170172for i in "$conf_dir/scripts/"*
171171-do
172172- [ -x "$i" ] && $i > /dev/null 2>&1 &
173173+do [ -x "$i" ] && $i > /dev/null 2>&1 &
173174done