简单的命令行工具,在目标程序完成工作后发出通知
nf的Python项目详细描述
简言之
nf是一个工具,用于通知用户其命令完成工作。例如,“make”程序需要很长时间才能完成。在
SPDX许可证标识符:0BSD
项目名称:nf 许可证:0BSD/免费公共许可证1.0.0 有关许可证的详细信息:https://opensource.org/licenses/0BSD
变更日志
- 来自1.3.2:
- –将run命令的detach作为分离的进程(stdout仍然相同,但进程的父进程依赖于系统)
- –等待pids等待一个或多个进程,然后运行cmd
- 添加新后端:win10toast persist
- 修复后端优先权赢
- 修复某些Linux配置上的“null”dbus接口
- 检测WSL(Win),但还不支持它
不安装
它是一个文件脚本,因此您可以下载和使用它。 您也可以从没有任何依赖关系的源代码中运行它*(只需要python,也许还需要一些附带的模块)
*-Windows需要一些模块才能工作,请参阅设置.py了解详情。在2020-03-08,它们是:python-m install psutil win10toast persist
最新开发版本:
wget -c https://github.com/NIC-MichalLabedzki/nf/raw/master/nf.py
或者
^{pr2}$或者把链接放到你的浏览器里
https://github.com/NIC-MichalLabedzki/nf/raw/master/nf.py
或者
git clone git@github.com:NIC-MichalLabedzki/nf.git
python ./nf.py
参见:
python ./nf.py --help
有关更多详细信息,请参阅CLI部分。在
以前的稳定版本:
wget -c https://github.com/NIC-MichalLabedzki/nf/raw/v1.4.0/nf.py wget -c https://github.com/NIC-MichalLabedzki/nf/raw/v1.3.2/nf.py wget -c https://github.com/NIC-MichalLabedzki/nf/raw/v1.2.0/nf.py wget -c https://github.com/NIC-MichalLabedzki/nf/raw/v1.1.1/nf.py wget -c https://github.com/NIC-MichalLabedzki/nf/raw/v1.0.1/nf.py
安装
python -m pip install nf
或者
python -m pip install nf --user
或者
python -m pip install nf --user --proxy=YOUR.PROXY.IP.v4:YOUR_PORT
或者
python -m pip install -e git+https://github.com/NIC-MichalLabedzki/nf.git#egg=master
或者
git clone https://github.com/NIC-MichalLabedzki/nf.git cd nf python setup.py # or python -m pip install -e .
或者
git clone git@github.com:NIC-MichalLabedzki/nf.git cd nf python setup.py # or python -m pip install -e .
要更新:
python -m pip install nf -U
接口
有一种接口:CLI。在
如果您认为需要lib/module,请告诉我原因。 也许这是有原因的。在
CLI
CLI是命令行界面。所以你有一个叫做:nf的工具
$ python nf.py --help usage: nf.py [-h][-l LABEL][-p][-n][-s][-w WAIT_FOR_PID][--detach][-b {paramiko,ssh,dbus,gdbus,notify-send,termux-notification,win10toast-persist,win10toast,plyer,plyer_toast,stdout}][-v][-d][--debugfile DEBUGFILE][--custom_notification_text CUSTOM_NOTIFICATION_TEXT][--custom_notification_title CUSTOM_NOTIFICATION_TITLE][--custom_notification_exit_code CUSTOM_NOTIFICATION_EXIT_CODE] cmd ... Simple command line tool to make notification after target program finished work positional arguments: cmd args optional arguments: -h, --help show this help message and exit -l LABEL, --label LABEL Add humn readable text to custom job identification -p, --print Print notification text in stdout too -n, --no-notify Do not do annoying notifications -s, --save Save/append command and stat to .nf file -w WAIT_FOR_PID, --wait-for-pid WAIT_FOR_PID Wait for PID aka waitfor already run process finish work. This option can be used multiple times. --detach Run command or waitfor pid in detached process -b {paramiko,ssh,dbus,gdbus,notify-send,termux-notification,win10toast-persist,win10toast,plyer,plyer_toast,stdout}, --backend {paramiko,ssh,dbus,gdbus,notify-send,termux-notification,win10toast-persist,win10toast,plyer,plyer_toast,stdout} Notification backend -v, --version Print version -d, --debug More print debugging on stdout --debugfile DEBUGFILE More print debugging save into file --custom_notification_text CUSTOM_NOTIFICATION_TEXT Custom notification text --custom_notification_title CUSTOM_NOTIFICATION_TITLE Custom notification title --custom_notification_exit_code CUSTOM_NOTIFICATION_EXIT_CODE Custom notification exit code Examples: nf make nf ls nf ls not_exist_file nf sleep 2 nf -l sleeping sleep 2 nf -l `tty` ls nf "ls | grep .py" nf --detach sleep 15 nf -w 55555 ls nf -w 55555 --detach echo Finished nf -w 55555 -w 55556echo Done "/home/nic/src/nf$ nf.py -p ls LICENSE nf.py pytest.ini README README.dev requirements-dev.txt setup.cfg setup.py tox.ini ----------------------------------------------------------- "/home/nic/src/nf$ ls" finished work. Start time: 17:32.50 End time: 17:32.50 Elapsed time: 00:00.00 -----------------------------------------------------------
局限性
- 使用Jython:它没有dbus模块,回退到命令行。在
- 在KDE中观察到:可以删除具有相同正文(文本)的通知。为了避免这种情况,我添加了时间戳文本以使nofittations唯一。在
特点
- 通过termux通知支持Android通知(当然是通过termux)
- 通过python模块或回退到notify send(libnotify0.7.7或0.7.8的一部分)
- 在stdout上打印通知的选项。在
- 选项将完整的命令行和stat保存到工作目录中。在
- 支持整个python实现/版本(至少不会崩溃并在stdout上打印)
- Case SSH:如果您使用SSH,则通过向后SSH连接将通知发送到您的本机系统(强制密码)
- 支持的通知后端:paramiko(ssh)、ssh、dbus、notify send、termux notification(Android)、win10toast(Windows)、plyer、plyer_toast、stdout
- 标签中的yakuake/konsole终端标签名称
- 屏幕/tmux会话/window/pane title/name in label
- Python模块aka库接口“导入nf;纳滤(['ls')”
nf使用的TMUX/SCREEN或如何测试它
1。tmux会话名称: .. bash::块代码
tmux rename-session sesja tmux list-sessions -F “#{session_name}”
2。tmux窗口名称: .. 代码块::bash
tmux rename-window okno tmux list-window -F “#{window_name} #{window_active}”
3。tmux窗格名称: .. 代码块::bash
printf ‘033]2;%s033' ‘this is a title’ tmux list-pane -F “#{pane_title} #{pane_active}”
4。获取父级的客户端pid(例如:yakuake) .. 代码块::bash
tmux display-message -p “#{client_pid}”
5。屏幕会话: .. 代码块::bash在
screen -list There are screens on: 7842.pts-30.nic (Attached) 6981.pts-25.nic (Attached) 2 Sockets in /tmp/screens/S-nic.
6。屏幕窗口标题 .. bash::块代码
screen -S 6981.pts-25.nic -Q title terefere
7。屏幕窗口: .. bash::块代码
screen -S 6981.pts-25.nic -Q windows 0* terefere 1 bash 2 bash 3- bash
托多
- –try version=1.3.2-下载(需要互联网连接),放在主目录中并使用它而不是安装的版本
- –try version=dev-要测试的最新git版本
- $HOME/.nf目录和“versions”子目录到下载的版本
- WSL支持
- 项目
标签: