#!/bin/bash mapfile -t allLines < $HOME/.config/sxhkd/sxhkdrc jsonstr="[" for ((i = 0; i < ${#allLines[@]}; ++i)); do if [[ ${allLines[$i]} =~ ^#.* ]]; then shortcut="${allLines[$i]:1}: ${allLines[$(( $i + 1 ))]}" if (( $i > 0 )); then jsonstr+="," fi jsonstr+="{" jsonstr+=\""name"\"":" jsonstr+=\""${shortcut}"\" jsonstr+=","\""command"\"":""\""\" jsonstr+="}" fi done jsonstr+="]" echo $jsonstr > /tmp/sxhkdrc.json rofi -modi " Hotkeys":"~/.config/rofi/helper/rofi-json.sh /tmp/sxhkdrc.json" -show " Hotkeys" -theme $HOME/.config/rofi/config.rasi