tubbadu

Untitled

Mar 6th, 2022
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #
  2. # doNotDisturb.py
  3. #
  4.  
  5. #!usr/bin/python3
  6.  
  7. def set_procname(Newname):
  8. newname = bytes(Newname, 'utf-8')
  9. from ctypes import cdll, byref, create_string_buffer
  10. libc = cdll.LoadLibrary('libc.so.6') #Loading a 3rd party library C
  11. buff = create_string_buffer(len(newname)+1) #Note: One larger than the name (man prctl says that)
  12. buff.value = newname #Null terminated string as it should be
  13. libc.prctl(15, byref(buff), 0, 0, 0) #Refer to "#define" of "/usr/include/linux/prctl.h" for the misterious value 16 & arg[3..5] are zero as the man page says.
  14.  
  15. set_procname("doNotDisturb.py")
  16.  
  17. from pydbus import SessionBus
  18. import signal
  19.  
  20. bus = SessionBus()
  21. remote_object = bus.get("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
  22.  
  23. remote_object.Inhibit("", "", {})
  24.  
  25. signal.pause()
  26.  
  27. #
  28. ##########################################
  29. #
  30.  
  31.  
  32. #
  33. # doNotDisturbToggle.sh
  34. #
  35.  
  36. #!usr/bin/bash
  37.  
  38. dnd=$(pgrep doNotDisturb.py)
  39. if [[ $dnd ]];
  40. then
  41. kill $dnd
  42. else
  43. /home/user/path/to/doNotDisturb.py &
  44. fi
Add Comment
Please, Sign In to add comment