~umang/indicator-stickynotes/trunk

« back to all changes in this revision

Viewing changes to indicator-stickynotes.py

  • Committer: Umang Varma
  • Date: 2018-09-08 16:05:26 UTC
  • mfrom: (157.1.4)
  • Revision ID: git-v1:41cd2e9bda580728be734496c46f216c47c2f9b9
Merge branch 'jamesljlster-master'

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
from functools import wraps
37
37
from shutil import copyfile, SameFileError
38
38
 
 
39
import socket
 
40
import sys
 
41
 
39
42
def save_required(f):
40
43
    """Wrapper for functions that require a save after execution"""
41
44
    @wraps(f)
249
252
    def save(self):
250
253
        self.nset.save()
251
254
 
252
 
 
253
255
def main():
 
256
    # Avoid duplicate process
 
257
    # From https://stackoverflow.com/questions/788411/check-to-see-if-python-script-is-running
 
258
    procLock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
 
259
    try:
 
260
        procLock.bind('\0' + 'indicator-stickynotes')
 
261
    except socket.error:
 
262
        print('Indicator stickynotes already running.')
 
263
        sys.exit()
 
264
 
254
265
    try:
255
266
        locale.setlocale(locale.LC_ALL, '')
256
267
    except: