about summary refs log tree commit diff stats
path: root/src/xmpp/resource.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2021-03-26 10:05:24 +0100
committerMichael Vetter <jubalh@iodoru.org>2021-03-26 10:05:24 +0100
commitacda845b2aa212ff19b2b0c10d77a2b7eb090156 (patch)
treec12bc67610258af450edff2a32fe3031cb081e5e /src/xmpp/resource.c
parent3884a4d35bce3e306fc1b7e02d55184bc7a90f19 (diff)
downloadprofani-tty-acda845b2aa212ff19b2b0c10d77a2b7eb090156.tar.gz
iq: use define for 'cancel'
Diffstat (limited to 'src/xmpp/resource.c')
0 files changed, 0 insertions, 0 deletions
itle='Blame the previous revision' href='/akspecs/ranger/blame/examples/plugin_ipc.py?id=db7c728b71bce950b4683dca16d85fbc55bd2c42'>^
b3d031a9 ^

eed17676 ^





dded3cb8 ^
eed17676 ^

d1bb32bf ^


eed17676 ^


b3d031a9 ^
eed17676 ^







b3d031a9 ^
eed17676 ^



b3d031a9 ^


eed17676 ^
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56








                                                                      
                                                                  
 

                 

                                    

 



                        

                                                        





                                    
 

                                 


                                                                           


                                                    
                                                        







                                         
                                              



                              


                         
                                
# Tested with ranger 1.7.0 through ranger 1.7.*
#
# This plugin creates a FIFO in /tmp/ranger-ipc.<PID> to which any
# other program may write. Lines written to this file are evaluated by
# ranger as the ranger :commands.
#
# Example:
#   $ echo tab_new ~/images > /tmp/ranger-ipc.1234

from __future__ import (absolute_import, division, print_function)

import ranger.api


HOOK_INIT_OLD = ranger.api.hook_init


def hook_init(fm):
    try:
        # Create a FIFO.
        import os
        ipc_fifo = "/tmp/ranger-ipc." + str(os.getpid())
        os.mkfifo(ipc_fifo)

        # Start the reader thread.
        try:
            import thread
        except ImportError:
            import _thread as thread

        def ipc_reader(filepath):
            while True:
                # The IPC encoding depends on the system locale so we can't
                # guess here.
                # pylint: disable=unspecified-encoding
                with open(filepath, 'r') as fifo:
                    line = fifo.read()
                    fm.execute_console(line.strip())
        thread.start_new_thread(ipc_reader, (ipc_fifo,))

        # Remove the FIFO on ranger exit.
        def ipc_cleanup(filepath):
            try:
                os.unlink(filepath)
            except IOError:
                pass
        import atexit
        atexit.register(ipc_cleanup, ipc_fifo)
    except IOError:
        # IPC support disabled
        pass
    finally:
        HOOK_INIT_OLD(fm)


ranger.api.hook_init = hook_init