⚡ updated
This commit is contained in:
@ -78,7 +78,7 @@ function removePack(path){
|
||||
s.cd(dirs.pack);
|
||||
s.$("-V").rm("-rf", path);
|
||||
const root= dirs.pack+path.split("/")[0];
|
||||
const { code, stdout }= s.$().find(root+"/*/*");
|
||||
const { code, stdout }= s.$("-Sf").find(root+"/*/*");
|
||||
if(!code) echo(stdout);
|
||||
else if(s.test("-d", root))
|
||||
s.$("-V").rm("-rf", root);
|
||||
|
@ -1,6 +1,20 @@
|
||||
#!/bin/bash
|
||||
# heredoc
|
||||
read -r -d '' JS <<JS
|
||||
const dir= '/home/jaandrle/Obrázky/Bing Image Of The Day/';
|
||||
const img= 'horizontally.jpg';
|
||||
desktops()
|
||||
.filter(d=> d.wallpaperPlugin==='org.kde.image')
|
||||
.forEach(d=> {
|
||||
d.currentConfigGroup= ['Wallpaper', 'org.kde.image', 'General'];
|
||||
if(!d.readConfig('Image').endsWith(img)) return;
|
||||
d.writeConfig('Image', 'file://' + dir + 'now.jpg');
|
||||
d.writeConfig('Image', 'file://' + dir + img);
|
||||
});
|
||||
JS
|
||||
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
|
||||
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "$JS"
|
||||
# plasma-apply-wallpaperimage '/home/jaandrle/Obrázky/Bing Image Of The Day/now.jpg' && plasma-apply-wallpaperimage '/home/jaandrle/Obrázky/Bing Image Of The Day/horizontally.jpg'
|
||||
# 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());' && \
|
||||
|
@ -9,7 +9,7 @@ const path_home= $.xdg.home`Obrázky/Bing Image Of The Day/`;
|
||||
const path_info= join(path_home, "images.json");
|
||||
|
||||
$.api()
|
||||
.version("2024-06-17")
|
||||
.version("2024-11-14")
|
||||
.command("pull", "Pull new/today image(s)")
|
||||
.action(async function pull(){
|
||||
const images= {
|
||||
@ -18,15 +18,19 @@ $.api()
|
||||
};
|
||||
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);
|
||||
const images_save= Object.entries(images)
|
||||
.reduce((acc, [ key, { caption } ])=>
|
||||
Reflect.set(acc, key, caption) && acc,
|
||||
{});
|
||||
convert(paths, images_save);
|
||||
s.echo(JSON.stringify(images_save, null, "\t")).to(path_info);
|
||||
$.exit(0);
|
||||
})
|
||||
.command("redraw")
|
||||
.action(function redraw(){
|
||||
const paths= [ "now", "prev" ].map(key=> join(path_home, `${key}.jpg`));
|
||||
const images= s.cat(path_info).xargs(JSON.parse);
|
||||
convert(paths, images);
|
||||
$.exit(0);
|
||||
})
|
||||
.command("status")
|
||||
@ -40,13 +44,35 @@ $.api()
|
||||
/** @typedef {{ url: string, caption: string }} T_response */
|
||||
/** @typedef {Record<"now"|"prev",T_response>} T_images */
|
||||
/** @param {Record<"now"|"prev",string>} paths */
|
||||
function convert(paths){
|
||||
function convert(paths, images){
|
||||
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(" ");
|
||||
const caption= (position, text)=> [
|
||||
"convert",
|
||||
`"${target}"`,
|
||||
"\\(",
|
||||
"-pointsize", "12",
|
||||
"-background", "transparent",
|
||||
"-fill", "white",
|
||||
"-family", `"Ubuntu Mono"`,
|
||||
"-weight", "Bold",
|
||||
"-gravity", "center",
|
||||
"-bordercolor", '"rgba(0,0,0,0.3)"',
|
||||
"-border", "10",
|
||||
"-size", "500x",
|
||||
`caption:"${text}"`,
|
||||
"\\)",
|
||||
"-gravity", position,
|
||||
"-geometry", "+0+0",
|
||||
"-composite",
|
||||
`"${target}"`,
|
||||
].join(" ");
|
||||
s.run`convert ${paths} ${params} +append ${target}`;
|
||||
s.run(caption("southwest", images.now));
|
||||
s.run(caption("southeast", images.prev));
|
||||
}
|
||||
import { writeFileSync } from "node:fs";
|
||||
/** @param {T_images} images */
|
||||
|
Reference in New Issue
Block a user