rofi: remember the last selected directory

This commit is contained in:
Colin 2024-03-02 00:32:43 +00:00
parent a7ef9fc0b8
commit f4ec09f010
3 changed files with 12 additions and 6 deletions

View File

@ -11,6 +11,7 @@ configuration {
kb-accept-entry: "Return,KP_Enter,XF86PowerOff";
kb-row-up: "Up,XF86AudioRaiseVolume";
kb-row-down: "Down,XF86AudioLowerVolume";
cache-dir: "~/.cache/rofi";
/* to position rofi to the top of the screen: */
/* location: 2; */
@ -31,7 +32,8 @@ configuration {
filebrowser {
/* directory: filebrowser starting directory. leave unset to start at the last directory. */
directory: "/home";
/* directory: "/home"; */
/* display-name: text to prepend in combi mode */
display-name: "/";
/* `command` is the prefix to prepend (along with a space) *before* passing it off to `run-command` */

View File

@ -97,12 +97,10 @@ in
];
fs.".config/rofi/config.rasi".symlink.target = ./config.rasi;
# redirect its default drun cache location
fs.".cache/rofi3.druncache".symlink.target = "rofi/rofi3.druncache";
fs.".cache/rofi3.filebrowsercache".symlink.target = "rofi/rofi3.filebrowsercache";
fs.".cache/rofi-drun-desktop.cache".symlink.target = "rofi/rofi-drun-desktop.cache";
persist.byStore.cryptClearOnBoot = [
# optional, for caching .desktop files rofi finds on disk (perf)
# this gets us a few things:
# - file browser remembers its last directory
# - caching of .desktop files (perf)
".cache/rofi"
];
};

View File

@ -14,6 +14,12 @@ shift
binArgs=("$@")
if [ "$desktop" != .desktop ]; then
# launching an app; the file browser position is no longer interesting: clear it so it opens in ~ next time.
# better UX would be to manage this in the other branch:
# - open in ~ by default, regardless of last directory
# - after launching a *file*, when that file is closed, re-open rofi in that file's directory.
# however, `xdg-open` and the `OpenFile` xdg-desktop-portal API don't give any obvious way to block for the app to close.
rm -f ~/.cache/rofi/rofi3.filebrowsercache
exec sane-open-desktop "$desktop"
elif [ "$binary" = "xdg-open" ]; then
exec xdg-open "$@"