Skip to content

Passing Rofi options on initialize? #4

@paulalden

Description

@paulalden

Hello, I just found your Gem and i'm in the progress of converting my shell scripts to ruby scripts to control Rofi. I was wondering if you would accept a PR to allow users to pass rofi options on initalize?

I was thinking something like this:

require "fuzz"
require "debug"

module Fuzz
  class RofiPicker
    def initialize(args = {})
      @args = { "show" => "run", "matching" => "fuzzy", "dmenu" => "", "i" => "" }.merge(args)
    end

    def pick(keys)
      Fuzz::Executable.new("rofi").error_if_missing

      `echo "#{ keys.join("\n") }" | #{ command }`.strip
    end

    private

    def command
      "rofi #{string_args}"
    end

    def string_args
      @args.map { |k,v| "-#{k} #{v}" }.join(" ")
    end
  end
end

args = {
  "theme" => "~/.config/rofi/my-custom-theme.rasi"
}
selector = Fuzz::Selector.new(options, picker: Fuzz::RofiPicker.new(args))

It could be make to set -show run -matching fuzzy -dmenu -i as defaults within the instance options to clean it up a little bit more.

Looking forward to hearing your thoughts :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions