GithubHelp home page GithubHelp logo

clipster's People

Contributors

barraponto avatar bduncan avatar bwduncan avatar chron-isch avatar glubsy avatar klao avatar lilyinstarlight avatar mk-fg avatar mrichar1 avatar sebastianst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clipster's Issues

Text selection highlighting vanishes when `sync_selections = yes`

If I set sync_selections = yes and I select some text in my urxvt terminal, the selection highlight vanishes away. This might be tricky but I wish to keep the selected text highlighted. Thank you!

TIP: If I select the same text twice or more, it stays highlighted the second time onwards.

clipster fails to delete entries containing unicode characters

In testing, I have found that clipster errors and fails to delete any entry containing unicode.

~ -> clipster -d -l DEBUG
DEBUG:Debugging Enabled.
DEBUG:Merged config: [('active_selections', 'PRIMARY,CLIPBOARD'), ('data_dir', '/home/demure/.local/share/clipster'), ('default_selection', 'PRIMARY'), ('duplicates', 'no'), ('extract_emails', 'yes'), ('extract_patterns', 'no'), ('extract_uris', 'yes'), ('filter_classes', ''), ('history_file', '/home/demure/.local/share/clipster/history'), ('history_size', '200'), ('history_update_interval', '60'), ('max_input', '50000'), ('pid_file', '/home/demure/.local/share/clipster/clipster.pid'), ('row_height', '3'), ('smart_update', '1'), ('socket_file', '/home/demure/.local/share/clipster/clipster_sock'), ('sync_selections', 'no'), ('write_on_change', 'no')]
DEBUG:Writing history file every 60 seconds
DEBUG:Client connection received.
DEBUG:Received: sig:SELECT, board:CLIPBOARD, count:0

(clipster:1402): Gtk-WARNING **: Allocating size to GtkDialog 0x56208489e330 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?
DEBUG:Deleting history entry: ☃
/usr/local/sbin/clipster:217: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
if self.read_board(board) == item:
/usr/local/sbin/clipster:349: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
if text in self.boards[board]:
DEBUG:Deleting history entry: ☈
DEBUG:Client connection received.
DEBUG:Received: sig:SELECT, board:CLIPBOARD, count:0

(clipster:1402): Gtk-WARNING **: Allocating size to GtkDialog 0x5620849d4560 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?
DEBUG:Deleting history entry: ☃
DEBUG:Deleting history entry: ☈
DEBUG:Client connection received.
DEBUG:Received: sig:SELECT, board:CLIPBOARD, count:0

(clipster:1402): Gtk-WARNING **: Allocating size to GtkDialog 0x562084a32e50 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?
DEBUG:Deleting history entry: ☃
DEBUG:Deleting history entry: ☈

Thank you for your time.
-demure

Use `a in b` in smart_update check

I realized that my primary clipboard is often flooded with strings that grow or shrink to the left. This is caused, for example, when I select text with the mouse from right to left . Then the smart_update feature doesn't work, because in method update_history, the checks in line 372 use str.startswith().

Would you maybe agree to switch to a in b here to detect growth in any direction? Or would you rather make that optional via the configuration?

(Update: python strings don't have a contains() method :) )

License

Hi. What license does clipster have?

GUI lacks WM attributes

Currently the GUI window doesn't have any WM_* attributes set - like NAME or CLASS so xprop shows (on i3):

WM_NAME(STRING) = "[i3 con] floatingcon around 0x55fa99de0030"
WM_CLASS(STRING) = "i3-frame", "i3-frame"

This may cause unexpeted issues, especially in cases where people are using these attributes to assign the GUI to workspaces etc.

WM attributes should be added - at least NAME and CLASS but possibly also things like roles, and maybe popup-esque attributes.

Multi-DISPLAY support

I am using different X server instances, and have noticed that you can only have one clipster daemon running, and it's bound to that $DISPLAY.

I might be nice to have headless daemon that can be used from different environments, and where clipster -s (to open the selection window) uses the current $DISPLAY.

sync_selections not working

Hello and thank you for this project.
I am running clipster like this...

./clipster -d -l DEBUG -f /home/marc/.config/clipster/clipster.ini

...and this is my config file:

 [0] ~/.config/clipster >> egrep -v "^#|^$" clipster.ini 
[clipster]
data_dir = /home/marc/clipster
default_selection = PRIMARY
active_selections = PRIMARY,CLIPBOARD
sync_selections = yes
history_file = /home/marc/clipster/history
history_size = 200
history_update_interval = 60
write_on_change = no
socket_file = /home/marc/clipster/clipster_sock
pid_file = /home/marc/clipster/clipster.pid
max_input = 50000
row_height = 3
duplicates = no
smart_update = 1
extract_uris = no
extract_emails = no
extract_patterns = no

But when I select some text in my urxvt terminal the selection is not synced to the CLIPBOARD.

[0] ~/git/clipster (master) >> ./clipster -d -l DEBUG -f /home/marc/.config/clipster/clipster.ini 
DEBUG:Debugging Enabled.
DEBUG:Trying to read config file: /home/marc/.config/clipster/clipster.ini
DEBUG:Merged config: [('active_selections', 'PRIMARY,CLIPBOARD'), ('data_dir', '/home/marc/clipster'), ('default_selection', 'PRIMARY'), ('duplicates', 'no'), ('extract_emails', 'no'), ('extract_patterns', 'no'), ('extract_uris', 'no'), ('filter_classes', ''), ('history_file', '/home/marc/clipster/history'), ('history_size', '200'), ('history_update_interval', '60'), ('max_input', '50000'), ('pid_file', '/home/marc/clipster/clipster.pid'), ('row_height', '3'), ('smart_update', '1'), ('socket_file', '/home/marc/clipster/clipster_sock'), ('sync_selections', 'yes'), ('write_on_change', 'no')]
DEBUG:Writing history file every 60 seconds
DEBUG:owner-change event!
DEBUG:selection: PRIMARY
DEBUG:Selection in 'active_selections'
DEBUG:Selection is text.
DEBUG:Updating clipboard: PRIMARY
DEBUG:['history']
DEBUG:Writing history to file.
^CDEBUG:Daemon exiting...
DEBUG:History unchanged - not writing to file.

Syntax error

Following latest update I can’t run clipster because of:

line 438
    os.chmod(self.sock_file, 0600)

SyntaxError: invalid token

I tried changing to 600: now the demon starts, but then when launching -s I get: ERROR:Error connecting to socket. Is daemon running?

History isn’t written sometimes

As the title says, I noticed that history sometimes (most of the times) doesn’t get written (the file isn’t created, or if it exists it isn’t updated). Still, if I launch clipster -s I get everything (until I restart the demon).
I tried all the -l modes, but it seems nothing strange is happening.

Python2 unicode

This is an aide-memoire for some of the utf-8 related code for python2...

If we add £3.99 to the clipboard, then (with debugging turned on) we see the in-memory buffer holds:

python3: '£3.99' (we can walk away at this point...)

python2: '\xc2\xa33.99'

In both cases, the JSON history file will contain the 'ascii-fied' "\u00a33.99"

However, with python2 when the history file is read back in, it becomes:

python2 u'\xa33.99'

This causes the smart-update and duplicates code to fail, since these will be treated as unequal when compared.

The solution is to always try to decode('utf-8') the selection, ignoring any failures. This will ensure that all comparisons are of u'' objects.

The other solution of course is to just use python3.

newlines get removed sometimes

I'm sorry for not having a clearer idea of when this happens, but sometimes a multi-line copy turns into a one-line paste.

Here's how I use clipster (bound to a key in my WM):

clipster -o -n 200 -0 | rofi -i -dmenu -sep '\x00' -eh 2 -p paste: | tr -d '\n' | clipster

Copied text lost when closing

When I copy e.g. from my editor, then I close it, the selection is not available anymore for other applications (i.e. the system’s clipboard is emptied) unless I open clipster and copy it again from it.

Feature request: add a whiltelist

As discussed, would be nice to have a white list.

I've made a patch, submitting pull request.

I have some small improvements I'll include in another pull request too: getting config options every time the owner-change method is called seems very inefficient to me (python is slow enough as it is). ;)

Search only matches beginning of clipboard entries

Only the beginning of clipboard entries is matched when typing a word in the clipboard history window. Searching should match anywhere inside the entries, not just the beginning.

Related to this, there's no way to jump to the next match of a search (or is there?).

Ignore selection based on pattern

I'm using clipster with rofi and loving it so far. So, thank you very much for your work :)

I recently noticed that I have a lot of entries that follow a certain pattern and that I don't want to save. However, I cannot find a configuration value to ignore a selection change based on a pattern. Have I overlooked something? Would it be possible to implement something like this?

Thanks again!

Allow to set output delimiter

This would be useful for dumping the output of the clipboard in a text editor friendly format:

  1. json is not that.
  2. The default \n is ambiguous since clipboard entries often contains \n
  3. The -0 option is not text editor friendly.

Please allow delimiter specification (like >>>>>>>) in the config file and/or the CLI.

Broken pipe

Thanks for the release!

On 1.0.0 I get the following error:

$ Traceback (most recent call last):
  File "/nix/store/vxwz45d3wqs1l28s7dax8vsfia9gvcx5-python3-3.5.3-env/lib/python3.5/site-packages/gi/overrides/GLib.py", line 735, in <lambda>
    func_fdtransform = lambda _, cond, *data: callback(channel, cond, *data)
  File "/nix/store/8yclnhbfzz5xkgqsspdhkz3hf7qcqaid-clipster-1.0.0/bin/.clipster-wrapped", line 514, in socket_recv
    self.process_msg(conn)
  File "/nix/store/8yclnhbfzz5xkgqsspdhkz3hf7qcqaid-clipster-1.0.0/bin/.clipster-wrapped", line 544, in process_msg
    conn.sendall(json.dumps(self.boards[board][-count:][::-1]).encode('utf-8'))
BrokenPipeError: [Errno 32] Broken pipe
Traceback (most recent call last):
  File "/nix/store/vxwz45d3wqs1l28s7dax8vsfia9gvcx5-python3-3.5.3-env/lib/python3.5/site-packages/gi/overrides/GLib.py", line 735, in <lambda>
    func_fdtransform = lambda _, cond, *data: callback(channel, cond, *data)
  File "/nix/store/8yclnhbfzz5xkgqsspdhkz3hf7qcqaid-clipster-1.0.0/bin/.clipster-wrapped", line 514, in socket_recv
    self.process_msg(conn)
  File "/nix/store/8yclnhbfzz5xkgqsspdhkz3hf7qcqaid-clipster-1.0.0/bin/.clipster-wrapped", line 544, in process_msg
    conn.sendall(json.dumps(self.boards[board][-count:][::-1]).encode('utf-8'))
BrokenPipeError: [Errno 32] Broken pipe
 Traceback (most recent call last):
  File "/nix/store/vxwz45d3wqs1l28s7dax8vsfia9gvcx5-python3-3.5.3-env/lib/python3.5/site-packages/gi/overrides/GLib.py", line 735, in <lambda>
    func_fdtransform = lambda _, cond, *data: callback(channel, cond, *data)
  File "/nix/store/8yclnhbfzz5xkgqsspdhkz3hf7qcqaid-clipster-1.0.0/bin/.clipster-wrapped", line 514, in socket_recv
    self.process_msg(conn)
  File "/nix/store/8yclnhbfzz5xkgqsspdhkz3hf7qcqaid-clipster-1.0.0/bin/.clipster-wrapped", line 544, in process_msg

Option to disable one of the two clipboards

For example disabling primary, that many people don’t use or don’t want to store for reuse. Main advantage is that if we write history on every change it becomes much less invasive (we are always selecting text, whereas we rarely ctrl-c)

Using `clipster -c` or `clipster -p` results in "Socket error [Errno 32] Broken pipe"

Using the latest in master (3d0c2bc) with a fresh history file, whenever I attempt to pipe anything in using clipster -c or clipster -p, the daemon throws the follow error and does not save the clip to the specified clipboard.

DEBUG:Client connection received.
DEBUG:Received: sig:BOARD, board:CLIPBOARD, count:0
DEBUG:Sending requested selection(s): []
ERROR:Socket error [Errno 32] Broken pipe
DEBUG:Exception:
Traceback (most recent call last):
  File "./clipster", line 555, in process_msg
    conn.sendall(json.dumps(result[-count:][::-1]).encode('utf-8'))
BrokenPipeError: [Errno 32] Broken pipe
DEBUG:History unchanged - not writing to file.

Using any version of clipster before the July 20th batch of updates works as expected. It seems the commit "Restructure msg protocol to extend querying server" is the culprit.

I'm at work currently, but will look into creating a pull request after work.

Unlimited history

Hi,

The Windows open-source clipboard manager Ditto has an unique feature which I've yet to find in any Linux clipboard manager: unlimited history.

That is, there can be no limit to the number of stored entries. All entries are saved in an SQLite database, which is indexed with SQLite's excellent full text indexing. This allows incrementally searching through hundreds of thousands of clipboard entries in seconds.

I have found this to be incredibly convenient, as it means that I can always cut instead of delete anything, with the peace of mind that I can always recover it later. It also allows me to quickly paste in code snippets written any amount of time ago.

Would this be a viable feature request for this project?

ASCII problem

I'm using clipster with roficlip, that is, clipster is called with clipster -c -o -n 500 -0.
Unfortunately, that fails with the following error:

Traceback (most recent call last):
  File "/usr/local/bin/clipster", line 854, in <module>
    main()
  File "/usr/local/bin/clipster", line 837, in main
    print(client.output(), end='')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 41: ordinal not in range(128)

It seems that the wrong encoding is used. How can I change that?

Fails to capture anything copied from Blender

Anything copied from Blender doesn't end up in clipster's history.
Blender works fine with clipit, so I suspect this is a clipster issue.

Debug output:

% clipster -d -l DEBUG              

** (clipster:6892): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-0jJrcSQjtc: Connection refused
DEBUG:Debugging Enabled.
DEBUG:Trying to read config file: /home/gandalf3/.config/clipster/clipster.ini
DEBUG:Merged config: [('active_selections', 'CLIPBOARD'), ('data_dir', '/home/gandalf3/.local/share/clipster'), ('default_selection', 'CLIPBOARD'), ('duplicates', 'no'), ('extract_emails', 'yes'), ('extract_patterns', 'no'), ('extract_uris', 'yes'), ('filter_classes', ''), ('history_file', '/home/gandalf3/.local/share/clipster/history'), ('history_size', '30'), ('history_update_interval', '60'), ('max_input', '50000'), ('pid_file', '/home/gandalf3/.local/share/clipster/clipster.pid'), ('row_height', '3'), ('smart_update', '1'), ('socket_file', '/home/gandalf3/.local/share/clipster/clipster_sock'), ('sync_selections', 'no'), ('write_on_change', 'no')]
DEBUG:Writing history file every 60 seconds
# Here I attempt to copy
DEBUG:owner-change event!
DEBUG:selection: CLIPBOARD
DEBUG:Selection in 'active_selections'
DEBUG:Client connection received.
# And here I run clipster -sc
DEBUG:Received: sig:SELECT, board:CLIPBOARD, count:0

sync_selections not working

sync_selections is not working

HEAD: 3ca241f

[~]── -  clipster -d -f ~/.config/clipster/clipster.ini -l DEBUG

(clipster:15593): Gtk-WARNING **: Theme parsing error: gtk.css:3881:29: The style property GtkButton:inner-border is deprecated and shouldn't be used anymore. It will be removed in a future version
DEBUG:Debugging Enabled.
DEBUG:Trying to read config file: /home/benedikt/.config/clipster/clipster.ini
DEBUG:Merged config: [('active_selections', 'PRIMARY,CLIPBOARD'), ('clipster_dir', '/home/benedikt/.clipster'), ('data_dir', '$XDG_DATA_HOME'), ('default_selection', 'PRIMARY'), ('duplicates', 'no'), ('extract_emails', 'yes'), ('extract_patterns', 'no'), ('extract_uris', 'yes'), ('filter_classes', '"pass,rofi"'), ('history_file', '/home/benedikt/.clipster/history'), ('history_size', '200'), ('history_update_interval', '60'), ('max_input', '50000'), ('pid_file', '/home/benedikt/.clipster/clipster.pid'), ('row_height', '3'), ('smart_update', '1'), ('socket_file', '/home/benedikt/.clipster/clipster_sock'), ('sync_selections', 'yes'), ('write_on_change', 'no')]
DEBUG:Writing history file every 60 seconds
DEBUG:owner-change event!
DEBUG:selection: PRIMARY
DEBUG:Selection is text.
DEBUG:Updating clipboard: PRIMARY
DEBUG:['', 'clipboard-test']
DEBUG:owner-change event!
DEBUG:selection: CLIPBOARD
DEBUG:Selection is text.
DEBUG:Updating clipboard: CLIPBOARD
DEBUG:['', 'clipboard-test']
DEBUG:owner-change event!
DEBUG:selection: PRIMARY
DEBUG:Selection is text.
DEBUG:Updating clipboard: PRIMARY
DEBUG:['', 'clipboard-test', 'primary-test']
^CDEBUG:Daemon exiting...
DEBUG:Writing history to file.

Confusing example config file

In the config file, you have:

# Directory for clipster data/files (usually `$HOME/.local/share/clipster`)
data_dir = $XDG_DATA_HOME

I didn't think twice and copy pasted the config. But using this value in fact creates a folder called \$XDG_DATA_HOME in the current directory! Commenting the line out works as expected.

Discard (strings only containing) whitespaces

Whilte using the primary clipboard it happends quite offen to me that I accidentialy mark way more than I actually want to in a console, or just simply move my mouse a little too much and send 2 or even more lines to the primary clipboard, padded by a whole lot of whitespaces.

It would be awesome if we could filter those extra whitespaces out. The difficult thing would be to not filter out too much.

I guess it could be done with patterns alone, I just wanted to know what you think about it.

delete items from clipboard history

There should be some way to delete things from the clipboard history (other than opening the history file in a JSON editor...)

2 possible interfaces:

  • DEL key/buttons in the UI.
  • command-line option - e.g. --delete

piping to rofi or dmenu broken in 1.2.4

I use clipster trough rofi, with the command clipster -o -n 0 -0 | rofi -i -dmenu -sep '\x00' -eh 2 -p paste: | sed -ze 's/\n$//' | clipster.
On version 1.0.1 that worked just fine, but on 1.2.4 I get all the text overlaid on one line: https://imgur.com/a/QKpjT

Also more minimal versions fail in similar ways:
clipster -o -n 0 -0 | rofi -dmenu
clipster -o -n 0 -0 | dmenu

Permission Error

Running the latest git revision (dfa75b5). Python 3.6.

Since some days, when running clipster -d I get the following traceback:

Traceback (most recent call last):
  File "clipster", line 810, in <module>
    main()
  File "clipster", line 783, in main
    Daemon(config).run()
  File "clipster", line 639, in run
    self.prepare_files()
  File "clipster", line 580, in prepare_files
    os.kill(pid, 0)
PermissionError: [Errno 1] Operation not permitted

I tried googling for this error, and found this

OS Error: Too many files open

❯ Traceback (most recent call last):                                                                                                                                                     [17:41:09]
  File "/usr/bin/clipster", line 484, in owner_change
  File "/usr/bin/clipster", line 416, in update_history
  File "/usr/bin/clipster", line 317, in write_history_file
  File "/usr/lib/python3.6/tempfile.py", line 342, in mkstemp
  File "/usr/lib/python3.6/tempfile.py", line 260, in _mkstemp_inner
OSError: [Errno 24] Too many open files: '/home/jack/.config/clipster/tmp0tv2av8_'
Traceback (most recent call last):
  File "/usr/bin/clipster", line 484, in owner_change
  File "/usr/bin/clipster", line 416, in update_history
  File "/usr/bin/clipster", line 317, in write_history_file
  File "/usr/lib/python3.6/tempfile.py", line 342, in mkstemp
  File "/usr/lib/python3.6/tempfile.py", line 260, in _mkstemp_inner
OSError: [Errno 24] Too many open files: '/home/jack/.config/clipster/tmp9iayxe0f'

I'd love to post something more meaningful than just a traceback but I cannot seem to pinpoint the cause. (This does repeatedly happen occasionally though)

Config below :

[clipster]
data_dir = /home/jack/.config/clipster
default_selection = PRIMARY
active_selections = PRIMARY,SECONDARY,CLIPBOARD
sync_selections = yes
history_file = %(data_dir)s/history
history_size = 5000
history_update_interval = 30
write_on_change = yes
socket_file = %(data_dir)s/clipster_sock
pid_file = %(data_dir)s/clipster.pid
max_input = 50000
row_height = 3
duplicates = no
smart_update = 1
extract_uris = yes
extract_emails = yes
extract_patterns = no
filter_classes = ""

Ignore clipboard changes from certain apps

Investigate ignoring clipboard changes for certain apps, such as password managers, so as to not cache passwords in history.

In theory, we can look at the clipboard owner, get the WM_NAME, WM_CLASS etc and use a user-defined filter to exclude these... however gtk doesn't seem keen to give us this information.

We can get the owning GDK window associated with the event as follows:

owner = event.owner

This window has no useful methods to directly get the X properties though - we have to go via something indirect like libwnck's window_get from the xid: https://developer.gnome.org/libwnck/stable/WnckWindow.html#wnck-window-get

xid = owner.get_xid()
wnck_win = Wnck.Window.get(xid)
wm_name = wnck_win.get_name()
wm_class = wnck_win.get_name()

However the xid here is NOT the xid of the 'application root' window, and so Wnck returns None. Perhaps we need to get it's parent:

parent_xid = owner.get_parent().get_xid()
# Repeat as above...

However get_parent doesn't ask X for the parent, so seems to always return the root window: https://developer.gnome.org/gdk3/3.16/gdk3-Windows.html#gdk-window-get-parent

This is where I'm stuck for now - if anyone has any ideas I'm interested! I'd rather avoid having to add xlib if I can help it...

clipster -s spits out warnings

I'm not sure if this is a bug, but wanted to pass the info anyway.
When I run clipster -s in the terminal, I get 18 times:

(.clipster-wrapped:4373): Gtk-WARNING **: Allocating size to GtkDialog 0x213ff40 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?

dmenu support?

This is by far one of the lightest clipboard managers available for X. How hard would it be add dmenu support. If you could give me somewhere to start I could probably give it a go myself and then create pull request.

WM Integration: i3block

Hi @mrichar1 ,

Thanks a lot for this tool, I had great time playing with it and it'll probably help my a lot in various pipelines in coming years.

Here is a quick gadget I made to integrate clipster into i3block, allowing me to quickly view if an element has been copied, and helping me merging the last 2 elements from the pasteboard (main usecase: merging a website url with a matching text description).

  • insert into $HOME/.i3blocks.conf
[clipster]                                                
command=$HOME/.config/i3/clipster                         
interval=1
  • insert into $HOME/.config/i3/clipster
#!/bin/bash

shortlength=30;
content=`clipster -o -n 2`;

if [ ${#content} -gt 0 ]; then

  isFirstLineRead=false;

  firstLine="";
  secondLine="";

  while read -r line; do
    if [ "$isFirstLineRead" = false ]; then
      isFirstLineRead=true;
      firstLine=$line;
    else
      secondLine=$line;
    fi
  done <<< "$content"

  case $BLOCK_BUTTON in
    1) echo "$secondLine $firstLine" | clipster ;;
  esac

  if [ ${#firstLine} -gt 30 ]; then
    firstLine="${firstLine:0:20}...${firstLine: -10}"
  fi

  if [ ${#secondLine} -gt 30 ]; then
    secondLine="${secondLine:0:7}..."
  fi

  echo "$secondLine | $firstLine"

else
  echo "#empty#"
fi
  • add executable flag on $HOME/.config/i3/clipster
chmod +x $HOME/.config/i3/clipster
  • restart i3wm: i3-msg restart

The bash script could probably be clearer, improvements and other ideas are welcomed. I'll test it for a week and propose it to https://github.com/acleverpun/i3-blocks-contrib next weekend.

Have a nice day,

Alex

Double URL entries

I'm not exactly sure how this happens, but I am able to recreate on my system with three different browsers, so I assume it is related to clipster. This has been happening for a while as well, I've just been too lazy to document it.

It looks like any time a top level page's URL is copied, you get two entries in clipster, the second entry (the newer of the two) differs by having a trailing '/'.

Example:

https://www.google.com/
https://www.google.com
https://duckduckgo.com/
https://duckduckgo.com

This does not appear to happen for some urls with content after the '/, depending on what I assume is a relationship to certain special characters like '.' and '-'.

Example of non double entry:

https://github.com/qutebrowser/qutebrowser/blob/master/INSTALL.asciidoc

Thanks for your time.
-demure

Automatic pasting

I think this is a feature request, but perhaps I don't understand how best to use this. Would I would like to accomplish is that after clipster -s that if I press Enter on that screen, the output is pasted. I prefer this to needing to press paste afterwards.

Chrome generates duplicates in history, despite smart_update

The smart_update is not very reliable, when selecting text fast, it doesn't kick in and lets a lot of "incomplete" duplicate populate the history.

        text = safe_decode(text)

        if not self.config.getboolean('clipster', 'duplicates'):
            self.remove_history(board, text)
        diff = self.config.getint('clipster', 'smart_update')
        try:
            last_item = self.boards[board][-1]
        except IndexError:
            # List was empty
            last_item = ''
        # Check for growing or shrinking, but ignore duplicates
        if last_item and text != last_item and (text in last_item or last_item in text):
            # Make length difference a positive number before comparing
            if abs(len(text) - len(last_item)) <= diff:
                logging.debug("smart-update: removing.")
                # new selection is a longer/shorter version of previous
                self.boards[board].pop()

Why is diff compared here? Its value is supposed to be 1 here, how is that supposed to be efficient?
text will most likely be longer than last_item (at least when doing a selection from left to right), and there is a high chance the abs difference will yield something bigger than 1. Am I missing something?

Anyway, why is the history populating when "copy" is not even clicked on (in Chrome, after right-clicking)? Shouldn't it only populate when the clipboard is actually being updated? (the CLIPBOARD clipboard, not the PRIMARY clipboard if I understand right...)
It seems Clipster is emulating the "copy-on-selecting" from Linux in Chrome, which causes it to update the PRIMARY clipboard all the time... but then why is the CLIPBOARD clipboard updated as well?

Nice program, thanks for sharing. I'm interested because I'm trying to make a python script run automatically when the clipboard is updated. Clipster would be a nice module to use in other programs.

Allow to save specific clipboard history item(s) to file and edit and retrieve those.

I would find it neat to have clipster allow me to save a clipboard history item and associate a name to it.

On the command line, I see the following changes, add:

-w, --save PATTERN NAME
# Save all matching line history number under NAME

-e, --edit NAME
# Opens $EDITOR with the saved clipboard history as content

Update:

-o [NAME], --output [NAME]  Output last selection from history (or more, see -n) or saved clipboard history if NAME is given.

I totally agree that this could be done with just a hint of batch scripting, saving can be done with:

clipster -n 0 | grep PATTERN > ~/.config/clipster/saved/NAME

Editing with

$EDITOR ~/.config/clipster/saved/NAME

Copying back with:

clipster --ignore && clipster < ~/.config/clipster/saved/NAME

What I don't like about this last solution is the need to use grep, clipster daemon should be able to accept a PATTERN option so that it doesn't need to send everything back to the client.
That being said, I just would find it neater to be integrated.
What do you think? I'm okay to propose a PR.

Support Wayland

Currently clipster fails on wayland (wm: sway). The stacktrace reports that libwnck is "designed to work under X11 only".

I fear this is going to be difficult to fix. If I understand correctly, wayland makes getting data from other windows very difficult (for security reasons). Clipit too doesn't run on wayland.

Deleting items doesn't seem to work properly

It looks like clipster isn't properly deleting entries. For example if I were to create a clip:

echo '1234' | clipster -c

And then tried to delete that clip using the following commands:

echo '1234' | clipster -r
clipster -r '1234'
clipster -r

None of them seem to actually result in deleting the item from the clipboard.

By the way I absolutely love this clipboard daemon!

Option to sync the two clipboards

It might be useful to have any changes to a clipboard be copied to the other one, for those people who always want to use mouse selection/Ctrl-C/V and not have to work out which board a selection went to.

Points to note:

  • copying boards will trigger events which could result in an infinite copy loops. Stop event handling, or be clever with board content comparison to avoid this.
  • If this is enabled, if there any need to store separate histories? #12 is already asking for the option to not write one (or both?) boards, which would tie in here.

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.