aboutsummaryrefslogtreecommitdiffstats
path: root/src/redshift-gtk/utils.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-03-17 15:37:37 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2014-03-17 15:37:37 +0100
commit3e58daa3f4465a6a94ab157ec507dcba040db74a (patch)
tree0f5981581a5c5a4878503cedef8f8b61c20b2cdf /src/redshift-gtk/utils.py
parentMerge remote-tracking branch 'maandree/leaks' (diff)
downloadredshift-ng-3e58daa3f4465a6a94ab157ec507dcba040db74a.tar.gz
redshift-ng-3e58daa3f4465a6a94ab157ec507dcba040db74a.tar.bz2
redshift-ng-3e58daa3f4465a6a94ab157ec507dcba040db74a.tar.xz
[gtk] Set proc title
Try to set the process title during startup. Before, redshift-gtk appeared as a python process. This change enables `pgrep redshift-gtk` or `killall redshift-gtk`.
Diffstat (limited to 'src/redshift-gtk/utils.py')
-rw-r--r--src/redshift-gtk/utils.py14
1 files changed, 14 insertions, 0 deletions
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