[Build] Prep
This commit is contained in:
parent
49595c3811
commit
aea9229c54
@ -1,9 +1,52 @@
|
||||
// Using commonjs instead of ejs, because more widely compatible
|
||||
const mustache = require( 'mustache' );
|
||||
const inquirer = require( 'inquirer' );
|
||||
const fs = require( 'fs' );
|
||||
const path = require( 'path' );
|
||||
const os = require( 'os' );
|
||||
const render = require( './render' );
|
||||
|
||||
// Define view options (for rendering with mustache)
|
||||
const view = {
|
||||
// Colours
|
||||
'colour_foreground': '',
|
||||
|
||||
// Prompt user to select a wallpaper (if no path is passed as argument)
|
||||
const wallpapers = fs.readdirSync( path.join( os.homedir(), '/NextCloud/Wallpapers' ) );
|
||||
const wallpaperChoices = [];
|
||||
wallpapers.forEach(element => {
|
||||
wallpaperChoices.push( { 'name': element.split( '.' )[ 0 ], 'value': element } );
|
||||
});
|
||||
|
||||
|
||||
// Selection options
|
||||
const chooseWallpaper = {
|
||||
'type': 'list',
|
||||
'name': 'wallpaper',
|
||||
'message': 'Choose the wallpaper to be used',
|
||||
'choices': wallpaperChoices,
|
||||
};
|
||||
|
||||
const chooseLockpaper = {
|
||||
'type': 'list',
|
||||
'name': 'lockpaper',
|
||||
'message': 'Choose the lockscreen wallpaper to be used',
|
||||
'choices': wallpaperChoices,
|
||||
};
|
||||
|
||||
const chooseTheme = {
|
||||
'type': 'list',
|
||||
'name': 'theme',
|
||||
'message': 'Choose the general colourway to be used',
|
||||
'choices': [
|
||||
{ name: 'Nordic', value: 'nordic' },
|
||||
{ name: 'Deep-Dark', value: 'deep-dark' },
|
||||
{ name: 'Material-You', value: 'material' },
|
||||
{ name: 'Light', value: 'light' },
|
||||
{ name: 'Bright', value: 'bright' },
|
||||
]
|
||||
}
|
||||
|
||||
// TODO: Add argument parsing
|
||||
const args = process.argv.slice( 2 );
|
||||
inquirer.default.prompt( [
|
||||
chooseWallpaper,
|
||||
chooseTheme
|
||||
] ).then( answers => {
|
||||
render( path.join( os.homedir(), '/NextCloud/Wallpapers', answers.wallpaper ), path.join( os.homedir(), '/NextCloud/Wallpapers', answers.lockpaper ), answers.theme );
|
||||
} );
|
||||
|
@ -14,6 +14,9 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@janishutz/colorthief": "^3.0.2",
|
||||
"color-convert": "^3.0.1",
|
||||
"inquirer": "^12.5.0",
|
||||
"mustache": "^4.2.0"
|
||||
}
|
||||
}
|
||||
|
77
build/render.js
Normal file
77
build/render.js
Normal file
@ -0,0 +1,77 @@
|
||||
const mustache = require( 'mustache' );
|
||||
const colorThief = require( '@janishutz/colorthief' );
|
||||
const convert = require( 'color-convert' );
|
||||
|
||||
const build = ( wallpaper, lockpaper, theme ) => {
|
||||
console.log( '\n=> Extracting colours' );
|
||||
// Extract colour palette from chosen wallpaper using Color-Thief
|
||||
colorThief.getPalette( wallpaper ).then( palette => {
|
||||
// Define view options (for rendering with mustache)
|
||||
console.log( palette );
|
||||
const view = {
|
||||
'wallpaper-path': wallpaper,
|
||||
'lockpaper-path': lockpaper,
|
||||
|
||||
// Colours
|
||||
'colour-foreground-hex': renderColourAsHex( palette[ 0 ] ),
|
||||
'colour-foreground-rgb': renderColourAsRGB( palette[ 0 ] ),
|
||||
'colour-accent-hex': renderColourAsHex( palette[ 1 ] ),
|
||||
'colour-accent-rgb': renderColourAsRGB( palette[ 1 ] ),
|
||||
'colour-accent-2-hex': renderColourAsHex( palette[ 2 ] ),
|
||||
'colour-accent-2-rgb': renderColourAsRGB( palette[ 2 ] ),
|
||||
'colour-accent-3-hex': renderColourAsHex( palette[ 3 ] ),
|
||||
'colour-accent-3-rgb': renderColourAsRGB( palette[ 3 ] ),
|
||||
'colour-background-hex': '',
|
||||
'colour-background-rgb': '',
|
||||
'colour-shadow-hex': '',
|
||||
'colour-shadow-rgb': '',
|
||||
'colour-inavtive-hex': '',
|
||||
'colour-inavtive-rgb': '',
|
||||
|
||||
// General style
|
||||
'style-corner-rounding': 5000,
|
||||
|
||||
// Fonts
|
||||
'font-primary': 'Comfortaa',
|
||||
'font-accent': 'Source Code Pro',
|
||||
|
||||
// yazi theme
|
||||
'yazi-theme': 'tokyo-night',
|
||||
|
||||
// Path to this repo on disk
|
||||
'path-to-dotfiles': __dirname.slice(0, __dirname.length - 5),
|
||||
}
|
||||
|
||||
// TODO: Maybe bar config? Reordering? Same for quick actions?
|
||||
console.log( view );
|
||||
} ).catch( () => {
|
||||
console.error( '\n=> Failed to load image or retrieve colour palette from it' );
|
||||
} )
|
||||
}
|
||||
|
||||
const colours = {
|
||||
|
||||
}
|
||||
|
||||
const fonts = {
|
||||
|
||||
}
|
||||
|
||||
const yaziThemes = {
|
||||
|
||||
}
|
||||
|
||||
const renderColourAsHex = ( colour ) => {
|
||||
return '#' + convert.default.rgb.hex( colour[ 0 ], colour[ 1 ], colour[ 2 ] );
|
||||
}
|
||||
|
||||
const renderColourAsRGB = ( colour ) => {
|
||||
return `rgb( ${ colour[ 0 ] }, ${ colour[ 1 ] }, ${ colour[ 2 ] } )`
|
||||
}
|
||||
|
||||
const render = ( templatePath, view ) => {
|
||||
|
||||
}
|
||||
|
||||
|
||||
module.exports = build;
|
Loading…
x
Reference in New Issue
Block a user