Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0278e90985
Fetching contributors…

Cannot retrieve contributors at this time

executable file 64 lines (52 sloc) 1.834 kb
#!/usr/bin/python
# -*- coding: utf-8 -*-
#This program is free software. It comes without any warranty, to
#the extent permitted by applicable law. You can redistribute it
#and/or modify it under the terms of the Do What The Fuck You Want
#To Public License, Version 2, as published by Sam Hocevar. See
#http://sam.zoy.org/wtfpl/COPYING for more details.
import sys
import os
import subprocess
import config
is_ret = True
target_num = 0
args = sys.argv[1:]
if len(args)>0:
if '-t' in args:
is_ret = False
if '-s' in args:
target_num = int(args[args.index('-s') + 1])
output_path = config.target[target_num]['path']
img = config.target[target_num]['img']
title = output_path.split('/')[-1].upper()
def get_xsel_input():
in_content = subprocess.check_output(['xsel','-p'])
return in_content
def clear_input(in_content):
in_string = in_content.replace('\t',' ')
in_string = in_string.replace('\n', '\t')
return in_string
def save_content(out_path, in_string, is_ret):
#there must be a easer way to add a string in the end of a file!
outfile = open(out_path, 'r')
in_content = outfile.read()
outfile.close
in_content+=in_string
if is_ret:
in_content+='\n'
else:
in_content+='\t'
outfile = open(out_path, 'w')
outfile.write(in_content)
outfile.close
def notify_send(title, saved_string, is_ret):
if not is_ret:
saved_string = '^fg(red)' + saved_string
output = 'echo \"->{1}: {0}\"'.format(saved_string, title)
subprocess.Popen([output + '| dzen2 -p 2 -w 400 -h 30 -ta r -x 800 -y 100 -l 3 -fg green'], shell=True)
in_content = get_xsel_input()
in_string = clear_input(in_content)
save_content(output_path, in_string, is_ret)
notify_send(title, in_string, is_ret)
#TODO ignore ' and " in input string
Jump to Line
Something went wrong with that request. Please try again.