diff --git a/config/rofi/bin/browsermenu b/config/rofi/bin/browsermenu
new file mode 100755
index 00000000..c822af72
--- /dev/null
+++ b/config/rofi/bin/browsermenu
@@ -0,0 +1,60 @@
+#!/usr/bin/env sh
+
+# Interactively select (in skim) an url from Firefox/Chrome/Chromium history to
+# open in your browser (depends on $BROWSER). Should work on Linux and MacOS.
+#
+# requires: sqlite3
+
+ROFI_CMD='rofi -dmenu -theme theme/browsermenu.rasi -columns 1 -markup-rows -multi-select -p browser -i'
+SEP=${1:-'{{::}}'}
+
+_do_rofi() {
+ urls=$(awk -F "$SEP" '{printf "%s: %s\n", $1, $2}' | $ROFI_CMD | sed -e 's#&#g' -e 's#<#<#g' -e 's#>#>#g')
+ IFS=$'\n'
+ for url in $urls; do
+ url=${url%*}
+ url=${url##*}
+ echo $url
+ done | xargs $BROWSER
+}
+
+case ${BROWSER:-firefox} in
+ firefox)
+ for dir in ~/.mozilla/firefox/*.default \
+ $XDG_CONFIG_HOME/firefox/.mozilla/firefox/*.default \
+ $XDG_DATA_HOME/mozilla/firefox/*.default \
+ ~/Library/Application\ Support/Firefox/Profiles/*.default; do
+ if [[ -d "$dir" ]]; then
+ # The db can be locked from time to time. This is inefficient, but
+ # places.sqlite is usually under 30mb so this should be instant, and
+ # /tmp is cleared at boot so...
+ # if ! find /tmp/rofi-browsermenu -mmin +60 2>&1 >/dev/null; then
+ cp "$dir/places.sqlite" "/tmp/places.sqlite"
+ sqlite3 -separator $SEP "/tmp/places.sqlite" \
+ "SELECT DISTINCT title, url FROM moz_places \
+ WHERE title IS NOT NULL \
+ ORDER BY last_visit_date DESC" >/tmp/rofi-browsermenu
+ sqlite3 -separator $SEP "/tmp/places.sqlite" \
+ "SELECT DISTINCT mb.title, mp.url FROM moz_bookmarks mb \
+ INNER JOIN moz_places mp ON mp.id = mb.fk \
+ WHERE mb.type = 1 AND mb.title IS NOT NULL \
+ ORDER BY mp.frecency DESC \
+ LIMIT 200" >>/tmp/rofi-browsermenu
+ # fi
+ cat /tmp/rofi-browsermenu | sed -e 's#&#g' -e 's#<#<#g' -e 's#>#>#g' | _do_rofi
+ break
+ fi
+ done
+ ;;
+ qutebrowser)
+ {
+ sed -e 's/ /{{::}}/' urls | awk -F'{{::}}' '{printf "%s{{::}}%s\n", $2, $1}'
+ sqlite3 -separator $SEP "$XDG_DATA_HOME/qutebrowser/history.sqlite" \
+ "SELECT title, url FROM History \
+ WHERE title != '' \
+ GROUP BY url \
+ ORDER BY atime DESC"
+ } | _do_rofi
+ ;;
+ *) rofi -e "No known browser" ;;
+esac
diff --git a/modules/desktop/rofi.nix b/modules/desktop/rofi.nix
index 0d6ed62a..354bc0ef 100644
--- a/modules/desktop/rofi.nix
+++ b/modules/desktop/rofi.nix
@@ -5,9 +5,17 @@
systemPackages = with pkgs; [
(writeScriptBin "rofi" ''
#!${stdenv.shell}
- exec ${rofi}/bin/rofi -terminal xst -m -1 $@
+ exec ${rofi}/bin/rofi -terminal xst -m -1 "$@"
'')
rofi
+
+ (makeDesktopItem {
+ name = "browsermenu";
+ desktopName = "Open Bookmark in Firefox";
+ icon = "firefox";
+ exec = "/home/hlissner/.config/rofi/bin/browsermenu";
+ categories = "Network";
+ })
];
# shellAliases = {};
diff --git a/themes/glimpse/rofi/browsermenu.rasi b/themes/glimpse/rofi/browsermenu.rasi
new file mode 100644
index 00000000..50c33b8c
--- /dev/null
+++ b/themes/glimpse/rofi/browsermenu.rasi
@@ -0,0 +1,16 @@
+/* -*- mode: css; -*- */
+
+@import "appmenu.rasi"
+
+#prompt {
+ background-color: #a9a1e1;
+}
+
+#entry {
+ text-color: #a9a1e1;
+}
+
+#element.selected {
+ text-color: #a9a1e1;
+ border-color: #a9a1e1;
+}