From dc0ae2b4a8d4322a2f3c6f8985ca365698cf556e Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 3 Oct 2011 22:03:44 +0200 Subject: move irssi afk code to screen-locker.sh Signed-off-by: Florian Pritz --- irssi_socket_control.py | 50 ------------------------------------------------- screen-locker.sh | 8 +++----- 2 files changed, 3 insertions(+), 55 deletions(-) delete mode 100755 irssi_socket_control.py diff --git a/irssi_socket_control.py b/irssi_socket_control.py deleted file mode 100755 index e613149..0000000 --- a/irssi_socket_control.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -#---------------------------------------------------- -# Version: 0.1.0 -# Author: Florian "Bluewind" Pritz -# -# Licensed under WTFPL v2 -# (see COPYING for full license text) -# -#---------------------------------------------------- -# runs commands in irssi using socket_interface.pl -#---------------------------------------------------- - -import socket -import user -import sys - -def smart_bool(s): - """ - Converts many strings to booleans - - from http://codecomments.wordpress.com/2008/04/08/converting-a-string-to-a-boolean-value-in-python/ - """ - if s is True or s is False: - return s - s = str(s).strip().lower() - return not s in ['false','f','n','0',''] - -def handler(away): - s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - - try: - s.connect(user.home + "/.irssi/socket") - except socket.error: - exit(1) - - if away: - s.send("command /away afk") - else: - s.send("command /away") - s.close() - -def main(): - try: - away = smart_bool(sys.argv[1]) - except IndexError: - away=False - handler(away) - -if __name__ == '__main__': - main() diff --git a/screen-locker.sh b/screen-locker.sh index b5ec254..d0eb820 100755 --- a/screen-locker.sh +++ b/screen-locker.sh @@ -1,19 +1,17 @@ #!/bin/sh #---------------------------------------------------- -# Version: 0.1.1 # Author: Florian "Bluewind" Pritz # # Licensed under WTFPL v2 # (see COPYING for full license text) # #---------------------------------------------------- -# mange script for locking the screen +# managing script for locking the screen #---------------------------------------------------- lock () { gajim-remote change_status away & - ssh mistral 'python2 ~/bin/irssi_socket_control.py 1' -# (sleep 0.5 && swarp 0 0) & + echo "command /away afk" | ssh mistral 'socat stdin unix-connect:.irssi/socket' xset dpms 5 5 5 slock } @@ -21,7 +19,7 @@ lock () { unlock () { xset dpms 0 0 0 gajim-remote change_status online & - ssh mistral 'python2 ~/bin/irssi_socket_control.py 0' + echo "command /away" | ssh mistral 'socat stdin unix-connect:.irssi/socket' } if pidof slock &> /dev/null; then exit 1; fi -- cgit v1.2.3-24-g4f1b