aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-03-18 16:31:39 +0100
committerJon Lund Steffensen <jonlst@gmail.com>2014-03-23 01:16:44 +0100
commitae5c6f5d834aff4af1fd3a7c26267b297692c019 (patch)
tree0bcc1ac0a899fa5dc1fa3c6fceb77ef2e61c2bed
parentFix #40: redshift-gtk: toggle_item is checkbox that follows the icon (diff)
downloadredshift-ng-ae5c6f5d834aff4af1fd3a7c26267b297692c019.tar.gz
redshift-ng-ae5c6f5d834aff4af1fd3a7c26267b297692c019.tar.bz2
redshift-ng-ae5c6f5d834aff4af1fd3a7c26267b297692c019.tar.xz
[redshift-gtk] Add BSD support to proc title setting
-rw-r--r--src/redshift-gtk/utils.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/redshift-gtk/utils.py b/src/redshift-gtk/utils.py
index 4d3b619..73c95a9 100644
--- a/src/redshift-gtk/utils.py
+++ b/src/redshift-gtk/utils.py
@@ -67,12 +67,23 @@ def set_autostart(active):
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
+ title_bytes = title.encode(sys.getdefaultencoding(), 'replace')
+ buf = ctypes.create_string_buffer(title_bytes)
+ if 'linux' in sys.platform:
+ try:
+ libc = ctypes.cdll.LoadLibrary("libc.so.6")
+ except OSError:
+ return
+ try:
+ libc.prctl(15, buf, 0, 0, 0)
+ except AttributeError:
+ return # Strange libc, just skip this
+ elif 'bsd' in sys.platform:
+ try:
+ libc = ctypes.cdll.LoadLibrary("libc.so.7")
+ except OSError:
+ return
+ try:
+ libc.setproctitle(ctypes.create_string_buffer(b"-%s"), buf)
+ except AttributeError:
+ return