Giter Club home page Giter Club logo

Comments (1)

francwalter avatar francwalter commented on June 4, 2024

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() + '".')

from clipmenu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.