Recently Written · git

sbm

dmenu bookmarks. Instantly fuzzy search thousands of bookmarks and plumb them. LOOKING FOR SUCKLESS SOFTWARE EDITION? GO TO sbm-suckless INSTEAD

git clone https://github.com/equwal/sbm

Log | Files | Refs


contrib/windows/sbm.nsi (7229 bytes)

1 ; sbm.nsi: the Windows installer of sbm. contrib/windows/build-installer.sh
2 ; runs makensis on this file.
3 ;
4 ; The installer needs Cygwin with mintty. It puts bm and the bm-* tools in
5 ; /usr/local/bin, fzf.exe in /usr/local/libexec/sbm, and the settings in
6 ; /etc/profile.d/sbm.sh. It makes a desktop shortcut and a Start menu entry
7 ; that open bm in a mintty window. The key of the desktop shortcut is
8 ; Ctrl+Alt+Shift+F24. Almost no keyboard has an F24 key, so keyboard firmware
9 ; can use this key combination without conflicts. Only one shortcut has the
10 ; key: when two shortcuts have the same key, Explorer can lose the key.
11 ;
12 ; A Startup entry runs bm-watch in a hidden mintty at each login. bm-watch
13 ; brings the bookmarks of the Chromium browsers into bm, and then the new
14 ; bookmarks as you add them. The installer also starts bm-watch at once.
15 ;
16 ; The uninstaller stops bm-watch and removes these files. It keeps the
17 ; bookmarks of the user.
18 
19 Unicode true
20 ManifestDPIAware true
21 !include LogicLib.nsh
22 
23 !ifndef VERSION
24   !error "Give the version, for example -DVERSION=0.3"
25 !endif
26 !ifndef VIVERSION
27   !error "Give the version in four numbers, for example -DVIVERSION=0.3.0.0"
28 !endif
29 !ifndef SRC
30   !error "Give the directory with the files to install, with -DSRC=dir"
31 !endif
32 !ifndef OUTFILE
33   !error "Give the name of the installer, with -DOUTFILE=file"
34 !endif
35 
36 !define UNINSTKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\sbm"
37 !define MINTTYARGS "--class sbm -t sbm -s 120,32 -p center -o ConfirmExit=no -o Scrollbar=none /bin/bash -lc bm"
38 !define WATCHARGS '--class sbm-watch -w hide /bin/bash -lc "exec bm-watch brave chrome chromium edge vivaldi"'
39 
40 Name "sbm ${VERSION}"
41 OutFile "${OUTFILE}"
42 RequestExecutionLevel admin
43 ShowInstDetails show
44 ShowUninstDetails show
45 
46 VIProductVersion "${VIVERSION}"
47 VIAddVersionKey "ProductName" "sbm"
48 VIAddVersionKey "ProductVersion" "${VERSION}"
49 VIAddVersionKey "FileVersion" "${VERSION}"
50 VIAddVersionKey "FileDescription" "sbm ${VERSION} installer"
51 VIAddVersionKey "LegalCopyright" "Spenser Truex"
52 
53 Var Cygwin
54 
55 Page instfiles
56 UninstPage uninstConfirm
57 UninstPage instfiles
58 
59 Function .onInit
60   ; Cygwin setup is a 64-bit program. It writes to the 64-bit registry.
61   SetRegView 64
62   ReadRegStr $Cygwin HKLM "Software\Cygwin\setup" "rootdir"
63   ${If} $Cygwin == ""
64     ReadRegStr $Cygwin HKCU "Software\Cygwin\setup" "rootdir"
65   ${EndIf}
66   ${IfNot} ${FileExists} "$Cygwin\bin\mintty.exe"
67     MessageBox MB_ICONSTOP "sbm needs Cygwin with mintty.$\r$\nInstall Cygwin from https://cygwin.com, then start this installer again."
68     Abort
69   ${EndIf}
70 FunctionEnd
71 
72 Section
73   ; An earlier version can run bm-watch. Stop it before its files change.
74   ${If} ${FileExists} "$Cygwin\usr\local\libexec\sbm\sbm-setup"
75     nsExec::ExecToLog '"$Cygwin\bin\sh.exe" /usr/local/libexec/sbm/sbm-setup stop'
76     Pop $0
77   ${EndIf}
78 
79   SetOutPath "$Cygwin\usr\local\bin"
80   File "${SRC}\bin\bm"
81   File "${SRC}\bin\bm-check"
82   File "${SRC}\bin\bm-commit"
83   File "${SRC}\bin\bm-html"
84   File "${SRC}\bin\bm-import"
85   File "${SRC}\bin\bm-migrate"
86   File "${SRC}\bin\bm-sync"
87   File "${SRC}\bin\bm-title"
88   File "${SRC}\bin\bm-watch"
89   File "${SRC}\bin\fzf"
90   SetOutPath "$Cygwin\usr\local\libexec\sbm"
91   File "${SRC}\libexec\fzf.exe"
92   File "${SRC}\libexec\fzf-LICENSE.txt"
93   File "${SRC}\libexec\sbm-setup"
94   SetOutPath "$Cygwin\usr\local\share\sbm"
95   File "${SRC}\share\engines"
96   File "${SRC}\share\usertags"
97   File "${SRC}\share\LICENSE"
98   SetOutPath "$Cygwin\etc\profile.d"
99   File "${SRC}\etc\sbm.sh"
100 
101   ; Cygwin does not see an execute permission on files that a Windows
102   ; program makes. Cygwin chmod sets it.
103   nsExec::ExecToLog '"$Cygwin\bin\chmod.exe" 755 /usr/local/bin/bm /usr/local/bin/bm-check /usr/local/bin/bm-commit /usr/local/bin/bm-html /usr/local/bin/bm-import /usr/local/bin/bm-migrate /usr/local/bin/bm-sync /usr/local/bin/bm-title /usr/local/bin/bm-watch /usr/local/bin/fzf /usr/local/libexec/sbm/fzf.exe'
104   Pop $0
105   ${If} $0 != 0
106     Abort "chmod failed with exit status $0"
107   ${EndIf}
108 
109   nsExec::ExecToLog '"$Cygwin\bin\sh.exe" /usr/local/libexec/sbm/sbm-setup data'
110   Pop $0
111   ${If} $0 != 0
112     Abort "sbm-setup failed with exit status $0"
113   ${EndIf}
114 
115   ; bm-import reads the bookmarks of a browser with jq.
116   ${IfNot} ${FileExists} "$Cygwin\bin\jq.exe"
117     MessageBox MB_ICONEXCLAMATION|MB_OK "The browser import needs jq.$\r$\nInstall the jq package with Cygwin setup." /SD IDOK
118   ${EndIf}
119 
120   WriteUninstaller "$Cygwin\usr\local\libexec\sbm\uninstall.exe"
121 
122   SetShellVarContext current
123   CreateShortcut /NoWorkingDir "$DESKTOP\sbm.lnk" "$Cygwin\bin\mintty.exe" \
124     "${MINTTYARGS}" "$Cygwin\bin\mintty.exe" 0 SW_SHOWNORMAL \
125     ALT|CONTROL|SHIFT|F24 "sbm: bookmarks in fzf"
126   CreateShortcut /NoWorkingDir "$SMPROGRAMS\sbm.lnk" "$Cygwin\bin\mintty.exe" \
127     "${MINTTYARGS}" "$Cygwin\bin\mintty.exe" 0 SW_SHOWNORMAL "" \
128     "sbm: bookmarks in fzf"
129   CreateShortcut /NoWorkingDir "$SMSTARTUP\sbm-watch.lnk" "$Cygwin\bin\mintty.exe" \
130     '${WATCHARGS}' "$Cygwin\bin\mintty.exe" 0 SW_SHOWMINIMIZED "" \
131     "sbm: bring new browser bookmarks into bm"
132 
133   ; Start bm-watch now. Explorer starts it as the user, not as the
134   ; administrator that runs this installer.
135   Exec '"$WINDIR\explorer.exe" "$SMSTARTUP\sbm-watch.lnk"'
136 
137   WriteRegStr HKLM "${UNINSTKEY}" "DisplayName" "sbm"
138   WriteRegStr HKLM "${UNINSTKEY}" "DisplayVersion" "${VERSION}"
139   WriteRegStr HKLM "${UNINSTKEY}" "Publisher" "Spenser Truex"
140   WriteRegStr HKLM "${UNINSTKEY}" "URLInfoAbout" "https://github.com/equwal/sbm"
141   WriteRegStr HKLM "${UNINSTKEY}" "InstallLocation" "$Cygwin"
142   WriteRegStr HKLM "${UNINSTKEY}" "UninstallString" '"$Cygwin\usr\local\libexec\sbm\uninstall.exe"'
143   WriteRegDWORD HKLM "${UNINSTKEY}" "NoModify" 1
144   WriteRegDWORD HKLM "${UNINSTKEY}" "NoRepair" 1
145 SectionEnd
146 
147 Function un.onInit
148   SetRegView 64
149   ReadRegStr $Cygwin HKLM "${UNINSTKEY}" "InstallLocation"
150   ${IfNot} ${FileExists} "$Cygwin\bin\mintty.exe"
151     MessageBox MB_ICONSTOP "The registry does not give the Cygwin directory of sbm."
152     Abort
153   ${EndIf}
154 FunctionEnd
155 
156 Section Uninstall
157   nsExec::ExecToLog '"$Cygwin\bin\sh.exe" /usr/local/libexec/sbm/sbm-setup stop'
158   Pop $0
159 
160   Delete "$Cygwin\usr\local\bin\bm"
161   Delete "$Cygwin\usr\local\bin\bm-check"
162   Delete "$Cygwin\usr\local\bin\bm-commit"
163   Delete "$Cygwin\usr\local\bin\bm-html"
164   Delete "$Cygwin\usr\local\bin\bm-import"
165   Delete "$Cygwin\usr\local\bin\bm-migrate"
166   Delete "$Cygwin\usr\local\bin\bm-sync"
167   Delete "$Cygwin\usr\local\bin\bm-title"
168   Delete "$Cygwin\usr\local\bin\bm-watch"
169   Delete "$Cygwin\usr\local\bin\fzf"
170   Delete "$Cygwin\usr\local\libexec\sbm\fzf.exe"
171   Delete "$Cygwin\usr\local\libexec\sbm\fzf-LICENSE.txt"
172   Delete "$Cygwin\usr\local\libexec\sbm\sbm-setup"
173   Delete "$Cygwin\usr\local\libexec\sbm\uninstall.exe"
174   RMDir "$Cygwin\usr\local\libexec\sbm"
175   Delete "$Cygwin\usr\local\share\sbm\engines"
176   Delete "$Cygwin\usr\local\share\sbm\usertags"
177   Delete "$Cygwin\usr\local\share\sbm\LICENSE"
178   RMDir "$Cygwin\usr\local\share\sbm"
179   Delete "$Cygwin\etc\profile.d\sbm.sh"
180   SetShellVarContext current
181   Delete "$DESKTOP\sbm.lnk"
182   Delete "$SMPROGRAMS\sbm.lnk"
183   Delete "$SMSTARTUP\sbm-watch.lnk"
184   DeleteRegKey HKLM "${UNINSTKEY}"
185 SectionEnd