You are not logged in.

#1 2015-11-15 01:54:39

riddle00
Member
From: Lithuania
Registered: 2015-05-26
Posts: 81

[SOLVED] open Gmrun with command already typed

Hi,

What do I need to put in my .gmrunrc, so that when I run gmrun, it opens each time with the same command already typed, but not executed yet,
to be specific, with 'wmctrl -a'.

Last edited by riddle00 (2015-11-15 22:12:50)

Offline

#2 2015-11-15 02:08:23

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: [SOLVED] open Gmrun with command already typed

Hmmm, I didn't even know gmrun had a configuration file... interesting.

I don't see any way to do it via the documentation that I've found , but you can do it by manipulating the history file:

echo 'wmctrl -a' >> ~/.gmrun_history
gmrun

Wrap that up in a script that filters duplicate entries and you have what you need.


edit
This works. Save it as whatever (e.g. "gmrunner") and invoke it instead of gmrun. Obviously it depends on Python 3.

#!/usr/bin/env python3

from collections import OrderedDict
import os
import sys

GMRUN_BIN = '/usr/bin/gmrun'
GMRUN_HIST = '~/.gmrun_history'
CMD = 'wmctrl -a'

def main():
  histpath = os.path.expanduser(GMRUN_HIST)
  cmds = OrderedDict()

  try:
    with open(histpath, 'r') as f:
      for line in f:
        line = line.rstrip('\n')
        try:
          cmds[line] += 1
        except KeyError:
          cmds[line] = 1
  except FileNotFoundError:
    pass

  try:
    del cmds[CMD]
  except KeyError:
    pass
  cmds[CMD] = 1

  with open(histpath, 'w') as f:
    for cmd in cmds:
      f.write(cmd + '\n')

  args = [os.path.basename(GMRUN_BIN)] + sys.argv[1:]
  os.execv(GMRUN_BIN, args)

try:
  main()
except KeyboardInterrupt:
  pass

Last edited by Xyne (2015-11-15 02:30:13)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#3 2015-11-15 16:08:40

riddle00
Member
From: Lithuania
Registered: 2015-05-26
Posts: 81

Re: [SOLVED] open Gmrun with command already typed

Thanks, @Xyne, for your time, that's great, just what I needed! It would also be useful if somehow when gmrun is opened, the command is not selected, and the cursor is at the end of the command, ready for additional input. This way I could focus window by its title in as few steps as possible. Ex. for Firefox - 1step) keybinding for gmrunner 2step)typing 'f', which would be enough to recognize Firefox.

Offline

#4 2015-11-15 22:13:49

riddle00
Member
From: Lithuania
Registered: 2015-05-26
Posts: 81

Re: [SOLVED] open Gmrun with command already typed

Okey, I did it with the help of xdotool. smile

Offline

Board footer

Powered by FluxBB