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
     # Load single clip of choice
81
     # Load single clip of choice
82
     #
82
     #
83
     local clipname=$1
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
     cat $STORAGE_DIR/$name | xclip -i -selection $clipname
86
     cat $STORAGE_DIR/$name | xclip -i -selection $clipname
86
 }
87
 }
87
 
88
 
90
     # Remove single clip of choice
91
     # Remove single clip of choice
91
     #
92
     #
92
     local clipname=$1
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
     rm -f $STORAGE_DIR/$name
96
     rm -f $STORAGE_DIR/$name
95
 }
97
 }
96
 
98
 
104
     rmdir "$STORAGE_DIR" 2>/dev/null | :
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
 clipname=primary
116
 clipname=primary
109
 action=list_nice
117
 action=list_nice