aboutsummaryrefslogtreecommitdiffstats
path: root/src/redshift-gtk
diff options
context:
space:
mode:
authorJon Lund Steffensen <jonlst@gmail.com>2014-03-18 16:25:51 +0100
committerJon Lund Steffensen <jonlst@gmail.com>2014-03-18 16:25:51 +0100
commitf17e1d1f9890db612ceeab5368a31879eb170f7c (patch)
tree5c2f3e943da301c62608fc45f1fe9b00cc3eac5d /src/redshift-gtk
parentMerge pull request #48 from maandree/man (diff)
parent[gtk] Set proc title (diff)
downloadredshift-ng-f17e1d1f9890db612ceeab5368a31879eb170f7c.tar.gz
redshift-ng-f17e1d1f9890db612ceeab5368a31879eb170f7c.tar.bz2
redshift-ng-f17e1d1f9890db612ceeab5368a31879eb170f7c.tar.xz
Merge pull request #45 from phihag/setproctitle
redshift-gtk: Set proc title using libc prctl
Diffstat (limited to '')
-rw-r--r--src/redshift-gtk/statusicon.py3
-rw-r--r--src/redshift-gtk/utils.py14
2 files changed, 17 insertions, 0 deletions
diff --git a/src/redshift-gtk/statusicon.py b/src/redshift-gtk/statusicon.py
index 6174aec..6877eac 100644
--- a/src/redshift-gtk/statusicon.py
+++ b/src/redshift-gtk/statusicon.py
@@ -316,7 +316,10 @@ class RedshiftStatusIcon(object):
os.kill(self.process[0], signal.SIGINT)
os.waitpid(self.process[0], 0)
+
def run():
+ utils.setproctitle('redshift-gtk')
+
# Internationalisation
gettext.bindtextdomain('redshift', defs.LOCALEDIR)
gettext.textdomain('redshift')
diff --git a/src/redshift-gtk/utils.py b/src/redshift-gtk/utils.py
index 723d4d8..4d3b619 100644
--- a/src/redshift-gtk/utils.py
+++ b/src/redshift-gtk/utils.py
@@ -17,7 +17,9 @@
# Copyright (c) 2010 Francesco Marella <francesco.marella@gmail.com>
# Copyright (c) 2011 Jon Lund Steffensen <jonlst@gmail.com>
+import ctypes
import os
+import sys
from xdg import BaseDirectory as base
from xdg import DesktopEntry as desktop
@@ -62,3 +64,15 @@ def set_autostart(active):
for key, values in AUTOSTART_KEYS:
dfile.set(key, values[active])
dfile.write(filename=path)
+
+
+def setproctitle(title):
+ try:
+ libc = ctypes.cdll.LoadLibrary("libc.so.6")
+ except OSError:
+ return
+ buf = ctypes.create_string_buffer(title.encode(sys.getdefaultencoding()))
+ try:
+ libc.prctl(15, ctypes.byref(buf), 0, 0, 0)
+ except AttributeError:
+ return # Strange libc, just skip this