-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmenu.sh
executable file
·146 lines (109 loc) · 2.88 KB
/
dmenu.sh
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#! /usr/bin/env sh
. "/home/istvan/progs/utils/utils.sh"
opt="-fn -adobe-helvetica-bold-r-normal-*-25-180-100-100-p-138-iso8859-1"
alias mymenu="dmenu $opt"
extract_music() {
IFS=$'\n'
for zipfile in $(ls /tmp/*.zip); do
outpath="/home/istvan/Zenék/$(basename $zipfile .zip)"
mkdir $outpath
unzip $zipfile -d $outpath
done
}
if_nempty() {
if [ -n "$1" ]; then
eval "$2"
fi
}
last_field() {
while read data; do
printf "%s\n" $(printf "%s\n" $data | awk -F '/' '{print $NF}')
done
}
playlists() {
local path="/home/istvan/playlists"
local select=$(ls -1 $path/*.m3u | last_field | mymenu)
if_nempty $select "parole $path/$select &"
}
mc() {
local path="/home/istvan/progs"
local select=$(ls -1 -d $path/* | last_field | \
mymenu -p "Select progs directory")
if_nempty $select "$temu -e 'mc $path/$select'"
}
ssh() {
local select=$(printf "robosztus\nzafir\n" | mymenu -p "Select server")
case $select in
"robosztus")
$temu -e 'ssh -Y istvan@robosztus.ggki.hu'
;;
"zafir")
$temu -e 'ssh -Y istvan@zafir.ggki.hu'
;;
*)
printf "Unknown option: %s!\n" $select
esac
}
git_repo_manage() {
local path="/home/istvan/progs"
local gtmp="/tmp/git_commit_tpl"
local select=$(printf "utils\ngamma\ninsar_meteo\n"| mymenu -p "Select from github repos")
local gdir=$(printf "--git-dir=%s/%s" $path $select)
local _push="nano \"$gtmp\";git commit -a -F \"$gtmp\" $gdir;\
git push origin master $gdir;rm \"$gtmp\";"
case $1 in
"pull")
$temu -e "echo asd; cd $path/$select; git pull origin master"
;;
"push")
# $temu -e sh -c "$_push"
# ta "$gtmp"
$temu -e "git commit -a $gdir > /home/istvan/debug"
#cd $path/$select
#
#echo "Set commit message"
#nano "$gtmp"
#
#git commit -a -F "$gtmp"
#git push origin master
#
#rm "$gtmp"
;;
esac
}
select_module() {
local select=$(printf "playlist\nmc\nssh\npush\npull" | mymenu -p "Select from modules")
case $select in
"playlist")
playlists
;;
"mc")
mc
;;
"ssh")
ssh
;;
"push")
git_repo_manage push
;;
"pull")
git_repo_manage pull
;;
esac
}
main() {
check_narg $# 1
case $1 in
"programs")
dmenu_run $opt
;;
"modules")
select_module
;;
*)
printf "Unrecognized option %s!\n" $1 >&2
exit
;;
esac
}
main $@