Closed francwalter closed 1 year ago
Oh, oh. I found it. It has to be done first as command (F6) as I read in the README from commands. Sorry.
I changed it a bit, to have as default name the actual date and time, like 2023-03-08_15-04-00.png. Also I use the "Schreibtisch" (Desktop) as default path:
copyq:
var timetag = dateString('yyyy-MM-dd_HH-mm-ss')
var suffices = {
'image/svg': 'svg',
'image/png': 'png',
'image/jpeg': 'jpg',
'image/jpg': 'jpg',
'image/bmp': 'bmp',
'text/html': 'html',
'text/plain' : 'txt',
}
function hasSuffix(fileName)
{
return /\.[0-9a-zA-z]+$/.test(fileName);
}
function addSuffix(fileName, format)
{
var suffix = suffices[format]
return suffix ? fileName + "." + suffix : fileName
}
function filterFormats(format)
{
return /^[a-z]/.test(format) && !/^application\/x/.test(format)
}
function itemFormats(row)
{
return str(read('?', row))
.split('\n')
.filter(filterFormats)
}
function formatPriority(format)
{
var k = Object.keys(suffices);
var i = k.indexOf(format);
return i === -1 ? k.length : i
}
function reorderFormats(formats)
{
formats.sort(function(lhs, rhs){
var i = formatPriority(lhs);
var j = formatPriority(rhs);
return i === j ? lhs.localeCompare(rhs) : i - j;
})
}
if (selectedtab()) tab(selectedtab())
var row = selectedtab() ? currentitem() : -1
var formats = itemFormats(row)
reorderFormats(formats)
currentpath(Dir().homePath() + '/Schreibtisch/')
var defaultFileName = timetag
var keyFormat = 'Format'
var keyFileName = 'File'
var defaultFormat = formats[0]
var result = dialog(
'.title', 'Save Item As...',
'.width', 250,
keyFormat, [defaultFormat].concat(formats),
keyFileName, File(defaultFileName)
) || abort()
var fileName = result[keyFileName]
var format = result[keyFormat]
if (!format || !fileName)
abort()
if (!hasSuffix(fileName))
fileName = addSuffix(fileName, format)
var f = File(fileName)
if (!f.open()) {
popup('Failed to open "' + f.fileName() + '"', f.errorString())
abort()
}
f.write(selectedtab() ? getitem(currentitem())[format] : clipboard(format))
popup("Item Saved", 'Item saved as "' + f.fileName() + '".')
Hallo
I was looking for the feature to save an image (screenshot) from clipboard to a file and I found this in the help: Save Image to a File I read here, that I could use the command:
copyq read image/png 0 > image.png
or Alternatively use "Save Item/Clipboard To a File" command. My file manager ("Files" the default File Manager in Ubuntu Gnome) wont accept images as input to save.But when I look there, there is neither an entry in my toolbar (on the right side of the main window, I guess this is the "toolbar") nor is there any menu giving me "Save item". No entry in the contextmenu of an entry neither.
The README.md begins with "This section contains commands which can be executed from tool bar, menu or with shortcut." but it must be another version as mine. What am I missing here?
Thank, frank
ClipMenu 6.4.0 on Ubuntu 22.04
EDIT: here a screenshot with my toolbar (by the way, I didnt find any way to set the toolbar up):