Ejemplo n.º 1
0
    def on_done(self, index):
        if index == -1:
            return

        file_name_with_args = self.files[index][0]
        file_name, line, column, view_id = file_name_with_args.split(":")
        settings = sublime.load_settings("set_window_title.sublime-settings")

        for window in sublime.windows():
            for idx, view in enumerate(window.views(), start=0):
                if not str(view.id()) == view_id:
                    continue

                project = self.get_project(window)
                official_title = self.get_official_title(
                    window.active_view(), project, settings)

                wmctrl_out = os.popen(
                    "wmctrl -dliGux | grep '{sublime_title}'".format(
                        sublime_title=official_title)).read()
                wmctrl_out = wmctrl_out.split('\n')[0]

                current_window = WmctrlWindow(wmctrl_out)
                current_window.set_focus()
                sublime_api.window_focus_view(window.id(), view.id())
                view.sel().clear()
                view.sel().add(
                    sublime.Region(view.text_point(int(line), int(column))))
                view.show(view.text_point(int(line), int(column)))
                break
Ejemplo n.º 2
0
def main(argv):
    display = Display()
    root = display.screen().root
    root.change_attributes(event_mask=X.PropertyChangeMask
                           | X.SubstructureNotifyMask)
    skip_windows = [
        'tk.TkN/Awindowswitcher',
        'xfce4-appfinder.Xfce4-appfinderxavierApplicationFinder'
    ]

    NET_ACTIVE_WINDOW = display.intern_atom('_NET_ACTIVE_WINDOW')

    try:
        while True:
            event = display.next_event()
            if event.type != X.PropertyNotify:
                continue

            response = root.get_full_property(NET_ACTIVE_WINDOW,
                                              X.AnyPropertyType)
            win_id = hex(response.value[0]).rstrip('L').lstrip('0x')

            if len(win_id) == 0:
                continue

            wmctrl_out = os.popen(
                'sleep 0.1; wmctrl -dliGux | grep -i {win_id}'.format(
                    win_id=win_id)).read()
            wmctrl_out = wmctrl_out.split('\n')
            wmctrl_out.pop()

            if len(wmctrl_out) != 1:
                continue

            window = WmctrlWindow(wmctrl_out[0])
            # ignore window switcher
            if window.name in skip_windows:
                continue

            str_json = open("/home/danilo/scripts/flip360_wids.json",
                            "r").read()
            jjson = json.loads(str_json)

            key_json = 'm{m}{w}'.format(m=window.monitor, w=window.workspace)
            if jjson.get(key_json, None) == None:
                continue

            window_previous = WmctrlWindow(jjson[key_json])
            if window.id == window_previous.id:
                continue

            jjson[key_json] = window.str_win
            flip360_wids = open("/home/danilo/scripts/flip360_wids.json", "w")
            flip360_wids.write(json.dumps(jjson))
            flip360_wids.close()

    finally:
        display.close()
Ejemplo n.º 3
0
  def on_window_show(self, window1):
    label_window_name = builder.get_object('label_window_name')

    active_window = WmctrlWindow(wmctrl_line)
    # print(repr(active_window))
    label_window_name.set_text(active_window.name)
Ejemplo n.º 4
0
import sys
import os
import re

sys.path.append("/home/danilo/scripts/")

from wmctrl_window import WmctrlWindow

outt = os.popen('wmctrl -dliGux').read()
lines = outt.split("\n")
lines.pop()

windows = []
for line in lines:
    windows.append(WmctrlWindow(line))

# if workspace is -1 dont be necessary
workspace = int(sys.argv[1][1]) - 1
monitor = int(sys.argv[1][3])
class_window = sys.argv[2]

windows.sort(key=lambda x: x.monitor, reverse=False)
windows = filter(
    lambda x: x.monitor == monitor and
    (workspace == -1 or x.workspace == workspace), windows)
windows = filter(lambda x: re.search("^" + class_window, x.name), windows)

if len(windows) == 0:
    sys.exit()
Ejemplo n.º 5
0
def get_windows(options):
    all_windows = []
    current_window = {}

    if not options['only_tabs']:
        wmctrl_out = check_output(['wmctrl', '-dliGux'])  #.decode('utf-8')
        wmctrl_out = wmctrl_out.split('\n')
        wmctrl_out.pop()

        outt = os.popen('/home/danilo/scripts/get_current_window.sh').read()
        current_window_id = outt.replace(',', '').split('x')[1]
        current_window_id = re.sub(r'(\r\n\t|\n|\r\t|\n)', '',
                                   current_window_id)

        current_window = None
        for window in wmctrl_out[::-1]:
            ctrlWindow = WmctrlWindow(unicode(window, 'utf-8'))

            if window.find(current_window_id) >= 0:
                current_window = WmctrlWindow(window)

            id = ctrlWindow.id
            name = 'k' + str(ctrlWindow.workspace + 1) + 'm' + str(
                ctrlWindow.monitor) + ' ' + ctrlWindow.kname
            if ctrlWindow.workspace + 1 > 0:
                all_windows.append({
                    'id': ctrlWindow.id,
                    'type': ctrlWindow.type,
                    'set_focus': ctrlWindow.set_focus,
                    'name': name.lower()
                })

    all_tabs = []
    if not options['only_windows']:
        try:
            chromix_out = check_output(['chromix-too', 'ls']).decode('utf-8')
        except BaseException:
            chromix_out = ''

        chromix_out = chromix_out.split('\n')

        if len(chromix_out) < 2:
            return [all_windows, current_window]

        for tab in chromix_out:
            if len(tab) > 5:
                all_tabs.append(ChromixTooTab(tab))

        all_tabs.sort(key=lambda x: x.id, reverse=True)
        for tab in all_tabs:
            prefix = 't '
            if options['only_tabs']:
                prefix = ''

            all_windows.append({
                'id':
                tab.id,
                'type':
                tab.type,
                'set_focus':
                tab.set_focus,
                'name':
                prefix + tab.domain + ' ' + tab.title.lower()
            })

    all_sublime = []
    if not options['only_sublime']:
        str_json = open("/home/danilo/scripts/sublime_tabs.json", "r").read()
        sublime_tabs = json.loads(str_json)

        for window_id in sublime_tabs.keys():
            for idx, path_file in enumerate(sublime_tabs[window_id], start=0):
                sublime_tab = SublimeTab(window_id, path_file, idx)
                all_windows.append({
                    'id': sublime_tab.id,
                    'type': sublime_tab.type,
                    'set_focus': sublime_tab.set_focus,
                    'name': 's ' + sublime_tab.title
                })

    return [all_windows, current_window]
Ejemplo n.º 6
0
import sys
import json

from wmctrl_window import WmctrlWindow

# wmctrlWindow = WmctrlWindow("0x02a00136  1 0    473  3840 2137 xavier Tilix: teste")
# sys.exit()

# def ls_window
outt = os.popen('wmctrl -dliGux').read()
lines = outt.split("\n")
lines.pop()

windows = []
for line in lines:
    windows.append(WmctrlWindow(line))

windows.sort(key=lambda x: x.monitor, reverse=False)
# end

# def current_window
outt = os.popen('/home/danilo/scripts/get_current_window.sh').read()
current_window_id = outt.replace(',', '').split('x')[1]
current_window_id = re.sub(r'(\r\n\t|\n|\r\t|\n)', '', current_window_id)

current_window = None
for line in lines:
    if line.find(current_window_id) >= 0:
        current_window = WmctrlWindow(line)

# end
Ejemplo n.º 7
0
    list_to_show.append(name)

option = dmenu.show(list_to_show,
                    case_insensitive=True,
                    lines=20,
                    bottom=True,
                    monitor=3,
                    font='Monospace-16:normal')
item = tilix_mapping.get(option, None)

if not item:
    sys.exit()

# {"dxfac": {"session": "4", "tag": "1", "window": "0x06401143  1 7680 1350 2880 1620 xavier s6"}}

window = WmctrlWindow(item['window'])
window.set_focus()
time.sleep(0.2)

session = int(item.get('session', 0))
tab = int(item.get('tab', 0))
init_text = item.get('init_text', None)

if session > 0:
    os.popen(f'xdotool key ctrl+alt+{session}').read()

if tab > 0:
    os.popen(f'xdotool key super+shift+Up').read()
    os.popen(f'xdotool key super+shift+Left').read()

    if tab == 2:
Ejemplo n.º 8
0
import sys
import json

from wmctrl_window import WmctrlWindow

# wmctrlWindow = WmctrlWindow("0x02a00136  1 0    473  3840 2137 xavier Tilix: teste")
# sys.exit()

# def ls_window
outt = os.popen('wmctrl -dliGu').read()
lines = outt.split("\n")
lines.pop()

windows = []
for line in lines:
    windows.append(WmctrlWindow(line))

windows.sort(key=lambda x: x.monitor, reverse=False)
# end

# def current_window
outt = os.popen('/home/danilo/scripts/get_current_window.sh').read()
current_window_id = outt.replace(',', '').split('x')[1]
current_window_id = re.sub(r'(\r\n\t|\n|\r\t|\n)', '', current_window_id)

current_window = None
for line in lines:
    if line.find(current_window_id) >= 0:
        current_window = WmctrlWindow(line)

# end