mirror of
https://github.com/SinTan1729/random.git
synced 2025-04-19 09:10:00 -05:00
Compare commits
3 commits
0bab79d126
...
9f526cdcaf
Author | SHA1 | Date | |
---|---|---|---|
9f526cdcaf | |||
c0d8372159 | |||
12c0c39e67 |
3 changed files with 39 additions and 1 deletions
25
DND.py
Executable file
25
DND.py
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Turns on DND
|
||||||
|
# Can be used for toggling along with a parent script DNDToggle.sh
|
||||||
|
|
||||||
|
def set_procname(Newname):
|
||||||
|
newname = bytes(Newname, 'utf-8')
|
||||||
|
from ctypes import cdll, byref, create_string_buffer
|
||||||
|
libc = cdll.LoadLibrary('libc.so.6') #Loading a 3rd party library C
|
||||||
|
buff = create_string_buffer(len(newname)+1) #Note: One larger than the name (man prctl says that)
|
||||||
|
buff.value = newname #Null terminated string as it should be
|
||||||
|
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.
|
||||||
|
|
||||||
|
set_procname("DND.py")
|
||||||
|
|
||||||
|
from pydbus import SessionBus
|
||||||
|
import signal
|
||||||
|
|
||||||
|
bus = SessionBus()
|
||||||
|
remote_object = bus.get("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
|
||||||
|
|
||||||
|
remote_object.Inhibit("DND.py", "Manual suspend", {})
|
||||||
|
|
||||||
|
signal.pause()
|
||||||
|
|
13
DNDToggle.sh
Executable file
13
DNDToggle.sh
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Toggles DND
|
||||||
|
|
||||||
|
dnd=$(pgrep DND.py)
|
||||||
|
if [[ $dnd ]];
|
||||||
|
then
|
||||||
|
kill $dnd
|
||||||
|
pactl set-sink-mute @DEFAULT_SINK@ false
|
||||||
|
else
|
||||||
|
/home/sintan/.local/bin/personal/DND.py &
|
||||||
|
pactl set-sink-mute @DEFAULT_SINK@ true
|
||||||
|
fi
|
|
@ -1,4 +1,4 @@
|
||||||

|

|
||||||
# Random Scripts
|
# Random Scripts
|
||||||
This repository is for random scripts I wrote mostly for personal use.
|
This repository is for random scripts I wrote mostly for personal use.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue