{"id":5699,"date":"2020-02-29T12:03:24","date_gmt":"2020-02-29T12:03:24","guid":{"rendered":"https:\/\/really.zonky.org\/?p=5699"},"modified":"2020-02-29T12:04:11","modified_gmt":"2020-02-29T12:04:11","slug":"messing-with-rofi-inserting-unicode","status":"publish","type":"post","link":"https:\/\/really.zonky.org\/?p=5699","title":{"rendered":"Messing With Rofi: Inserting Unicode"},"content":{"rendered":"\n<p>I used to be able to remember all of the keyboard short-cuts I&#8217;d set up to insert &#8216;fun&#8217; (or useful) Unicode characters \u2026 but my memory isn&#8217;t quite what it used to be, and I happened to catch a video that mentioned a menu to insert Unicode characters.<\/p>\n<p>So I set out to create my own \u2026<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/zsh\n#\n# Run a menu of Unicode characters to put into the clipboard\n\nread -r -d '' menu &lt;&lt; END\n\u00de       Thorn (Sym-t)\n\u00de\tCapital thorn (Sym-T)\n\u2713\tTick (Sym-y)\n\u2714       Alternate tick (Sym-Y)\n\u03c0\tpi (Sym-p)\n\u03a0       PI (Sym-P)\n\u2605       Star\n\ud83d\udd95      Finger\nEND\n\nselectedchar=$(echo $menu |\\\n  rofi -dmenu -l 20 -fn misc-24 -p \"Unicode inserter\" |\\\n  awk '{print $1}')\nif &#91; -z \"$selectedchar\" ]\nthen\n  notify-send \"Unicode Inserter\" \"Cancelled\"\nelse\n  printf \"%s\" $selectedchar | xclip -selection clipboard\n  notify-send \"Unicode Inserter\" \\\n    \"Character $selectedchar now in clipboard\"\nfi<\/code><\/pre>\n\n\n\n<p>This script :-<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Creates a variable with a whole pile of text inside it. The original script contains a lot longer list, but including it would be a) boring and b) give too much away. As it stands, the format of each line is pretty much anything you want as long as the first character is the Unicode character followed by whitespace.<\/li><li>Runs <em>rofi<\/em> with the variable as input and selects the first field of the response.<\/li><li>Guards against the empty selection (when the menu was cancelled) for neatness mostly.<\/li><li>Prints the selected character (without a newline) into <em>xclip<\/em> so it can be pasted in. I did try using <em>xdotool<\/em> to type it directly into the active window, but this didn&#8217;t always work so well (i.e. <em>xdotool<\/em> couldn&#8217;t &#8220;type&#8221; some of the more esoteric characters).<\/li><li>And uses <em>notify-send<\/em> to alert the dumb user (me!) that something has happened.<\/li><\/ol>\n\n\n\n<p>Lastly, to make this useful, I added an entry to my <em>sxhkd<\/em> configuration :-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>super + F11\n  \/site\/scripts\/m-unicode-insert<\/code><\/pre>\n\n\n","protected":false},"excerpt":{"rendered":"<p>This script :- Creates a variable with a whole pile of text inside it. The original script contains a lot longer list, but including it would be a) boring and b) give too much away. As it stands, the format of each line is pretty much anything you want as long as the first character <a href='https:\/\/really.zonky.org\/?p=5699' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_share_on_mastodon":"0"},"categories":[4,209,226],"tags":[1915,1914,862],"class_list":["post-5699","post","type-post","status-publish","format-standard","hentry","category-it","category-linux-it","category-working-notes","tag-rofi","tag-sxhkd","tag-unicode","category-4-id","category-209-id","category-226-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"share_on_mastodon":{"url":"","error":""},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1f2KI-1tV","_links":{"self":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/5699","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5699"}],"version-history":[{"count":4,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/5699\/revisions"}],"predecessor-version":[{"id":5703,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/5699\/revisions\/5703"}],"wp:attachment":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}