aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoritz Meißelbach <m.meisselbach@inpsyde.com>2021-05-11 09:20:56 +0200
committerGitHub <noreply@github.com>2021-05-11 09:20:56 +0200
commit74ed255995f5935804235daf731471a422d44075 (patch)
treebc66b2208a1d126b2bb888bb0146a0bf40fec6ef
parentfda862a4d5958fa4fbc9668b99339c7a1e584584 (diff)
parent6fd48c02160e65b9f64fe0adf778be83a4a603ce (diff)
downloadsway-launcher-desktop-74ed255995f5935804235daf731471a422d44075.tar.gz
sway-launcher-desktop-74ed255995f5935804235daf731471a422d44075.zip
Merge pull request #42 from kubajaburek/master
Hide applications with NoDisplay=true
-rwxr-xr-xsway-launcher-desktop.sh8
-rw-r--r--tests/data/desktop-files/0/applications/nvim.desktop19
-rw-r--r--tests/data/desktop-files/0/applications/vim.desktop8
-rwxr-xr-xtests/entries.bats12
4 files changed, 43 insertions, 4 deletions
diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh
index 6da0101..555edba 100755
--- a/sway-launcher-desktop.sh
+++ b/sway-launcher-desktop.sh
@@ -113,6 +113,7 @@ function entries() {
}
BEGINFILE{
application=0;
+ hidden=0;
block="";
a=0
@@ -140,12 +141,15 @@ function entries() {
actions[a,"key"]=$0
}
/^Name=/{ (block=="action")? actions[a,"name"]=$2 : name=$2 }
+ /^NoDisplay=true/{ (block=="action")? actions[a,"hidden"]=1 : hidden=1 }
ENDFILE{
if (application){
- print FILENAME "\034desktop\034\033[33m" pre name "\033[0m";
+ if (!hidden)
+ print FILENAME "\034desktop\034\033[33m" pre name "\033[0m";
if (a>0)
for (i=1; i<=a; i++)
- print FILENAME "\034desktop\034\033[33m" pre name "\033[0m (" actions[i, "name"] ")\034" actions[i, "key"]
+ if (!actions[i, "hidden"])
+ print FILENAME "\034desktop\034\033[33m" pre name "\033[0m (" actions[i, "name"] ")\034" actions[i, "key"]
}
}' \
$@ </dev/null
diff --git a/tests/data/desktop-files/0/applications/nvim.desktop b/tests/data/desktop-files/0/applications/nvim.desktop
new file mode 100644
index 0000000..8897720
--- /dev/null
+++ b/tests/data/desktop-files/0/applications/nvim.desktop
@@ -0,0 +1,19 @@
+[Desktop Entry]
+Version=1.0
+Name=Neovim
+Type=Application
+Terminal=true
+Exec=nvim
+NoDisplay=true
+GenericName=Text Editor
+
+[Desktop Action new-file]
+Name=New File
+Terminal=true
+Exec=nvim
+
+[Desktop Action open-file]
+Name=Open File
+Terminal=true
+NoDisplay=true
+Exec=nvim
diff --git a/tests/data/desktop-files/0/applications/vim.desktop b/tests/data/desktop-files/0/applications/vim.desktop
new file mode 100644
index 0000000..b0d462e
--- /dev/null
+++ b/tests/data/desktop-files/0/applications/vim.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Version=1.0
+Name=Vim
+Type=Application
+Terminal=true
+Exec=vim
+NoDisplay=true
+GenericName=Text Editor
diff --git a/tests/entries.bats b/tests/entries.bats
index 0b50876..763dda7 100755
--- a/tests/entries.bats
+++ b/tests/entries.bats
@@ -22,12 +22,20 @@
@test "Wildcard expansion works for extraction of desktop files" {
run ../sway-launcher-desktop.sh entries data/desktop-files/0/applications/*.desktop
[ "$status" -eq 0 ]
- [[ ${#lines[@]} == 8 ]]
+ [[ ${#lines[@]} == 9 ]]
}
@test "Reoccurring desktop file ids are not parsed twice" {
run ../sway-launcher-desktop.sh entries data/desktop-files/**/*.desktop
echo "EXPECTED: foo-bar.desktop ACTUAL: $output"
[ "$status" -eq 0 ]
- [[ ${#lines[@]} == 8 ]]
+ [[ ${#lines[@]} == 9 ]]
+}
+
+@test "Hidden desktop entries are ignored" {
+ run ../sway-launcher-desktop.sh entries data/desktop-files/0/applications/*vim.desktop
+ [ "$status" -eq 0 ]
+ [[ ${#lines[@]} == 1 ]]
+ [[ ${lines[0]} =~ data/desktop-files/0/applications/nvim.desktop ]]
+ [[ ${lines[0]} =~ ^data/desktop-files/0/applications/nvim.desktop.*Neovim.*(New File).*new-file ]]
}