Permalink
Browse files

added sorter, modified dmenuclip to use it and added the details to R…

…EADME.pod
  • Loading branch information...
1 parent 71d09f6 commit addd4b04ed7ffe9dda21158f8ab3aa28253f0cba Pablo Fredrikson committed Oct 24, 2013
Showing with 22 additions and 1 deletion.
  1. +3 −0 README.pod
  2. +2 −1 scripts/dmenuclip
  3. +17 −0 scripts/sorter
View
@@ -24,6 +24,9 @@ file for different purposes.
dmenuclip - launch dmenu listing all previously clipboarded content
+ sorter - it moves the content to the end of the file after using, so you
+ will have the last clipboarded content in the top of dmenuclip
+
=head1 OPTIONS
-l, --last show the n latest additions
View
@@ -4,6 +4,7 @@
use strict;
my $xsels = "$ENV{XDG_DATA_HOME}/clipbored/clips";
+my $sortercmd = "/usr/local/bin/sorter";
my $font = (exists $ENV{CLIPBORED_DMENU_FONT})
? $ENV{CLIPBORED_DMENU_FONT}
@@ -49,4 +50,4 @@ my $dmenu = "dmenu -i -b $list_mode "
. "-nb $normal_bg -nf $normal_fg -sb $select_bg -sf $select_fg";
my $dmenu_cmd = qq["\$(tac $xsels | $dmenu -fn $font -p dmenuclip)"];
-system("printf $dmenu_cmd | xclip -selection $x_buffer -i -l 0 | xclip -o");
+system("$sortercmd $xsels $dmenu_cmd | xclip -selection $x_buffer -i -l 0 | xclip -o");
View
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+
+## contributed by @godlike64
+## it takes the variable pattern and moves to the end of the file
+
+import sys
+filename = sys.argv[1]
+pattern = sys.argv[2]
+buffer = ""
+with open(filename, "r") as file_:
+ for line in file_:
+ if line.replace("\n", "") != pattern:
+ buffer = buffer + line
+with open(filename, "w") as file_:
+ file_.write(buffer)
+ file_.write(pattern + "\n")
+print(pattern)

0 comments on commit addd4b0

Please sign in to comment.