Compare commits

...

7 Commits

Author SHA1 Message Date
bf5ee3437d
WIP new github-releases 2024-05-12 10:26:24 +02:00
7e64148005
🔤 updated KDE Plasma 6 fixes 2024-05-12 10:25:03 +02:00
219caa08af
vim+coc+ultisnips 2024-05-12 10:24:34 +02:00
a7dd1a8521
🔤 newsboat 2024-05-12 10:23:25 +02:00
ee94361f1a
🐛 better fzf/compose jaaENV
- `§ck-grep`: find combination for symbol
- `fzf`: typo
- `jaaENV`: switch java support and enhancements
2024-05-12 10:21:19 +02:00
f02723bdc6
🐛 ai commit (correct regular/conventional) 2024-05-12 10:19:02 +02:00
352632e5a5
use wikimedia Potd as HTML wallpaper
[Commons:Picture of the day - Wikimedia Commons](https://commons.wikimedia.org/wiki/Commons:Picture_of_the_day)
2024-05-12 10:16:48 +02:00
18 changed files with 686 additions and 45 deletions

View File

@ -89,6 +89,7 @@ alias §psmem='§psmem_all | head -n 10'
alias §pscpu_all='ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu'
alias §pscpu='§pscpu_all | head -n 10'
alias §psnet_all='lsof -P -i -n'
alias §ck-grep='cat /usr/share/X11/locale/en_US.UTF-8/Compose ~/.XCompose | grep -i'
§ping-test(){ # Pings ip address of noip.com and www.google.com.
ping -c 1 -q 8.23.224.107 | grep --color=never -A 1 -i '\---'
@ -116,7 +117,8 @@ alias npx-wca='npx -y web-component-analyzer'
alias npx-qnm='npx -y qnm'
alias npx-hint='npx -y hint'
alias npx-markdown='nohup npx markserv'
alias zfz=fzf-carroarmato0.fzf
alias fzf=fzf-carroarmato0.fzf
§url-curl(){ curl --silent -I "$1" | grep -i location; }

View File

@ -13,6 +13,7 @@ alias C--uu='eval "$($HOME/bin/uu --completion-bash)"'
alias C--bs='eval "$(bs .completion bash)"'
alias C--jc='eval "$(jc -B)" … newer version needed'
\. "$BASH_DOTFILES/cordova.completion"
\. "$BASH_DOTFILES/install-release.completion"
eval "$(node --completion-bash)"
eval "$(npm completion)"
eval "$(nodejsscript --completion bash)"

View File

@ -38,17 +38,21 @@ function jaaENV {
do
case "$1" in
nodejs|node)
local nodejs_version=`node --version`
local nodejs_version=$(node --version)
echo "nodejs=${nodejs_version:1}" >> .jaaENV
;;
gradle)
local gradle_version=`gradle --version | head -n 3 | tail -n 1 | §awk 2`
local gradle_version=$(gradle --version | head -n 3 | tail -n 1 | §awk 2)
echo "gradle=$gradle_version" >> .jaaENV
;;
php)
local php_version=`php --version | head -n 1 | §awk 2`
local php_version=$(php --version | head -n 1 | §awk 2)
echo "php=$php_version" >> .jaaENV
;;
java)
local java_version=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2 | cut -d'.' -f1)
echo "java=$java_version" >> .jaaENV
;;
*)
echo "unknown '$1' skipped"
;;
@ -73,6 +77,22 @@ function jaaENV {
else
. ./.jaaENV
fi
if [ ! -z ${java+x} ]; then
[[ "$java" == "8" ]] && java=1.8
local java_local=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2)
if [[ "$java_local" != "$java"* ]]; then
[[ "$java" == "1.8" ]] && java=8
echo "java $java$java_local"
local v="/usr/lib/jvm/java-$java-openjdk-amd64/"
[[ "$java" == "8" ]] && local vv="jre/" || local vv=""
sudo update-alternatives --set java ${v}${vv}bin/java
local javac=$(update-alternatives --list javac | grep java-$java)
[ $javac ] && sudo update-alternatives --set javac $javac
sudo -k
fi
export JAVA_HOME=$(update-alternatives --display java | grep momentálně | §awk 5 | cut -d \/ -f1-5)/
echo \$JAVA_HOME=$JAVA_HOME
fi
if [ ! -z ${android_home+x} ]; then export ANDROID_HOME=$ANDROID_HOME_BAK; echo "\$ANDROID_HOME=$ANDROID_HOME"; else unset ANDROID_HOME; echo "\$ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"; fi
if [ ! -z ${android_home_is_sdk+x} ]; then export ANDROID_HOME=$ANDROID_SDK_ROOT; echo "\$ANDROID_HOME=$ANDROID_HOME"; fi
if [ ! -z ${jdk+x} ]; then
@ -87,7 +107,7 @@ function jaaENV {
if [ ! -z ${nodejs+x} ]; then nvm use $nodejs; fi
if [ ! -z ${gradle+x} ]; then sdk use gradle $gradle | tr -d '\n'; echo ; fi
if [ ! -z ${php+x} ]; then
local php_local=`php --version | head -n 1 | §awk 2`
local php_local=$(php --version | head -n 1 | §awk 2)
if [[ "$php_local" == "$php"* ]]; then
echo "php $php"
else
@ -100,4 +120,5 @@ function jaaENV {
unset nodejs
unset gradle
unset php
unset java
}

View File

@ -0,0 +1,10 @@
_install_release_completion() {
local IFS=$'
'
COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
COMP_CWORD=$COMP_CWORD \
_INSTALL_RELEASE_COMPLETE=complete_bash $1 ) )
return 0
}
complete -o default -F _install_release_completion install-release

View File

@ -0,0 +1 @@
extends javascript

View File

@ -1,10 +1,4 @@
extends php, html
extends php, html
extends php, html
extends php, html
extends php, html
extends php, html
extends php, html
#endextends
snippet sceleton "HTML5" b
@ -2369,4 +2363,4 @@ snippet csp_cordova "CSP used in cordova"
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; img-src 'self' data: android-webview-video-poster:; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
endsnippet
#endextends
#endextends

View File

@ -0,0 +1 @@
extends javascript

View File

@ -0,0 +1 @@
extends javascript

View File

@ -0,0 +1,245 @@
{
"target": "/home/jaandrle/bin/",
"packages": [
{
"repository": "shiftkey/desktop",
"name": "GitHub Desktop",
"group": "dev",
"file_name": "github-desktop",
"exec": "yes",
"description": "Fork of GitHub Desktop to support various Linux distributions",
"last_update": "2024-03-31T17:49:36Z",
"downloads": "/home/jaandrle/bin/github-desktop",
"version": "release-3.3.12-linux2",
"glare": ".*x86_64.*.AppImage"
},
{
"repository": "jaandrle/jaaCSS-cli",
"name": "jaaCSS",
"description": "EXPERIMENT Helper for managing functional CSS classes",
"group": "dev",
"file_name": "jaaCSS.js",
"exec": "yes",
"downloads": "/home/jaandrle/bin/jaaCSS.js",
"version": "v1.3.2",
"last_update": "2022-09-02T13:33:16Z",
"glare": "jaaCSS.js"
},
{
"repository": "th-ch/youtube-music",
"name": "youtube-music",
"description": "YouTube Music Desktop App bundled with custom plugins (and built-in ad blocker / downloader)",
"group": "nondev",
"file_name": "youtube-music",
"exec": "yes",
"last_update": "2024-04-13T14:34:34Z",
"downloads": "/home/jaandrle/bin/youtube-music",
"version": "v3.3.6",
"glare": "AppImage"
},
{
"repository": "ArchGPT/insomnium",
"name": "insomnium",
"description": "Insomnium is a fast local API testing tool that is privacy-focused and 100% local. For testing GraphQL, REST, WebSockets and gRPC. This is a fork of Kong/insomnia",
"group": "dev",
"file_name": "insomnium",
"exec": "yes",
"last_update": "2023-11-13T10:03:28Z",
"downloads": "/home/jaandrle/bin/insomnium",
"tag_name_regex": "core@.*",
"version": "core@0.2.3-a",
"glare": "AppImage"
},
{
"repository": "Kong/insomnia",
"name": "insomnia",
"description": "The open-source, cross-platform API client for GraphQL, REST, and gRPC.",
"group": "skip",
"file_name": "insomnia",
"exec": "yes",
"last_update": "2024-04-17T16:38:03Z",
"downloads": "/home/jaandrle/bin/insomnia",
"tag_name_regex": "core@.*",
"version": "core@9.0.0-beta.4",
"glare": "AppImage"
},
{
"repository": "rvpanoz/luna",
"name": "luna",
"description": "Manage npm dependencies through a modern UI.",
"group": "skip",
"file_name": "luna",
"exec": "yes",
"glare": "AppImage"
},
{
"repository": "angela-d/wifi-channel-watcher",
"name": "wifi-channel-watcher",
"group": "skip",
"file_name": "wifi-channel-watcher",
"exec": "no",
"description": "Monitor channel usage of neighboring routers & get an alert if your active channel is not optimal.\tTroubleshoot wifi without lifting a finger!"
},
{
"repository": "vinceliuice/Tela-circle-icon-theme",
"name": "Tela-circle-icon-theme",
"description": "Tela-circle-icon-theme",
"group": "skip",
"file_name": "tela-circle-icon-theme.zip",
"last_update": "2021-07-19T14:12:05Z",
"exec": "no"
},
{
"repository": "AppImage/AppImageKit",
"name": "AppImageKit",
"group": "skip",
"file_name": "appimagekit",
"exec": "yes",
"description": "Package desktop applications as AppImages that run on common Linux-based operating systems, such as RHEL, CentOS, openSUSE, SLED, Ubuntu, Fedora, debian and derivatives. Join #AppImage on irc.freenode.net",
"glare": ".*x86_64.*.AppImage"
},
{
"repository": "dynobo/normcap",
"name": "NormCap",
"description": "Switched to flatpak version | OCR powered screen-capture tool to capture information instead of images",
"group": "skip",
"file_name": "normcap",
"exec": "yes",
"last_update": "2023-12-12T22:23:37Z",
"downloads": "/home/jaandrle/bin/normcap",
"version": "v0.5.2"
},
{
"repository": "upscayl/upscayl",
"name": "upscayl",
"description": "🆙 Upscayl - Free and Open Source AI Image Upscaler for Linux, MacOS and Windows built with Linux-First philosophy.",
"group": "nondev",
"file_name": "upscayl",
"exec": "yes",
"last_update": "2024-04-25T04:29:38Z",
"downloads": "/home/jaandrle/bin/upscayl",
"version": "v2.11.0",
"glare": "AppImage"
},
{
"repository": "RasmusLindroth/tut",
"name": "tut",
"description": "TUI for Mastodon with vim inspired keys",
"group": "nondev",
"file_name": "tut",
"exec": "yes",
"last_update": "2023-01-26T17:48:00Z",
"downloads": "/home/jaandrle/bin/tut",
"version": "2.0.1",
"glare": "tut-amd64"
},
{
"repository": "sunner/ChatALL",
"name": "ChatALL",
"description": " Concurrently chat with ChatGPT, Bing Chat, bard, Alpaca, Vincuna, Claude, ChatGLM, MOSS, iFlytek Spark, ERNIE and more, discover the best answers",
"group": "skip",
"file_name": "chatall",
"exec": "yes",
"last_update": "2024-04-14T02:09:42Z",
"downloads": "/home/jaandrle/bin/chatall",
"version": "v1.71.100",
"glare": ".*x86_64.*.AppImage"
},
{
"repository": "jaandrle/bs",
"name": "bs",
"description": "The simplest possible build system using executables",
"group": "dev",
"file_name": "bs",
"exec": "yes",
"last_update": "2024-03-28T13:16:41Z",
"downloads": "/home/jaandrle/bin/bs",
"version": "v0.7.4",
"glare": "bs-linux"
},
{
"repository": "h3poteto/fedistar",
"name": "Fedistar",
"description": "Multi-column Mastodon, Pleroma, and Friendica client for desktop",
"group": "nondev",
"file_name": "fedistar",
"exec": "yes",
"last_update": "2024-04-09T14:08:12Z",
"downloads": "/home/jaandrle/bin/fedistar",
"version": "v1.9.3",
"glare": ".*amd64.*.AppImage"
},
{
"repository": "ollama/ollama",
"name": "ollama",
"description": "Get up and running with Llama 2 and other large language models locally",
"group": "ai",
"file_name": "ollama",
"exec": "yes",
"last_update": "2024-04-28T17:51:17Z",
"downloads": "/home/jaandrle/bin/ollama",
"version": "v0.1.33-rc5",
"glare": "linux-amd64"
},
{
"repository": "neovim/neovim",
"name": "neovim",
"tag_name_regex": "v.*",
"description": "Vim-fork focused on extensibility and usability",
"group": "skip",
"file_name": "nvim",
"exec": "yes",
"downloads": "/home/jaandrle/bin/nvim",
"version": "v0.9.5",
"last_update": "2023-12-30T13:31:47Z"
},
{
"repository": "viarotel-org/escrcpy",
"name": "Escrcpy",
"description": "📱 Graphical Scrcpy to display and control Android, devices powered by Electron. | 使用图形化的 Scrcpy 显示和控制您的 Android 设备,由 Electron 驱动。",
"group": "dev",
"file_name": "escrcpy",
"exec": "yes",
"last_update": "2024-04-28T02:36:35Z",
"downloads": "/home/jaandrle/bin/escrcpy",
"version": "v1.18.3",
"glare": ".*x86_64.*.AppImage"
},
{
"repository": "drovp/drovp",
"name": "drovp",
"description": "Desktop app for encoding, converting, upscaling, and much more.",
"group": "dev-test",
"file_name": "drovp",
"exec": "yes",
"last_update": "2023-12-06T11:30:02Z",
"downloads": "/home/jaandrle/bin/drovp",
"version": "0.8.0",
"glare": "x64.AppImage"
},
{
"repository": "janhq/jan",
"name": "Jan",
"description": "Jan is an open source alternative to ChatGPT that runs 100% offline on your computer",
"group": "ai",
"file_name": "jan",
"exec": "yes",
"last_update": "2024-04-25T06:07:39Z",
"downloads": "/home/jaandrle/bin/jan",
"version": "v0.4.12",
"glare": ".*x86_64.*.AppImage"
},
{
"repository": "Bin-Huang/chatbox",
"name": "Chatbox",
"description": "Chatbox is a desktop client for ChatGPT, Claude and other LLMs, available on Windows, Mac, Linux",
"group": "ai",
"file_name": "Chatbox",
"exec": "yes",
"last_update": "2024-04-18T08:15:47Z",
"downloads": "/home/jaandrle/bin/Chatbox",
"version": "v1.3.5",
"glare": ".*x86_64.*.AppImage"
}
]
}

View File

@ -53,6 +53,7 @@ bind-key U show-urls
unbind-key ^B
bind-key m bookmark
# TODO: replace with nocodb
bookmark-cmd "~/bin/pocket-sh-add.sh"
bookmark-autopilot yes

View File

@ -7,8 +7,6 @@ https://www.youtube.com/feeds/videos.xml?channel_id=UCPeHT7xKjaw_-8hHW0GEXLg ! v
https://www.youtube.com/feeds/videos.xml?channel_id=UCD9L1HvpYpmZ8rrXABARCRQ ! video
https://www.youtube.com/feeds/videos.xml?channel_id=UCONH73CdRXUjlh3-DdLGCPw ! video
https://herohero.co/services/functions/rss-feed?token=eyJhbGciOiJSUzI1NiJ9.eyJ1IjoiYWpzbHV6YnlsdXh1dnlueSIsImMiOiJuYXBvdGl0a3V6d3VhdWhvZCIsInQiOjE2ODU2MDk1ODl9.LfJHvtdm4fPq25NCfoC5ZU6cPmZLRjXO2Xhl6fcG78j-8tjatznyBDQdKwKiMfdQMKK9peOkYAKyIXTBvjBBN9XJ9CKoOnAfIyHiBlyo200TWeG3Ll37U8LRN7So4npT4-Qr_FzZGSMYO_ispVL6Gj2HYfwYORq6-1t78v9k5Ke7up-w4aM4-jUXD3_Zdsu70jJV5-fEAM11pgkfh8HydW9vm_MvkZ1q1DSIRlZR8jQNQZgGWeYMjzF9owD00TQGUGsXGNH0lit-IhFX9_VFqG5so5i6ugv8AyCJK7g3B59YV6TsWVANtWN5NB_B3f-TXSE4Cs7tOZrU0riVxI-4Ew ! video
https://www.youtube.com/feeds/videos.xml?channel_id=UCKlOmM_eB0nzTNiDFZibSSA !
"query:Sakitech Note/Update:title =~ \"(Note|Phones|phones)\" and title !~ \"(Wallpaper|wallpaper)\" and rssurl == \"https://www.youtube.com/feeds/videos.xml?channel_id=UCKlOmM_eB0nzTNiDFZibSSA\"" video
"exec:~/.newsboat/html2rss-streamCZ.mjs 'Kokoti na neděli' 'https://www.stream.cz/kokoti-na-nedeli'" ! video
"exec:~/.newsboat/html2rss-streamCZ.mjs 'Šťastné pondělí' 'https://www.stream.cz/stastne-pondeli'" !
"query:Šťastné pondělí:title =~ \"Šťastné pondělí\" and feedtitle == \"Šťastné pondělí\"" video

View File

@ -1,26 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bing Image Of The Day</title>
<style>
body{ display: flex; flex-flow: row nowrap;
width: 100vw; height: 100vh; overflow: hidden; margin: 0;
}
div{ position: relative; flex: 1; }
img{ height: 100%; width: 100%; object-fit: contain; }
.detail{ position: absolute; bottom: 0; left: 0; padding: .5rem 1rem;
text-align: center; background: rgba(0, 0, 0, .35); color: whitesmoke; }
.prev .detail{ left: initial; right: 0; }
@media screen and (max-aspect-ratio: 16/9){
.prev{display: none;}
}
</style>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bing Image Of The Day</title>
<style>
body{ display: flex; flex-flow: row nowrap;
width: 100vw; height: 100vh; overflow: hidden; margin: 0;
}
div{ position: relative; flex: 1; }
img{ height: 100%; width: 100%; object-fit: cover; }
.detail{ position: absolute; bottom: 0; left: 0; padding: .5rem 1rem;
max-width: 35ch;
text-align: center; background: rgba(0, 0, 0, .35); color: whitesmoke; }
.prev .detail{ left: initial; right: 0; }
@media screen and (max-aspect-ratio: 16/9){
.prev{display: none;}
}
</style>
</head>
<body>
<div class="now"> <img src="now.jpg"> <div class="detail">::now::</div> </div>
<div class="prev"> <img src="prev.jpg"> <div class="detail">::prev::</div> </div>
<div class="now"> <img src="now.jpg"> <div class="detail">::now::</div> </div>
<div class="prev"> <img src="prev.jpg"> <div class="detail">::prev::</div> </div>
</body>
</html>

View File

@ -53,6 +53,7 @@ Sekce obsahuje log změn v Tuxedo laptopu s KDE Neon.
- [ ] partially FIXED by update: Wayland go to sleep even the external monitor is connected (HDMI)
- *→ seems to be this issue [438716 Lid close leads to suspend even when external monitor is attached](https://bugs.kde.org/show_bug.cgi?id=438716)*
- needs to keyboard/mouse imput to intterupt the go sleep process
- [x] [PSA: How to re-enable LibreOffice integration in Plasma 6 : r/kde](https://www.reddit.com/r/kde/comments/1b9k755/psa_how_to_reenable_libreoffice_integration_in/)
- [x] FIXED by update: ~desktop exceptionally freeze for less than a second: *investigation → report a bug*~
- [x] FIXED by update: ~logout/poweroff dialog not showing and not working: *investigation → report a bug* … see below~
- [x] krunner not launching → created `/usr/share/dbus-1/services/org.kde.krunner.service` (see below)

View File

@ -7,9 +7,9 @@
"file_name": "github-desktop",
"exec": "yes",
"description": "Fork of GitHub Desktop to support various Linux distributions",
"last_update": "2024-02-04T22:31:22Z",
"last_update": "2024-03-31T17:49:36Z",
"downloads": "/home/jaandrle/bin/github-desktop",
"version": "release-3.3.8-linux2"
"version": "release-3.3.12-linux2"
},
{
"repository": "jaandrle/jaaCSS-cli",
@ -29,9 +29,9 @@
"group": "nondev",
"file_name": "youtube-music",
"exec": "yes",
"last_update": "2024-02-20T12:07:29Z",
"last_update": "2024-03-26T10:58:44Z",
"downloads": "/home/jaandrle/bin/youtube-music",
"version": "v3.3.2"
"version": "v3.3.5"
},
{
"repository": "ArchGPT/insomnium",
@ -141,9 +141,9 @@
"group": "dev",
"file_name": "bs",
"exec": "yes",
"last_update": "2023-06-30T07:48:58Z",
"last_update": "2024-03-28T13:16:41Z",
"downloads": "/home/jaandrle/bin/bs",
"version": "v0.7.3"
"version": "v0.7.4"
},
{
"repository": "h3poteto/fedistar",
@ -152,9 +152,9 @@
"group": "nondev",
"file_name": "fedistar",
"exec": "yes",
"last_update": "2024-02-29T11:08:37Z",
"last_update": "2024-03-29T15:39:36Z",
"downloads": "/home/jaandrle/bin/fedistar",
"version": "v1.9.0"
"version": "v1.9.2"
},
{
"repository": "ollama/ollama",
@ -186,9 +186,9 @@
"group": "dev",
"file_name": "escrcpy",
"exec": "yes",
"last_update": "2024-03-13T03:05:48Z",
"last_update": "2024-03-29T03:30:14Z",
"downloads": "/home/jaandrle/bin/escrcpy",
"version": "v1.17.3"
"version": "v1.17.8"
},
{
"repository": "drovp/drovp",
@ -218,7 +218,21 @@
"description": "Chatbox is a desktop client for ChatGPT, Claude and other LLMs, available on Windows, Mac, Linux",
"group": "ai",
"file_name": "Chatbox",
"exec": "yes"
"exec": "yes",
"last_update": "2024-03-15T15:58:59Z",
"downloads": "/home/jaandrle/bin/Chatbox",
"version": "v1.3.1"
},
{
"repository": "Helium314/HeliBoard",
"name": "HeliBoard",
"description": "Customizable and privacy-conscious open-source keyboard",
"group": "android",
"file_name": "heliboard.apk",
"exec": "no",
"last_update": "2024-03-31T20:11:03Z",
"downloads": "/home/jaandrle/bin/heliboard.apk",
"version": "v1.0"
}
]
}

231
bin/github-releases.mjs Executable file
View File

@ -0,0 +1,231 @@
#!/usr/bin/env nodejsscript
/* jshint esversion: 11,-W097, -W040, module: true, node: true, expr: true, undef: true *//* global echo, $, pipe, s, fetch, cyclicLoop */
// "\x1b[38;2;150;150;150m"
// https://talyian.github.io/ansicolors/
/**
* Represents a package record stored locally
*
* @typedef ConfigPackage
* @type {Object}
* @property {string} repository - Repo in the form `<owner>/<repo>`
* @property {string} name - Name/Identifier
* @property {string} description - A description of the repo/package
* @property {string} file_name - The name of the file as stored locally
* @property {"yes"|"no"} exec - Whether the file is executable
* @property {string} last_update - The date and time of the last update
* @property {string} downloads - The path to the file
* @property {string} version - The version of the file
* @property {string} tag_name_regex - Filter only matching releases
* */
/**
* @typedef Config
* @type {{ packages: ConfigPackage[] }}
* */
/**
* Represents a GitHub release information.
*
* @typedef {Object} GitHubRelease
* @property {number} id - The ID of the GitHub release.
* @property {string} url - The URL of the GitHub release.
* @property {string} assets_url - The URL of the assets associated with the GitHub release.
* @property {string} html_url - The HTML URL of the GitHub release.
* @property {string} tag_name - The tag name of the GitHub release.
* @property {string} published_at - The publication date of the GitHub release.
*/
import { join } from "node:path";
const path_config= $.xdg.config`github-releases`;
const path_config_json= join(path_config, "config.json");
const path_config_lock= join(path_config, "lock");
const path_temp= $.xdg.temp`github-releases.json`;
const url_api= "https://api.github.com/repos/";
const url_download= "https://glare.now.sh/"; // https://github.com/Contextualist/glare
const css= echo.css`
.pkg { color: lightcyan; }
.ok { color: lightgreen; }
.err { color: lightred; }
.skip { color: red; color: gray; }
.spin { display: list-item; list-style: --terminal-spin; }
`;
$.api()
.version("2.0.0")
.describe("Helper for working with “packages” stored in GitHub releases.")
.command("config [mode]", [ "Config (file), use `mode` with these options:",
"- `edit`: opens config file in terminal editor using `$EDITOR` (defaults to vim)",
"- `path`: prints path to config file"
])
.action(async function(mode= "path"){
switch(mode){
case "path": echo(path_config_json); break;
case "edit":
const editor= $.env.EDITOR || "vim";
await s.runA`${editor} ${path_config_json}`.pipe(process.stdout);
break;
default:
echo(`Unknown mode: '${mode}'. See '--help' for details.`);
}
$.exit(0);
})
.command("ls", [ "Lists registered packages",
"Repositories marked with `-` signifies that the package is in the 'skip' group.",
"These are registered by this script but not managed by it (updates, etc).",
"Repositories marked with `+` signify that updates of the package are checked."
])
.option("--group, -G", "Filter by group")
.option("--repository, -R", "Filter by repository")
.action(function(filter){
const config = readConfig();
for(const { repository, version, description, group } of grepPackages(config, filter))
if(group!=="skip")
echo(`+ %c${repository}%c@${version ? version : "—"}: %c${description}`, css.pkg, css.unset, css.skip);
else
echo(`- %c${repository}: ${description}`, css.skip);
$.exit(0);
})
.command("check", "Shows/checks updates for registered packages")
.option("--group, -G", "Filter by group")
.option("--repository, -R", "Filter by repository")
.option("--cache", "Use cache [yes, no]", "yes")
.action(async function({ cache, ...filter }){
const config = readConfig();
const results= await check(grepPackages(config, filter), cache);
for(const { status, value } of results)
echoPkgStatus(status, value);
if(!results.length) echo("Nothing to do.");
$.exit(0);
})
.command("update", "Updates registered packages")
.option("--group, -G", "Filter by group")
.option("--repository, -R", "Filter by repository")
.action(async function(filter){
if(s.test("-f", path_config_lock))
return $.error(`The lock file '${path_config_lock}' already exists! Check if some other instance is running.`);
s.touch(path_config_lock);
const config = readConfig();
const results= await check(grepPackages(config, filter));
const start= Date.now();
let done= 0;
let todo= [];
echo("Collecting packages to update…");
for(const { status, value } of results){
if(status!==3 || value.local.group==="skip") continue;
echo("%c"+value.local.repository, css.pkg);
todo.push(download(
value,
()=> done+= 1,
config.target
));
}
const { length }= todo;
if(!length){
echo("%cAll up-to-date!%c Nothing to do.", css.ok);
} else {
const id= setInterval(()=>
echo.use("-R", `%cUpdating packages (${done}/${length})`, css.spin), 500);
const updates= await Promise.allSettled(todo);
clearInterval(id);
echo("Updating packages completed:");
for (const { status, value, reason } of updates) {
if(status==="rejected"){
echo("%c✗ "+reason.local.repository+": %c"+reason.err, css.err);
continue;
}
const { local, remote }= value;
echo("%c✓ "+local.repository+"%c@"+remote.tag_name, css.ok, css.skip);
}
s.echo(JSON.stringify(config, null, "\t")).to(path_config_json);
}
s.rm(path_config_lock);
$.exit(0);
})
.parse();
import { createWriteStream } from "node:fs";
async function download(value, onprogress, target){
const { repository, glare }= value.local;
const { tag_name }= value.remote;
if(!glare) return Promise.reject({ err: "Missing 'glare' in config.", ...value });
const response= await fetch(url_download+repository+`@${tag_name}/${glare}`);
const buffer= Buffer.from(await response.arrayBuffer());
const downloads= target+value.local.file_name;
const ws= createWriteStream(downloads, { flags: "w" });
ws.write(buffer);
Object.assign(value.local, {
last_update: value.remote.published_at,
version: value.remote.tag_name,
downloads
});
if(value.local.exec==="yes")
s.chmod("+x", downloads);
onprogress();
return value;
}
function grepPackages({ packages }, { group, repository }){
const f= {};
let is_filter= false;
if(group){ is_filter= true; f.group= group; }
if(repository){ is_filter= true; f.repository= repository; }
if(!is_filter) return packages;
return packages.filter(r=> Object.keys(f).every(k=> r[k]===f[k]));
}
function echoPkgStatus(status, { local, remote }){
let status_css, status_text;
if(local.group==="skip"){
status_text= "skipped";
status_css= "skip";
} else {
status_text= status===3 ? "outdated" : "up-to-date";
status_css= status===3 ? "err" : "ok";
}
echo((status_text==="outdated" ? "+" : "-") + " %c"+local.repository + "%c: %c"+status_text+"%c (%c"+remote.tag_name+"%c)",
css.pkg, css.unset, css[status_css], css.unset, css.skip, css.unset);
}
/**
* @param {Config.packages} packages
* @return {{ status: 0|1|2|3, value: { remote: GitHubRelease, local: ConfigPackage } }}
* */
async function check(packages, cache){
return (await pipe(
ps=> ps.map(p=> fetchRelease(p, cache).then(remote=> ({ local: p, remote }))),
ps=> Promise.allSettled(ps)
)(packages))
.map(({ status, ...v })=> status==="rejected" ?
{ status: -1, value: v } :
{ status: packageStatus(v.value.local, v.value.remote), value: v.value })
.filter(({ status, value })=> {
if(status!==-1) return true;
echo("%c"+value.reason, css.err);
});
}
/** @type {(local: ConfigPackage, remote: GitHubRelease)=> 0|1|2|3} */
function packageStatus({ last_update: local }, { published_at: remote }){
if(!remote) return 0;
if(!local) return 3;
if(remote===local) return 1;
return 2+(local<remote);
}
/** @param {ConfigPackage} package */
async function fetchRelease({ repository, tag_name_regex }, cache){
const headers= { 'User-Agent': 'node' };
if(cache==="no") headers['Cache-Control'] = 'no-cache';
const url= url_api+repository+"/releases";
const releases= await fetch(url, { headers }).then(res=> res.json());
if(releases.message) return $.error(url+": "+releases.message);
return releases.find(function ({ draft, published_at, tag_name }){
if(draft||!published_at) return false;
if(!tag_name_regex) return true;
return (new RegExp(tag_name_regex, 'g')).test(tag_name);
});
}
function readConfig(){
if(!s.test("-f", path_config_json)) return { packages: [] };
const out= Object.assign({ target: "~/bin/" },
s.cat(path_config_json).xargs(JSON.parse));
if(out.target.startsWith("~/")) out.target= $.xdg.home(out.target.slice(2));
return out;
}

View File

@ -68,7 +68,7 @@ $.api("", true)
.map(pipe(
j=> j.choices[0].text.trim(),
convertToArray,
format==="regular" ? i=> i : i=> gitmoji(i, format==="git3moji"),
format==="regular" || format==="conventional" ? i=> i : i=> gitmoji(i, format==="git3moji"),
a=> a.join("\n")
))
.join("\n\n");

6
bin/§wallpaper_BIOTD Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
nm-online -x -q && \
node "/home/jaandrle/.nvm/versions/node/$(node --version)/bin/nodejsscript" /home/jaandrle/bin/§wallpaper_WCPOTD.mjs pull && \
cd "/home/jaandrle/Obrázky/Bing Image Of The Day" && \
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'const d= desktops().filter(d=> d.wallpaperPlugin==="de.unkn0wn.htmlwallpaper")[0];const url= (i= "")=> `file:///home/jaandrle/Obr%C3%A1zky/Bing%20Image%20Of%20The%20Day/index${i}.html`;d.currentConfigGroup= Array("Wallpaper", "de.unkn0wn.htmlwallpaper","General");d.writeConfig("DisplayPage", url("1"));d.writeConfig("DisplayPage", url());'
# convert now.jpg prev.jpg +append horizontally.jpg

113
bin/§wallpaper_WCPOTD.mjs Executable file
View File

@ -0,0 +1,113 @@
#!/usr/bin/env nodejsscript
/* jshint esversion: 11,-W097, -W040, module: true, node: true, expr: true, undef: true *//* global echo, $, pipe, s, fetch, cyclicLoop */
const img_params= "?width=1920";
const url_api= "https://commons.wikimedia.org/w/api.php";
const url_image= "https://commons.wikimedia.org/wiki/Special:FilePath/";
import { join } from "node:path";
const path_home= $.xdg.home`Obrázky/Bing Image Of The Day/`;
const path_info= join(path_home, "images.json");
$.api()
.version("2024-05-12")
.command("pull", "Pull new/today image(s)")
.action(async function pull(){
const images= {
now: await getImagePath(0),
prev: await getImagePath(-1)
};
const paths= await downloadImages(images);
updateHTML(images);
convert(paths);
pipe(
images=> Object.entries(images)
.reduce((acc, [ key, { caption } ])=>
Reflect.set(acc, key, caption) && acc,
{}),
images=> JSON.stringify(images, null, "\t"),
s.echo
)(images).to(path_info);
$.exit(0);
})
.command("status")
.action(function status(){
const images= s.cat(path_info).xargs(JSON.parse);
const [ stats ]= s.ls("-l", path_info);
echo({ timestamp: stats.mtime, ...images });
$.exit(0);
})
.parse();
/** @typedef {{ url: string, caption: string }} T_response */
/** @typedef {Record<"now"|"prev",T_response>} T_images */
/** @param {Record<"now"|"prev",string>} paths */
function convert(paths){
const resize_to= "1920x1080";
paths= Object.values(paths);
const target= join(path_home, "horizontally.jpg");
const params= `-resize ${resize_to}^ -gravity center -extent ${resize_to}`.split(" ");
s.run`convert ${paths} ${params} +append ${target}`;
}
import { writeFileSync } from "node:fs";
/** @param {T_images} images */
function updateHTML(images){
let template= s.cat(join(path_home, "index_template.html")).trim();
for(const [ key, image ] of Object.entries(images))
template= template.replace(`::${key}::`, image.caption);
s.echo(template).to(join(path_home, "index.html"));
}
/** @param {T_images} images */
async function downloadImages(images){
const out= {};
for(const [ key, image ] of Object.entries(images))
out[key]= await downloadImage(image, key);
return out;
}
async function getImagePath(shift= 0){
const date= dateISO(shift);
const { expandtemplates: { wikitext: filepath } }= await fetchGet({
action: "expandtemplates",
prop: "wikitext",
text: `{{Potd/${date}}}`,
});
const caption= pipe(
response=> response.expandtemplates.wikitext,
caption=> caption.replace(/\[\[.*?\]\]/g, m=> m.slice(2, -2).split("|").reverse()[0]),
caption=> caption.replace(/''(.*?)''/g, "„$1”"),
)(await fetchGet({
action: "expandtemplates",
prop: "wikitext",
text: `{{Potd/${date} (cs)}}`,
}));
/* TODO?
* action: 'query',
* prop: 'imageinfo',
* iiprop: 'extmetadata',
* iiextmetadatafilter: 'LicenseShortName|Artist|LicenseUrl',
* titles: `Image:${ filename }`
*
* res.data.query.pages[0].imageinfo[0].extmetadata
* */
return {
caption: caption,
url: url_image+encodeURI(filepath+img_params)
};
}
/** @param {T_response} image @param {"prev"|"now"} type */
async function downloadImage({ url }, type){
const filename= join(path_home, `${type}.jpg`);
const response= await fetch(url);
const buffer= await response.arrayBuffer();
writeFileSync(filename, Buffer.from(buffer));
return filename;
}
function dateISO(shift= 0){
const d= new Date();
d.setDate(d.getDate()+shift);
return d.toISOString().substring(0, 10);
}
function fetchGet(params){
if(!params.format) params.format= "json";
return fetch(url_api+"?"+(new URLSearchParams(params)).toString(), { method: "GET" }).then(res=> res.json());
}