-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslo
executable file
·63 lines (54 loc) · 1.46 KB
/
slo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# 2018-06-19
# Server for lo (Server for Lots of file Opener)
# Creates and uses ~/.slo to work in.
# Launch in your startup sequence. Needs "silent_cpucsekk" from my cli_util repo (or you could just replace that line by "sleep 1").
# It's a good idea to print the size of the queue in your status line:
# lolength=$(cat $HOME/.slo/2p.txt | wc -l)
# echo "lo: $lolength"
# Create ~/.slo/, ~/.slo/2p/, ~/.slo/2p.txt if doesn't exist
if [ ! -d $HOME/.slo/ ]
then
mkdir $HOME/.slo/
fi
if [ ! -d $HOME/.slo/2p/ ]
then
mkdir $HOME/.slo/2p/
fi
if [ ! -f $HOME/.slo/2p.txt ]
then
touch $HOME/.slo/2p.txt
fi
# First clean dir, should anything be left there from earlier sessions.
if [ ! -z "$(ls -A $HOME/.slo/2p)" ]
then
for i in $HOME/.slo/2p/*
do
intofile=${i##*/}
echo "$intofile" >> $HOME/.slo/2p.txt
done
fi
# Main loop: check what needs to be opened and open with browser or svlo.
while true
do
# This is from my cli_util repo:
silent_cpucsekk
if [ -s $HOME/.slo/2p.txt ]
then
line=$(sed -n 1p $HOME/.slo/2p.txt)
if [[ ! -z $line ]]
then
sed -i 1d $HOME/.slo/2p.txt
fi
#sed -i "/$line/d" $HOME/.slo/2p.txt #Cannot handle / in urls :-(
if [[ "$line" == "http://"* ]] || [[ "$line" == "https://"* ]] || [[ "$line" == "file://"* ]]
then
# mybr is my browser script, can replace this with e.g., "firefox" or "chromium-browser".
mybr "$line" &
elif [[ ! -z $line ]]
then
svlo "$line" &
fi
#sed -i "/$line/d" $HOME/.slo/2p.txt
fi
done