Advertisement
Guest User

rofi-background.py

a guest
Oct 27th, 2019
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import subprocess
  2. from pynput import keyboard
  3. import sys
  4. import time
  5.  
  6. def on_key_press(key):
  7.     if (str(key) == 'Key.esc' or str(key) == 'Key.enter'):
  8.         subprocess.call(["kill", str(process_feh.pid)])
  9.         sys.exit()
  10.  
  11. picture = "/path/to/your/picture"
  12.  
  13. process_rofi = subprocess.Popen(["rofi", '-show', 'run', '-config', '/path/to/your/rofi-config'])
  14. time.sleep(0.03) # Edit this to sync feh and rofi better
  15. process_feh = subprocess.Popen(["feh", '-x', picture, '--title', '\"rofi-feh\"', '--geometry', '960x360']) # Edit the 960x360 to fit your rofi
  16.  
  17. with keyboard.Listener(on_press = on_key_press) as listener:
  18.     listener.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement