clock with timer, folderflat with custom character and as-is
This commit is contained in:
60
FolderFlat
60
FolderFlat
@@ -4,25 +4,61 @@ function help() {
|
||||
echo "Files in subfolders will be renamed / -> _"
|
||||
echo "Empty folders are removed"
|
||||
echo " -f to force action "
|
||||
echo " -n to move files as is, i.e. not include path names in new name "
|
||||
echo " -p C Replace path separator / with character C "
|
||||
}
|
||||
|
||||
function helpexit() {
|
||||
help
|
||||
exit
|
||||
}
|
||||
[[ -z "$1" ]] && {
|
||||
|
||||
function preview() {
|
||||
echo ""
|
||||
for f in $( find . -mindepth 2 -type f -path '*.*' -printf %P'\n' | head ); do
|
||||
[[ "$NO_PATH" = "1" ]] && {
|
||||
echo "$f => " .
|
||||
} || {
|
||||
echo "$f =>" "${f//\//$SEP}"
|
||||
}
|
||||
done
|
||||
echo "..."
|
||||
}
|
||||
|
||||
function flat() {
|
||||
for f in $( find . -mindepth 2 -type f -path '*.*' -printf %P'\n' ); do
|
||||
[[ "$NO_PATH" = "1" ]] && {
|
||||
mv -iv "$f" .
|
||||
} || {
|
||||
mv -iv "$f" "${f//\//$SEP}"
|
||||
}
|
||||
done
|
||||
find . -depth -type d -empty -delete
|
||||
}
|
||||
|
||||
SEP="_"
|
||||
FORCE=0
|
||||
while getopts fhnp: opt
|
||||
do case "$opt" in
|
||||
f)
|
||||
FORCE=1
|
||||
;;
|
||||
h)
|
||||
helpexit
|
||||
;;
|
||||
n)
|
||||
NO_PATH=1
|
||||
;;
|
||||
p)
|
||||
SEP=$OPTARG
|
||||
;;
|
||||
esac
|
||||
done
|
||||
IFS=$'\n'
|
||||
[[ "$FORCE" = "0" ]] && {
|
||||
help
|
||||
preview
|
||||
echo "Are you sure? Break with ctrl-c"
|
||||
read i
|
||||
}
|
||||
[[ "$1" = "-h" ]] && helpexit
|
||||
|
||||
IFS=$'\n'
|
||||
|
||||
for f in $( find . -mindepth 2 -type f -path '*.*' -printf %P'\n' );
|
||||
do mv -iv "$f" "$( echo $f | sed s,[/],_,g )"
|
||||
done
|
||||
find . -depth -type d -empty -delete
|
||||
|
||||
|
||||
|
||||
flat
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
import curses
|
||||
import os,sys
|
||||
import time
|
||||
import time,datetime
|
||||
import math
|
||||
import signal
|
||||
from optparse import OptionParser
|
||||
@@ -30,12 +30,12 @@ def drawcircle(win,cy,cx,r):
|
||||
saddstr(win,dy,dx,'.')
|
||||
return
|
||||
|
||||
def drawline(win,cy,cx,a,r,char):
|
||||
def drawline(win,cy,cx,a,s,r,char):
|
||||
prec=2
|
||||
for l in range(r*prec):
|
||||
if l>1:
|
||||
if l>s:
|
||||
ly=int(round(cy-float(l)*math.cos(a)/prec))
|
||||
lx=int(round(cx+1.8*float(l)*math.sin(a)/prec))
|
||||
lx=int(round(cx+2.0*float(l)*math.sin(a)/prec))
|
||||
saddstr(win,ly,lx,char)
|
||||
|
||||
return
|
||||
@@ -97,9 +97,17 @@ def readinput(win):
|
||||
return ""
|
||||
return ""
|
||||
|
||||
class timer_struct:
|
||||
""" Class for storing timer. """
|
||||
def __init__(self,h,m,s):
|
||||
self.tm_hour=int(h)
|
||||
self.tm_min=int(m)
|
||||
self.tm_sec=int(s)
|
||||
|
||||
def main():
|
||||
stdscr=curses.initscr()
|
||||
curses.curs_set(0)
|
||||
start_t=time.time()
|
||||
try:
|
||||
#rows,columns = termsize()
|
||||
while (1):
|
||||
@@ -107,16 +115,30 @@ def main():
|
||||
cy,cx,r = centerpoint(rows,columns)
|
||||
stdscr.clear()
|
||||
t=time.localtime()
|
||||
alphas=math.pi*float(t.tm_sec)/30.0
|
||||
alpham=math.pi*float(t.tm_min)/30.0 + alphas/60.0
|
||||
alphah=math.pi*float(t.tm_hour)/6.0 + alpham/12.0
|
||||
if options.timer:
|
||||
t_new=time.time()-start_t
|
||||
t_m, t_s = divmod(t_new, 60)
|
||||
t_h, t_m = divmod(t_m, 60)
|
||||
else:
|
||||
t_s=float(t.tm_sec)
|
||||
t_m=float(t.tm_min)
|
||||
t_h=float(t.tm_hour)
|
||||
alphas=math.pi*t_s/30.0
|
||||
alpham=math.pi*t_m/30.0 + alphas/60.0
|
||||
alphah=math.pi*t_h/6.0 + alpham/12.0
|
||||
if options.seconds:
|
||||
drawline(stdscr,cy,cx,alphas,r/2,'s')
|
||||
drawline(stdscr,cy,cx,alpham,int(round(r*0.8)/2),'m')
|
||||
drawline(stdscr,cy,cx,alphah,int(round(r*0.5)/2),'HH')
|
||||
drawline(stdscr,cy,cx,alphas,1,r/2,'s')
|
||||
drawline(stdscr,cy,cx,alpham,1,int(round(r*0.8)/2),'m')
|
||||
drawline(stdscr,cy,cx,alphah,1,int(round(r*0.5)/2),'HH')
|
||||
stdscr.addstr(cy,cx,'o')
|
||||
drawcircle(stdscr,cy,cx,r/2)
|
||||
drawdigital(stdscr,1,1,t)
|
||||
for h in range(12):
|
||||
drawline(stdscr,cy,cx,math.pi*h/6.0,r,1+r/2,'O')
|
||||
if options.timer:
|
||||
drawdigital(stdscr,1,1,timer_struct(t_h,t_m,t_s))
|
||||
drawdigital(stdscr,7,1,t)
|
||||
else:
|
||||
drawdigital(stdscr,1,1,t)
|
||||
stdscr.refresh()
|
||||
#time.sleep(options.refresh)
|
||||
signal.signal(signal.SIGALRM, readinput)
|
||||
@@ -144,6 +166,8 @@ parser.add_option("-s",action="store_true",dest="seconds",default=False,
|
||||
help="Show seconds [%default]")
|
||||
parser.add_option("-r",type="int",dest="refresh",default=3,
|
||||
help="Refresh rate in seconds [%default]")
|
||||
parser.add_option("-t",action="store_true",dest="timer",default=False,
|
||||
help="Timer instead of current time [%default]")
|
||||
global options
|
||||
(options,args)=parser.parse_args()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user