Skip to content

Commit fdb467e

Browse files
committed
feat (workflow): Added icons for workflow names
1 parent 94909a6 commit fdb467e

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

β€ŽConfigs/.local/lib/hyde/workflows.shβ€Ž

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,20 @@ fi
5454

5555
# Functions
5656
fn_select() {
57-
workflow_items=$(find "$workflows_dir" -name "*.conf" ! -name "default.conf" 2>/dev/null | sed 's/\.conf$//')
57+
# Get default workflow icon
58+
default_icon=$(get_hyprConf "WORKFLOW_ICON" "${workflows_dir}/default.conf")
59+
default_icon=${default_icon:0:1}
60+
61+
# Find workflows and get icons in one pass
62+
workflow_list="${default_icon}\t default"
63+
while IFS= read -r workflow_path; do
64+
# Sanitize workflow name by removing any leading/trailing whitespace
65+
workflow_name=$(basename "$workflow_path" .conf | xargs)
66+
[ "$workflow_name" = "default" ] && continue
67+
workflow_icon=$(get_hyprConf "WORKFLOW_ICON" "$workflow_path")
68+
workflow_icon=${workflow_icon:0:1}
69+
workflow_list="${workflow_list}\n${workflow_icon}\t ${workflow_name}"
70+
done < <(find "$workflows_dir" -type f -name "*.conf" 2>/dev/null)
5871

5972
# Set rofi scaling
6073
font_scale="${ROFI_WORKFLOW_SCALE}"
@@ -75,15 +88,13 @@ fn_select() {
7588
hypr_width=${hypr_width:-"$(hyprctl -j getoption general:border_size | jq '.int')"}
7689
r_override="window{border:${hypr_width}px;border-radius:${wind_border}px;} wallbox{border-radius:${elem_border}px;} element{border-radius:${elem_border}px;}"
7790

78-
workflow_items="default
79-
$workflow_items"
8091
rofi_select="${HYPR_WORKFLOW/default/default}"
8192

8293
# Display options using Rofi with custom scaling, positioning, and placeholder
83-
selected_workflow=$(awk -F/ '{print $NF}' <<<"$workflow_items" |
94+
selected_workflow=$(echo -e "${workflow_list}" |
8495
rofi -dmenu -i -select "$rofi_select" \
8596
-p "Select workflow" \
86-
-theme-str "entry { placeholder: \"Select workflow...\"; }" \
97+
-theme-str "entry { placeholder: \"πŸ’Ό Select workflow...\"; }" \
8798
-theme-str "${font_override}" \
8899
-theme-str "${r_override}" \
89100
-theme-str "$(get_rofi_pos)" \
@@ -93,16 +104,11 @@ $workflow_items"
93104
if [ -z "$selected_workflow" ]; then
94105
exit 0
95106
fi
96-
case $selected_workflow in
97-
"default")
98-
selected_workflow="default"
99-
;;
100-
esac
101107

108+
# Extract the workflow name (remove the icon and tab)
109+
selected_workflow=$(awk -F'\t' '{print $2}' <<<"${selected_workflow}" | xargs)
102110
set_conf "HYPR_WORKFLOW" "$selected_workflow"
103111
fn_update
104-
# Notify the user
105-
notify-send -i "preferences-desktop-display" "Workflow:" "$selected_workflow"
106112
}
107113

108114
get_info() {
@@ -120,7 +126,6 @@ get_info() {
120126

121127
fn_update() {
122128
get_info
123-
echo "$current_icon $current_workflow: $current_description"
124129
cat <<EOF >"${confDir}/hypr/workflows.conf"
125130
#! β–ˆβ–‘β–ˆβ–‘β–ˆβ€ƒβ–ˆβ–€β–ˆβ€ƒβ–ˆβ–€β–ˆβ€ƒβ–ˆβ–„β–€β€ƒβ–ˆβ–€β–€β€ƒβ–ˆβ–‘β–‘β€ƒβ–ˆβ–€β–ˆβ€ƒβ–ˆβ–‘β–ˆβ–‘β–ˆβ€ƒβ–ˆβ–€
126131
#! β–€β–„β–€β–„β–€β€ƒβ–ˆβ–„β–ˆβ€ƒβ–ˆβ–€β–„β€ƒβ–ˆβ–‘β–ˆβ€ƒβ–ˆβ–€β–‘β€ƒβ–ˆβ–„β–„β€ƒβ–ˆβ–„β–ˆβ€ƒβ–€β–„β–€β–„β–€β€ƒβ–„β–ˆ
@@ -142,6 +147,10 @@ fn_update() {
142147
source = \$WORKFLOWS_PATH
143148
144149
EOF
150+
151+
printf "%s %s: %s\n" "$current_icon" "$current_workflow" "$current_description"
152+
notify-send -r 9 -i "preferences-desktop-display" "Workflow: ${current_icon} $current_workflow" "${current_description}"
153+
145154
}
146155

147156
handle_waybar() {
@@ -152,14 +161,18 @@ handle_waybar() {
152161

153162
echo "{\"text\": \"${text}\", \"tooltip\": \"${tooltip}\", \"class\": \"${class}\"}"
154163

155-
pkill -RTMIN+7 waybar
156164
}
157165

158166
# Process options
159167
while true; do
160168
case "$1" in
161169
-S | --select)
162170
fn_select
171+
# refresh waybar module only if waybar is running
172+
if pgrep -x waybar >/dev/null; then
173+
pkill -RTMIN+7 waybar
174+
fi
175+
163176
exit 0
164177
;;
165178
--help | -h)

0 commit comments

Comments
Β (0)