# Just use this handmade script:
#!/bin/zsh
# Path to the workspace names configuration file
config_file="$HOME/.dotfiles/dconf/.config/workspace_names.conf"
# Function to create the config file with default values if it doesn't exist
create_default_config() {
if [ ! -f "$config_file" ]; then
echo "Creating default configuration file..."
echo 'workspace-1="Work"' > "$config_file"
echo 'workspace-2="Personal"' >> "$config_file"
fi
}
# Function to display workspace names
display_workspace_names() {
while read -r line; do
echo "$line"
done < "$config_file"
}
# Function to prompt for workspace choice
prompt_workspace_choice() {
echo -n "Enter the workspace number ('q' to quit): "
read workspace_number
}
# Function to prompt for workspace name and save it
prompt_and_save_workspace_name() {
echo -n "Enter the workspace name: "
read workspace_name
# Save the workspace name to the configuration file
sed -i "${workspace_number}s/.*/workspace-${workspace_number}=\"${workspace_name}\"/" "$config_file"
}
# Function to add default workspaces up to the chosen workspace
add_default_workspaces() {
for ((i=1; i<workspace_number; i++)); do
if ! grep -q "workspace-${i}=" "$config_file"; then
echo "Adding default workspace for ${i}"
echo "workspace-${i}=\"Workspace ${i}\"" >> "$config_file"
fi
done
}
# Main loop
create_default_config
while true; do
echo "Available workspaces:"
display_workspace_names
prompt_workspace_choice
# Check if the user wants to quit
if [[ "$workspace_number" == "q" ]]; then
echo "Exiting..."
exit 0
fi
# Check if the provided input is a new workspace number
if [[ ! "$workspace_number" =~ ^[0-9]+$ ]]; then
echo "Invalid input. Please enter a valid workspace number or 'q' to quit."
continue
fi
# Add default workspaces up to the chosen workspace
add_default_workspaces
# Check if workspace number exists
if ! grep -q "workspace-${workspace_number}=" "$config_file"; then
echo "Adding default workspace for ${workspace_number}"
echo "workspace-${workspace_number}=\"Workspace ${workspace_number}\"" >> "$config_file"
fi
prompt_and_save_workspace_name
# Set workspace names using gsettings
new_workspace_names=$(awk -F'"' '{ printf("%s\"%s\"", sep, $2); sep=", " }' "$config_file")
gsettings set org.gnome.desktop.wm.preferences workspace-names "[$new_workspace_names]"
echo "Workspace name updated successfully!"
done