-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/bozso/utils
- Loading branch information
Showing
4 changed files
with
245 additions
and
8 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,236 @@ | ||
progs = "$HOME/progs" | ||
icons = "$progs/utils/icons" | ||
opt = "-fn -adobe-helvetica-bold-r-normal-*-25-180-100-100-p-138-iso8859-1" | ||
|
||
def mymenu(args) { | ||
return @(dmenu $opt -i $args) | ||
} | ||
|
||
# alias mymenu = "dmenu $opt -i" | ||
# alias dpass = "dmenu $opt -nf \"black\" -nb \"black\" <&-" | ||
|
||
temu = "lxterminal" | ||
|
||
def debug(args) { | ||
@(notify-send -i "$icons/debug.png" "Debug" "args[0]" -t 2500) | ||
} | ||
|
||
def perr(args) { | ||
@(printf "%s\n" "$args" >&2;) | ||
} | ||
|
||
|
||
def check_narg(one, two) { | ||
if (one > two) { | ||
perr("error: Wrong number of arguments!") | ||
return 1 | ||
} | ||
} | ||
|
||
|
||
def dprompt(txt, cmd) { | ||
if (@(printf "No\nYes" | mymenu -p $txt) == "Yes") { | ||
@(cmd) | ||
} | ||
} | ||
|
||
|
||
def notify(head, msg, icon) { | ||
if (len(icon) > 0) { | ||
@(notify-send -i $icons/$icon $head $msg -t 1500) | ||
} else { | ||
@(notify-send $head $msg -t 1500) | ||
} | ||
} | ||
|
||
def extract_music() { | ||
for (zipfile in @("/tmp/*.zip") { | ||
local outpath = "/home/istvan/Zenék/@(basename $zipfile .zip)" | ||
notify("Extracting file", $zipfile) | ||
@(unzip $zipfile -d $outpath) | ||
} | ||
} | ||
|
||
|
||
def last_field() { | ||
return @(awk -F '/' '{print $NF}') | ||
} | ||
|
||
|
||
def playlists() { | ||
local path = "/home/istvan/Zenék/playlists" | ||
|
||
local sel = @(ls -1 $path/* | last_field | \ | ||
mymenu("-p", "Select music:") | ||
|
||
if (len(sel) > 0) { | ||
local path = "$path/$sel" | ||
notify("Playing music", $sel, "music_note.png") | ||
@(parole $path &) | ||
} | ||
} | ||
|
||
|
||
# workspace() { | ||
# check_narg $# "2" | ||
# | ||
# local name="$1" | ||
# local path="$2" | ||
# | ||
# tmux start-server | ||
# | ||
# echo "$name $(tmux ls)" | ||
# local bool="$(in_str "$name" "$(tmux ls)")" | ||
# echo "$bool" | ||
# | ||
# if [ "$bool" = "false" ]; then | ||
# notify "tmux" "Starting session $name" | ||
# tmux new-session -d -t "$name" | ||
# tmux send-keys "cd $path" C-m | ||
# tmux split-window -h -c "$path" | ||
# tmux select-pane -t 2 | ||
# tmux send-keys "mc" C-m | ||
# tmux split-window -v -c "$path" | ||
# tmux select-pane -t 1 | ||
# fi | ||
# | ||
# $temu -e "tmux attach-session -d -t \"$name\"" | ||
# | ||
# } | ||
|
||
# work() { | ||
# local sel="$(dselect "$repos" "Select repo:")" | ||
# local path="$(mget "$sel" "$repos")" | ||
# | ||
# workspace "$sel" "$path" | ||
# } | ||
|
||
|
||
# mc() { | ||
# local sel="$(ls -d -1 $HOME/*/ | \ | ||
# awk -F '/' '{print $(NF - 1)}' | \ | ||
# mymenu -p "Select directory:")" | ||
# | ||
# if [ -n "$sel" ]; then | ||
# local path="$HOME/$sel" | ||
# notify "Started Midnight Commander." "$path" "mc.png" | ||
# $temu -e "mc $path" | ||
# fi | ||
# } | ||
|
||
|
||
# ssh() { | ||
# local select=$(printf "robosztus\nzafir\n" | mymenu -p "Select server") | ||
# | ||
# local header="Connecting to remote machine." | ||
# | ||
# case $select in | ||
# "robosztus") | ||
# notify "$header" "istvan@robosztus.ggki.hu" "ssh.png" | ||
# $temu -e 'ssh -Y istvan@robosztus.ggki.hu' | ||
# ;; | ||
# "zafir") | ||
# notify "$header" "istvan@zafir.ggki.hu" "ssh.png" | ||
# $temu -e 'ssh -Y istvan@zafir.ggki.hu' | ||
# ;; | ||
# *) | ||
# printf "Unknown option: %s!\n" $select | ||
# esac | ||
# } | ||
|
||
# shutdown_now() { | ||
# notify-send "Did you push all git repositories?" \ | ||
# "Check git repositories!" -u "critical" -i "$icons/warning.png" | ||
# dprompt "Shutdown?" "shutdown -h now" | ||
# } | ||
|
||
|
||
# gamma() { | ||
# local path="/home/istvan/Dokumentumok/gamma_doc" | ||
# | ||
# local sel=$(ls -1 $path/*.html | last_field | \ | ||
# mymenu -p "Select program:" -l 10) | ||
# | ||
# if [ -n "$sel" ]; then | ||
# local path="$path/$sel" | ||
# notify "Opening documentation" "${sel}" "music_note.png" | ||
# chromium-browser "${path}" | ||
# fi | ||
# } | ||
|
||
# modules=" | ||
# playlists | ||
# git | ||
# mc | ||
# ssh | ||
# repos_all | ||
# extract_music | ||
# work | ||
# gamma | ||
# " | ||
# | ||
# | ||
# select_module() { | ||
# local log="$HOME/menu.log" | ||
# local sel=$(printf "%s\n" $modules | mymenu -p "Select from modules:") | ||
# | ||
# for module in $(printf "%s\n" $modules); do | ||
# case $sel in | ||
# $module) | ||
# $module > $log | ||
# ;; | ||
# *) | ||
# ;; | ||
# esac | ||
# done | ||
# } | ||
# | ||
# Basename() { | ||
# while IFS= read -r line; do | ||
# printf '%s\n' "$(basename $line .png)" | ||
# done | ||
# } | ||
# | ||
# import() { | ||
# local root="${HOME}/screencap" | ||
# mkdir -p "${root}" | ||
# | ||
# last="$(ls ${root}/img_*.png \ | ||
# | Basename \ | ||
# | tr -d '[:alpha:]' \ | ||
# | tr -d '_' \ | ||
# | sort -g \ | ||
# | tail -1)" | ||
# | ||
# new=$((last+1)) | ||
# | ||
# import "${root}/img_${new}.png" > "${HOME}/import.log" | ||
# } | ||
# | ||
# main() { | ||
# check_narg $# 1 | ||
# | ||
# case $1 in | ||
# "programs") | ||
# dmenu_run $opt | ||
# ;; | ||
# "modules") | ||
# select_module | ||
# ;; | ||
# "markdown") | ||
# markdown $2 | ||
# ;; | ||
# "shutdown") | ||
# shutdown_now | ||
# ;; | ||
# "import") | ||
# import | ||
# ;; | ||
# *) | ||
# printf "Unrecognized option %s!\n" $1 >&2 | ||
# return 1 | ||
# ;; | ||
# esac | ||
# } | ||
# | ||
# main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters