26 lines
675 B
Ruby
26 lines
675 B
Ruby
#!/usr/bin/env ruby
|
|
|
|
require 'open3'
|
|
require 'uri'
|
|
require 'pathname'
|
|
require 'securerandom'
|
|
require 'net/scp'
|
|
|
|
file = Pathname.new(ARGV[0])
|
|
new_name = SecureRandom.hex(12) + File.extname(file)
|
|
abort "Och komm." unless file.exist? and file.readable?
|
|
|
|
url = URI.escape("https://drop.bascht.space/#{new_name}")
|
|
|
|
Net::SCP.start("drop.bascht.space", "bascht") do |scp|
|
|
scp.upload(file.expand_path.to_s, "/home/bascht/drop/#{new_name}")
|
|
end
|
|
|
|
if ENV["WAYLAND_DISPLAY"].nil?
|
|
Open3.popen3( "xclip -i -selection clipboard" ){ |input, _, _| input << url }
|
|
else
|
|
system "wl-copy #{url}"
|
|
end
|
|
|
|
system("notify-send 'Uploaded successfully' '<a href=\'#{url}\'>drop.bascht.space</a>'")
|