Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing Rofi options on initialize? #4

Open
prdanelli opened this issue Mar 13, 2022 · 0 comments
Open

Passing Rofi options on initialize? #4

prdanelli opened this issue Mar 13, 2022 · 0 comments

Comments

@prdanelli
Copy link

prdanelli commented Mar 13, 2022

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant