/* to show active config: `rofi -dump-config`
 * to show keybindings: `rofi -show keys`
 * to show theme config: `rofi -dump-theme`
 * - for live theme switching: `rofi-theme-selector`
 *
 * to see <span ...> markup: <https://docs.gtk.org/Pango/pango_markup.html>
 */

configuration {
  modes: "combi";
  font: "sans 19";
  show-icons: true;
  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; */

  combi {
    /* this is rendered in the filter box, here we disable it */
    display-name: "";
  }
  /* combi-display-format: "{mode} {text}"; */
  /* combi-display-format: "{text}"; */
  /* HACK: combi-display-format: "{mode}...</span>" expects `{mode}` to include <span>, allowing each mode to use custom styling */
  combi-display-format: "{mode}{text}</span>";
  combi-modes: "filebrowser,drun";

  drun {
    display-name: "<span>";
    /* icons in /run/current-system/sw/share/icons/Adwaita/16x16/mimetypes */
    fallback-icon: "application-x-executable";
  }
  drun-use-desktop-cache: true;

  filebrowser {
    /* directory: filebrowser starting directory. leave unset to start at the last directory. */
    /* directory: "/home"; */

    /* display-name: text to prepend in combi mode */
    display-name: "<span stretch='semicondensed' size='90%'>";
    /* `command` is the prefix to prepend (along with a space) *before* passing it off to `run-command` */
    command: "xdg-open";
    directories-first: true;
    /* sorting-method: name/atime/ctime/mtime */
    sorting-method: "name";
    show-hidden: false;
    fallback-icon: "application-x-generic";
  }

  run {
    display-name: "run ";
    fallback-icon: "application-x-executable";
  }
  /* launch applications via my own launcher, which directs them through to xdg-desktop-portal */
  run-command: "rofi-run-command '{app_id}.desktop' {cmd}";
  run-shell-command: "rofi-run-command '{app_id}.desktop' {cmd}";
}

/* theme */
* {
  /* my own variables */
  bg: #1d1721;       /* slight purple */
  fg0: #d8d8d8;      /* inactive text (light grey) */
  fg1: #ffffff;      /* active text (white) */
  accent0: #1f5e54;  /* darker but saturated teal */
  accent1: #418379;  /* teal (matches nixos-bg) */
  accent2: #5b938a;  /* brighter but muted teal */

  /* map my variables to variables rofi uses internally */
  background-color: var(accent0);
  background: var(accent0);
  /* foreground: non-alternating text, scrollbar, borders, separators */
  foreground: var(fg0);

  /* override derived styles */
  alternate-active-background: var(accent0);
  alternate-normal-background: var(accent0);
  alternate-active-foreground: var(fg0);
  alternate-normal-foreground: var(fg0);
  border-color: var(accent0);
  text-color: var(fg0);
  selected-active-background: var(accent1);
  selected-normal-background: var(accent1);
  selected-active-foreground: var(fg1);
  selected-normal-foreground: var(fg1);
  separatorcolor: var(accent1);
}
entry {
  placeholder: "";
  text-color: var(fg1);
}
num-rows, num-filtered-rows {
  text-color: var(fg0);
}
prompt, textbox-prompt-colon {
  /* hide */
  text-color: var(accent0);
}
scrollbar {
  handle-color: var(accent2);
}
window {
  /* rofi supports very complex calculations here */
  /* one may even read environment variables (useful for knowing if screen is rotated?) */
  /* `calc(... min 100%)` ensures it never overflows */
  /* rofi is aware of the top bar (waybar) and any virtual keyboards,
   * so e.g. height: 100% will occupy 100% of the height *not* allocated to bars/kbds.
   * however with y-offset, it becomes possible to overflow */

  width: calc(960 min 100%);
  /* 520px @ font size 20 gives 13 rows + filter */
  /* 482px @ font size 20 gives 12 rows + filter */
  /* 446px @ font size 20 gives 11 rows + filter */
  /* 90.5% @ font size 20, sway scale 2.0, moby in landscape mode: gives 7 rows + filter */
  /* 94% @ font size 19, sway scale 2.0, moby in landscape mode: gives 7 rows + filter */
  /* 465 @ font size 19, sway scale 2.0 gives 11 rows + filter */
  /* 427 @ font size 19, sway scale 2.0 gives 10 rows + filter */
  height: calc(429 min 94.0%);

  /* anchor the *north* edge of the window at the *north* location of the screen */
  anchor: north;
  location: north;
  /* 8.2% lines up nicely with Firefox */
  y-offset: 8.2%;

  /* padding: top right bottom left */
  padding: 4px 0px 1px 0px;
}
element {
  border: 0;
  margin: 0.5px;
  /* padding: top right bottom left */
  padding: 0 0 0 4px;
  spacing: 6px;  /* spacing between icon and text */
}
element-icon {
  size: 0.8em;
}
