Skip to content

Commit

Permalink
add hook to remove if nvidia driver is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
gitbarnabedikartola committed Sep 20, 2023
1 parent 7e0a96d commit acc4757
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
12 changes: 12 additions & 0 deletions usr/share/libalpm/hooks/render-menu-options-remove.hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Trigger]
Type = Path
Operation = Remove

Target = usr/bin/optimus-manager
Target = usr/bin/prime-run
Target = usr/bin/switcherooctl

[Action]
Description = Remove Render Menu
When = PostTransaction
Exec = /usr/share/libalpm/scripts/render-menu-options-remove.sh
33 changes: 33 additions & 0 deletions usr/share/libalpm/scripts/render-menu-options-remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

IFS=$'\n'

folderType=(
/usr/share/applications
)
#if the flatpak directory exists add it to $folderType
if [ -d /var/lib/flatpak/exports/share/applications ];then
folderType+=(/var/lib/flatpak/exports/share/applications)
fi
#add users to $folderType
for user in $(awk -F':' '{ if ($3 >= 1000 && $1 != "nobody") print $1 }' /etc/passwd); do
folderType+=(/home/"${user}"/.local/share/applications)
done

RenderType=(
NvidiaRender
IntegratedRender
)

for render in ${RenderType[@]}; do
for folder in ${folderType[@]}; do
Applications=$(grep -sl "Action $render" $folder/*.desktop)
for App in ${Applications[@]}; do
#remove app from action=
sed -i "/Actions=/s/$render;//g" $App
#remove Desktop Action
sed -i "/Desktop Action $render/,/^$/d" $App
done
update-desktop-database $folder
done
done

0 comments on commit acc4757

Please sign in to comment.