6 个版本
0.2.1 | 2022 年 5 月 5 日 |
---|---|
0.2.0 | 2022 年 1 月 29 日 |
0.1.10 | 2022 年 1 月 21 日 |
0.1.8 | 2021 年 11 月 22 日 |
1920 在 命令行工具
每月 25 次下载
77KB
1.5K SLoC
automat-termo-status
借助可见 Wi-Fi SSID 自动化 Mattermost 自定义状态。
开发网站托管在 gitlab 上。
发布二进制文件可在 此页面 获取。
用法
以下是命令行帮助信息。
automattermostatus 0.2.1
Automate mattermost status with the help of wifi network
Use current visible wifi SSID to automate your mattermost status. This program is meant to either be running in
background or be call regularly with option `--delay 0`. It will then update your mattermost custom status according to
the config file
USAGE:
automattermostatus [FLAGS] [OPTIONS]
FLAGS:
-h, --help
Prints help information
-q, --quiet
Decrease the output's verbosity level.
Used once, it will set error log level. Used twice, will silent the log completely
-v, --verbose
Increase the output's verbosity level
Pass many times to increase verbosity level, up to 3.
-V, --version
Prints version information
OPTIONS:
-b, --begin <begin hh:mm>
beginning of status update with the format hh:mm
Before this time the status won't be updated [env: BEGIN=]
--state-dir <cache dir>
directory for state file
Will use content of XDG_CACHE_HOME if unset. [env: STATE_DIR=]
--mm-secret-cmd <command>
mattermost secret command
The secret is either a `password` (default) or a`token` according to `secret_type` option [env:
MM_SECRET_CMD=]
--delay <delay>
delay between wifi SSID polling in seconds [env: DELAY=]
-e, --end <end hh:mm>
end of status update with the format hh:mm
After this time the status won't be updated [env: END=]
--expires-at <expiry hh:mm>
Expiration time with the format hh:mm
This parameter is used to set the custom status expiration time Set to "0" to avoid setting expiration time
[env: EXPIRES_AT=]
-i, --interface-name <itf_name>
wifi interface name [env: INTERFACE_NAME=]
-t, --secret-type <secret-type>
Type of secret. Either `Password` (default) or `Token` [env: SECRET_TYPE=] [possible values: Token,
Password]
--mm-secret <token>
mattermost private Token
Usage of this option may leak your personal token. It is recommended to use `mm_token_cmd` or
`keyring_service`.
The secret is either a `password` (default) or a`token` according to `secret_type` option [env: MM_SECRET]
--keyring-service <token service name>
Service name used for mattermost secret lookup in OS keyring.
The secret is either a `password` (default) or a`token` according to `secret_type` option [env:
KEYRING_SERVICE=]
-u, --mm-url <url>
mattermost URL [env: MM_URL=]
--mm-user <username>
User name used for mattermost login or for password or private token lookup in OS keyring [env: MM_USER=]
-s, --status <wifi_substr::emoji::text>...
Status configuration triplets (:: separated)
Each triplet shall have the format: "wifi_substring::emoji_name::status_text". If `wifi_substring` is empty,
the ssociated status will be used for off time.
配置
Automattermostatus 从配置文件和命令行(后者覆盖前者)获取配置。
配置文件
如果不存在,则会创建配置文件。根据您的操作系统,它将在以下位置创建或读取:
- Linux 上的 XDG 用户目录 规范(通常为
~/.config/automattermostatus/automattermostatus.toml
), - Windows 上的 已知文件夹系统(通常为
{FOLDERID_RoamingAppData}\ams\automattermostatus\config
), - macOS 上的 标准目录(通常为
$HOME/Library/Application Support/net.ams.automattermost
)。
以下是一个示例配置文件:
# Automattermostatus example configuration
#
# Wifi interface name. Use to check that wifi is enabled (Mac and Windows)
interface_name = 'wlp0s20f3'
# Status string containing 3 fields separated by `::`
# - First field is the wifi substring that should be contained in a visible SSID
# for this status to be set. If empty the associated status wil be used for
# off times.
# - Second field is the emoji string for the custom status.
# - Third field is the description text foir the custom status.
#
status = ["corporatewifi::corplogo::On premise work",
"homenet::house::Working home",
"::sleeping::Off time"]
# Base url of the mattermost instanbce
mm_url = 'https://mattermost.example.com'
# Level of verbosity among Off, Error, Warn, Info, Debug, Trace
verbose = 'Info'
# The type of the secret given by `mm_secret`, `mm_secret_cmd` or `kering_*`
# parameters. Either:
# secret_type = "Token" # for using a private acces token
# secret_type = "Password" # for using login and password credentials where
# the login is given by `mm_user`
secret_type = "Token"
# mattermost authentication secret. It is recommended to use `mm_secret_cmd` or
# better the OS keyring with `keyring_user` and `keyring_service`.
# mm_secret= 'cieVee1Ohgeixaevo0Oiquiu'
# Command that should be executed to get mattermost authentication secret (the
# secret shall be printed on stdout). See
# https://docs.mattermost.com/integrations/cloud-personal-access-secrets.html#creating-a-personal-access-secret.
# It is recommended to use the OS keyring with `keyring_service`.
# mm_secret_cmd = "secret-tool lookup name automattermostatus"
# *service* name used to query OS keyring in order to retrieve your
# mattermost private access secret. The user used to query the keyring is
# `mm_user`
keyring_service = 'mattermost_secret'
# set expiry time for custom mattermost status
expires_at = "19:30"
# set begin and end time of the working period. Outside of this period, custom
# status won't be set.
begin = "8:00"
end = "19:30"
# Definition of the day off (when automattermostatus do not update the user
# custom status). If a day is no present then it is considered as a workday.
# The attributes may be:
# - `EveryWeek`: the day is always off
# - `EvenWeek`: the day is off on even week (iso week number)
# - `OddWeek`: the day is off on odd week (iso week number)
[offdays]
Sat = 'EveryWeek'
Sun = 'EveryWeek'
Wed = 'EvenWeek'
Mattermost 认证密钥
用于认证 Mattermost 实例的密钥可以是 私有访问令牌 或与您的用户名关联的密码(请参阅 secret_type
配置参数)。
使用您的私有访问令牌的优点是,即使您设置了多因素认证,它也能正常工作。缺点是您的账户必须由 Mattermost 实例管理员明确授权才能使用 私有访问令牌。
如果您的账户启用了私有令牌,则可以在“账户参数 > 安全 > 个人访问令牌
”下找到它。您应避免使用mm_secret
参数,因为这可能会将您的令牌泄露给可以访问您电脑的其他人。建议使用mm_secret_cmd
选项或更好的是使用带有mm_user
和keyring_service
参数的本地操作系统密钥环。
例如,在Linux上,您可能可以使用secret-tool
# store your token (it will ask you the token)
secret-tool store --label='token' name automattermostatus
# use the following command in `mm_token_cmd` to retrieve your token:
secret-tool lookup name automattermostatus
或keyring
命令
# store your token (it will ask you the token)
keyring set mattermost_token mattermost_username
# use the following configuration
secret_type = "Token"
mm_user = 'username'
keyring_service = 'mattermost_token'
在Mac OS上,您可以使用密钥链来存储Mattermost访问令牌,并且它将在配置类似于以下配置的情况下由automattermostatus查找。
在Windows上,我没有测试的方法,但看起来您可能可以使用基于Microsoft凭证保管库的任何软件来存储您的Mattermost访问令牌。
依赖关系
在Linux上,automattermostatus依赖于NetworkManager
以获取无需root权限的可见SSID。
安装
您可以选择自行编译,从发布页面下载最新二进制文件,或安装可用的包。
Arch Linux
使用您喜欢的aur辅助工具。例如
yay -S automattermostatus
编译
您可以使用以下方法构建automattermostatus
二进制文件
cargo build --release --locked
然后可以在target/release
目录中找到二进制文件。
在启动时启动
Linux
您可以将distrib/automattermostatus.desktop
复制到/etc/xdg/autostart
或$HOME/.config/autostart
中,或者如果您使用systemd,则可以将auttoolmostatus systemd unit distrib/automattermostatus.service
复制到$HOME/.config/systemd/user
中,并执行
systemctl status --user enable --now automattermostatus
然后可以通过以下方式查看日志
journalctl --user -u automattermostatus
Windows
待办事项
Mac OS
待办事项
许可证
根据Apache License,版本2.0许可(LICENSE-APACHE)。
贡献
除非您明确声明,否则根据Apache-2.0许可证定义的,您有意提交以包含在作品中的任何贡献,将按照上述方式许可,不附加任何额外的条款或条件。
问题
您可以在gitlab问题页面上打开问题或功能请求。
补丁或功能
您可以在gitlab上分叉项目,在新分支上开发您的补丁或功能,然后将更改推送到您分叉的仓库后提交新的合并请求。
不要犹豫,提前打开一个问题来讨论错误修复策略或询问您想象的特性。
依赖关系
~13–26MB
~389K SLoC