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 (7709 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 ; Bidi=1: no right-to-left reordering on the alternate screen, where fzf
38 ; runs. The preview can show Arabic or Hebrew text of a page, and mintty
39 ; would then move that text out of the preview box (see "Box layout with
40 ; right-to-left text" in the mintty manual).
41 !define MINTTYARGS "--class sbm -t sbm -s 120,32 -p center -o ConfirmExit=no -o Scrollbar=none -o Bidi=1 /bin/bash -lc bm"
42 !define WATCHARGS '--class sbm-watch -w hide /bin/bash -lc "exec bm-watch brave chrome chromium edge vivaldi"'
43 
44 Name "sbm ${VERSION}"
45 OutFile "${OUTFILE}"
46 RequestExecutionLevel admin
47 ShowInstDetails show
48 ShowUninstDetails show
49 
50 VIProductVersion "${VIVERSION}"
51 VIAddVersionKey "ProductName" "sbm"
52 VIAddVersionKey "ProductVersion" "${VERSION}"
53 VIAddVersionKey "FileVersion" "${VERSION}"
54 VIAddVersionKey "FileDescription" "sbm ${VERSION} installer"
55 VIAddVersionKey "LegalCopyright" "Spenser Truex"
56 
57 Var Cygwin
58 
59 Page instfiles
60 UninstPage uninstConfirm
61 UninstPage instfiles
62 
63 Function .onInit
64   ; Cygwin setup is a 64-bit program. It writes to the 64-bit registry.
65   SetRegView 64
66   ReadRegStr $Cygwin HKLM "Software\Cygwin\setup" "rootdir"
67   ${If} $Cygwin == ""
68     ReadRegStr $Cygwin HKCU "Software\Cygwin\setup" "rootdir"
69   ${EndIf}
70   ${IfNot} ${FileExists} "$Cygwin\bin\mintty.exe"
71     MessageBox MB_ICONSTOP "sbm needs Cygwin with mintty.$\r$\nInstall Cygwin from https://cygwin.com, then start this installer again."
72     Abort
73   ${EndIf}
74 FunctionEnd
75 
76 Section
77   ; An earlier version can run bm-watch. Stop it before its files change.
78   ; Use the sbm-setup of this installer. The sbm-setup of sbm 0.4 to 0.6
79   ; does not find tr in the PATH of Windows, so it does not stop bm-watch.
80   SetOutPath "$Cygwin\usr\local\libexec\sbm"
81   File "${SRC}\libexec\sbm-setup"
82   nsExec::ExecToLog '"$Cygwin\bin\sh.exe" /usr/local/libexec/sbm/sbm-setup stop'
83   Pop $0
84 
85   SetOutPath "$Cygwin\usr\local\bin"
86   File "${SRC}\bin\bm"
87   File "${SRC}\bin\bm-check"
88   File "${SRC}\bin\bm-commit"
89   File "${SRC}\bin\bm-html"
90   File "${SRC}\bin\bm-import"
91   File "${SRC}\bin\bm-migrate"
92   File "${SRC}\bin\bm-page"
93   File "${SRC}\bin\bm-sync"
94   File "${SRC}\bin\bm-title"
95   File "${SRC}\bin\bm-watch"
96   File "${SRC}\bin\fzf"
97   SetOutPath "$Cygwin\usr\local\libexec\sbm"
98   File "${SRC}\libexec\fzf.exe"
99   File "${SRC}\libexec\fzf-LICENSE.txt"
100   SetOutPath "$Cygwin\usr\local\share\sbm"
101   File "${SRC}\share\engines"
102   File "${SRC}\share\usertags"
103   File "${SRC}\share\LICENSE"
104   SetOutPath "$Cygwin\etc\profile.d"
105   File "${SRC}\etc\sbm.sh"
106 
107   ; Cygwin does not see an execute permission on files that a Windows
108   ; program makes. Cygwin chmod sets it.
109   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-page /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'
110   Pop $0
111   ${If} $0 != 0
112     Abort "chmod failed with exit status $0"
113   ${EndIf}
114 
115   nsExec::ExecToLog '"$Cygwin\bin\sh.exe" /usr/local/libexec/sbm/sbm-setup data'
116   Pop $0
117   ${If} $0 != 0
118     Abort "sbm-setup failed with exit status $0"
119   ${EndIf}
120 
121   ; bm-import reads the bookmarks of a browser with jq.
122   ${IfNot} ${FileExists} "$Cygwin\bin\jq.exe"
123     MessageBox MB_ICONEXCLAMATION|MB_OK "The browser import needs jq.$\r$\nInstall the jq package with Cygwin setup." /SD IDOK
124   ${EndIf}
125 
126   WriteUninstaller "$Cygwin\usr\local\libexec\sbm\uninstall.exe"
127 
128   SetShellVarContext current
129   CreateShortcut /NoWorkingDir "$DESKTOP\sbm.lnk" "$Cygwin\bin\mintty.exe" \
130     "${MINTTYARGS}" "$Cygwin\bin\mintty.exe" 0 SW_SHOWNORMAL \
131     ALT|CONTROL|SHIFT|F24 "sbm: bookmarks in fzf"
132   CreateShortcut /NoWorkingDir "$SMPROGRAMS\sbm.lnk" "$Cygwin\bin\mintty.exe" \
133     "${MINTTYARGS}" "$Cygwin\bin\mintty.exe" 0 SW_SHOWNORMAL "" \
134     "sbm: bookmarks in fzf"
135   CreateShortcut /NoWorkingDir "$SMSTARTUP\sbm-watch.lnk" "$Cygwin\bin\mintty.exe" \
136     '${WATCHARGS}' "$Cygwin\bin\mintty.exe" 0 SW_SHOWMINIMIZED "" \
137     "sbm: bring new browser bookmarks into bm"
138 
139   ; Start bm-watch now. Explorer starts it as the user, not as the
140   ; administrator that runs this installer.
141   Exec '"$WINDIR\explorer.exe" "$SMSTARTUP\sbm-watch.lnk"'
142 
143   WriteRegStr HKLM "${UNINSTKEY}" "DisplayName" "sbm"
144   WriteRegStr HKLM "${UNINSTKEY}" "DisplayVersion" "${VERSION}"
145   WriteRegStr HKLM "${UNINSTKEY}" "Publisher" "Spenser Truex"
146   WriteRegStr HKLM "${UNINSTKEY}" "URLInfoAbout" "https://github.com/equwal/sbm"
147   WriteRegStr HKLM "${UNINSTKEY}" "InstallLocation" "$Cygwin"
148   WriteRegStr HKLM "${UNINSTKEY}" "UninstallString" '"$Cygwin\usr\local\libexec\sbm\uninstall.exe"'
149   WriteRegDWORD HKLM "${UNINSTKEY}" "NoModify" 1
150   WriteRegDWORD HKLM "${UNINSTKEY}" "NoRepair" 1
151 SectionEnd
152 
153 Function un.onInit
154   SetRegView 64
155   ReadRegStr $Cygwin HKLM "${UNINSTKEY}" "InstallLocation"
156   ${IfNot} ${FileExists} "$Cygwin\bin\mintty.exe"
157     MessageBox MB_ICONSTOP "The registry does not give the Cygwin directory of sbm."
158     Abort
159   ${EndIf}
160 FunctionEnd
161 
162 Section Uninstall
163   nsExec::ExecToLog '"$Cygwin\bin\sh.exe" /usr/local/libexec/sbm/sbm-setup stop'
164   Pop $0
165 
166   Delete "$Cygwin\usr\local\bin\bm"
167   Delete "$Cygwin\usr\local\bin\bm-check"
168   Delete "$Cygwin\usr\local\bin\bm-commit"
169   Delete "$Cygwin\usr\local\bin\bm-html"
170   Delete "$Cygwin\usr\local\bin\bm-import"
171   Delete "$Cygwin\usr\local\bin\bm-migrate"
172   Delete "$Cygwin\usr\local\bin\bm-page"
173   Delete "$Cygwin\usr\local\bin\bm-sync"
174   Delete "$Cygwin\usr\local\bin\bm-title"
175   Delete "$Cygwin\usr\local\bin\bm-watch"
176   Delete "$Cygwin\usr\local\bin\fzf"
177   Delete "$Cygwin\usr\local\libexec\sbm\fzf.exe"
178   Delete "$Cygwin\usr\local\libexec\sbm\fzf-LICENSE.txt"
179   Delete "$Cygwin\usr\local\libexec\sbm\sbm-setup"
180   Delete "$Cygwin\usr\local\libexec\sbm\uninstall.exe"
181   RMDir "$Cygwin\usr\local\libexec\sbm"
182   Delete "$Cygwin\usr\local\share\sbm\engines"
183   Delete "$Cygwin\usr\local\share\sbm\usertags"
184   Delete "$Cygwin\usr\local\share\sbm\LICENSE"
185   RMDir "$Cygwin\usr\local\share\sbm"
186   Delete "$Cygwin\etc\profile.d\sbm.sh"
187   SetShellVarContext current
188   Delete "$DESKTOP\sbm.lnk"
189   Delete "$SMPROGRAMS\sbm.lnk"
190   Delete "$SMSTARTUP\sbm-watch.lnk"
191   DeleteRegKey HKLM "${UNINSTKEY}"
192 SectionEnd