-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (24 loc) · 759 Bytes
/
Copy pathmain.py
File metadata and controls
31 lines (24 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import clipboard
import keyboard
import os
import time
import urllib.parse
import subprocess
import art
class GoogleZri:
hotkey = ''
def registerHotKey(self, hotkey):
self.hotkey = hotkey
keyboard.add_hotkey(self.hotkey, self.hotKeyCallback)
def hotKeyCallback(self):
selectedText = subprocess.getoutput('xclip -o')
selectedText = urllib.parse.quote_plus(selectedText)
os.system(
'sudo -u $(logname) google-chrome -new-tab https://www.google.com/search?q=' + selectedText + " &")
def listen(self):
art.tprint('GoogleZri')
print('Press ' + self.hotkey + ' to Google any selected text.')
keyboard.wait()
gz = GoogleZri()
gz.registerHotKey('ctrl+f2')
gz.listen()