Browse Source

Move clip selection to separate function

Alois Mahdal 9 years ago
parent
commit
4494cc4dad
1 changed files with 10 additions and 2 deletions
  1. 10
    2
      src/libexec/saturnin-clip

+ 10
- 2
src/libexec/saturnin-clip View File

@@ -81,7 +81,8 @@ load_clip() {
81 81
     # Load single clip of choice
82 82
     #
83 83
     local clipname=$1
84
-    local name=$(saturnin clip ls | saturnin dmenu | cut -d\   -f 1)
84
+    local name=$(pick_clip)
85
+    test -n "$name" || return 1
85 86
     cat $STORAGE_DIR/$name | xclip -i -selection $clipname
86 87
 }
87 88
 
@@ -90,7 +91,8 @@ rm_clip() {
90 91
     # Remove single clip of choice
91 92
     #
92 93
     local clipname=$1
93
-    local name=$(saturnin clip ls | saturnin dmenu | cut -d\   -f 1)
94
+    local name=$(pick_clip)
95
+    test -n "$name" || return 1
94 96
     rm -f $STORAGE_DIR/$name
95 97
 }
96 98
 
@@ -104,6 +106,12 @@ rm_all() {
104 106
     rmdir "$STORAGE_DIR" 2>/dev/null | :
105 107
 }
106 108
 
109
+pick_clip() {
110
+    saturnin clip ls \
111
+      | saturnin dmenu \
112
+      | cut -d\   -f 1
113
+}
114
+
107 115
 
108 116
 clipname=primary
109 117
 action=list_nice